และตอนนี้อยู่ใน Not ready tasks หมายความว่ามันจะไม่ทำงานหรือเปล่าค่ะ (ใช้ Cron status เช็คสถานะค่ะ) code ในส่วนของ cron
Code: Select all
<?php
namespace mindphp\m_trending\cron;
/**
* @ignore
*/
class trending_data extends \phpbb\cron\task\base {
protected $user;
protected $config;
protected $config_text;
protected $db;
protected $log;
protected $phpbb_root_path;
protected $php_ext;
public function __construct(\phpbb\user $user, \phpbb\config\config $config, \phpbb\config\db_text $config_text, \phpbb\db\driver\driver_interface $db, \phpbb\log\log $log, $table_prefix, $phpbb_root_path, $php_ext) {
$this->user = $user;
$this->config = $config;
$this->config_text = $config_text;
$this->db = $db;
$this->log = $log;
$this->table_prefix = $table_prefix;
$this->phpbb_root_path = $phpbb_root_path;
$this->php_ext = $php_ext;
}
public function run() { //ไม่ทำงาน ต่อให้กด run ก็ไม่ทำงานค่ะ
$this->user->add_lang_ext('mindphp/m_trending', 'acp/info_acp_m_trending');
$this->get_trending_topic();
global $phpbb_log;
date_default_timezone_set($this->config['board_timezone']);
$this->config->set('time_trending_data_last_gc',time(),TRUE);
$this->log->add('admin', 2, '127.0.0.1', 'sample.run');
}
public function is_runnable() { //ทำงานได้
$this->log->add('admin', 2, '127.0.0.1', 'sample.is_runnable');
return (bool) $this->config['m_trending_alert'];
}
function should_run() { //ทำงานได้
$this->log->add('admin', 2, '127.0.0.1', 'sample.should_run');
date_default_timezone_set($this->config['board_timezone']);
return $this->config['time_trending_data_last_gc'] < time() - $this->config['time_trending_data_gc'];
// return TRUE;
}
public function get_trending_topic() { //ไม่ทำงาน
$this->log->add('admin', 2, '127.0.0.1', 'Sucess Trending', time());
}
}