本文整理汇总了PHP中JApplicationCli::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCli::__construct方法的具体用法?PHP JApplicationCli::__construct怎么用?PHP JApplicationCli::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JApplicationCli
的用法示例。
在下文中一共展示了JApplicationCli::__construct方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Overrides JGithub constructor to initialise the api property.
*
* @param mixed $input An optional argument to provide dependency injection for the application's
* input object. If the argument is a JInputCli object that object will become
* the application's input object, otherwise a default input object is created.
* @param mixed $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
* event dispatcher. If the argument is a JDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
* @see loadDispatcher()
* @since 11.1
*/
public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
{
parent::__construct($input, $config, $dispatcher);
$options = new JRegistry();
$options->set('headers.Accept', 'application/vnd.github.html+json');
$this->api = new JGithub($options);
}
示例2: __construct
public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
{
// CLI Constructor
parent::__construct($input, $config, $dispatcher);
// Utilities
$this->db = JFactory::getDBO();
$this->updater = JUpdater::getInstance();
$this->installer = JComponentHelper::getComponent('com_installer');
// Validate Log Path
$logPath = $this->config->get('log_path');
if (!is_dir($logPath) || !is_writeable($logPath)) {
$logPath = JPATH_BASE . '/logs';
if (!is_dir($logPath) || !is_writeable($logPath)) {
$this->out('Log Path not found - ' . $logPath);
}
$this->config->set('log_path', JPATH_BASE . '/logs');
}
// Validate Tmp Path
$tmpPath = $this->config->get('tmp_path');
if (!is_writeable($tmpPath)) {
$tmpPath = JPATH_BASE . '/tmp';
if (!is_dir($tmpPath) || !is_writeable($tmpPath)) {
$this->out('Tmp Path not found - ' . $tmpPath);
}
$this->config->set('tmp_path', JPATH_BASE . '/tmp');
}
// Push to Global Config
$config = JFactory::getConfig();
$config->set('tmp_path', $this->config->get('tmp_path'));
$config->set('log_path', $this->config->get('log_path'));
}
示例3: __construct
/**
* Class constructor.
*
* This constructor invokes the parent JApplicationCli class constructor,
* and then creates a connector to the database so that it is
* always available to the application when needed.
*
* @since 11.3
* @throws JDatabaseException
*/
public function __construct()
{
// Call the parent __construct method so it bootstraps the application class.
parent::__construct();
jimport('joomla.database.database');
$this->dbo = JFactory::getDbo();
$this->app = JFactory::getApplication('site');
$this->config = JFactory::getConfig();
}
示例4: __construct
/**
* Class constructor.
*
* This constructor invokes the parent JApplicationCli class constructor,
* and then creates a connector to the database so that it is
* always available to the application when needed.
*
*/
public function __construct()
{
// Call the parent __construct method so it bootstraps the application class.
parent::__construct();
jimport('joomla.database.database');
// Note, this will throw an exception if there is an error
// creating the database connection.
$this->dbo = JDatabase::getInstance(array('driver' => $this->get('dbDriver'), 'host' => $this->get('dbHost'), 'user' => $this->get('dbUser'), 'password' => $this->get('dbPass'), 'database' => $this->get('dbName'), 'prefix' => $this->get('dbPrefix')));
}
示例5: __construct
/**
* Class constructor.
*
* This constructor invokes the parent JApplicationCli class constructor,
* and then creates a connector to the database so that it is
* always available to the application when needed.
*
* @since 11.3
* @throws JDatabaseException
*/
public function __construct()
{
// Call the parent __construct method so it bootstraps the application class.
parent::__construct();
//
// Prepare the logger.
//
// Include the JLog class.
jimport('joomla.log.log');
// Get the date so that we can roll the logs over a time interval.
$date = JFactory::getDate()->format('Y-m-d');
// Add the logger.
JLog::addLogger(array('text_file' => 'cron.' . $date . '.php', 'text_file_path' => __DIR__ . '/logs'));
//
// Prepare the database connection.
//
jimport('joomla.database.database');
// Note, this will throw an exception if there is an error
// creating the database connection.
$this->dbo = JDatabase::getInstance(array('driver' => $this->get('dbDriver'), 'host' => $this->get('dbHost'), 'user' => $this->get('dbUser'), 'password' => $this->get('dbPass'), 'database' => $this->get('dbName'), 'prefix' => $this->get('dbPrefix')));
}
示例6: __construct
/**
* Class constructor.
*
* @param mixed $input An optional argument to provide dependency injection for the application's
* input object. If the argument is a JInputCli object that object will become
* the application's input object, otherwise a default input object is created.
* @param mixed $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
* event dispatcher. If the argument is a JDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
* @since 11.1
* @throws RuntimeException
*/
public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
{
// Verify that the process control extension for PHP is available.
// @codeCoverageIgnoreStart
if (!defined('SIGHUP')) {
JLog::add('The PCNTL extension for PHP is not available.', JLog::ERROR);
throw new RuntimeException('The PCNTL extension for PHP is not available.');
}
// Verify that POSIX support for PHP is available.
if (!function_exists('posix_getpid')) {
JLog::add('The POSIX extension for PHP is not available.', JLog::ERROR);
throw new RuntimeException('The POSIX extension for PHP is not available.');
}
// @codeCoverageIgnoreEnd
// Call the parent constructor.
parent::__construct($input, $config, $dispatcher);
// Set some system limits.
@set_time_limit($this->config->get('max_execution_time', 0));
if ($this->config->get('max_memory_limit') !== null) {
ini_set('memory_limit', $this->config->get('max_memory_limit', '256M'));
}
// Flush content immediately.
ob_implicit_flush();
}
示例7: __construct
/**
* Class constructor.
*
* @param mixed $input An optional argument to provide dependency injection for the application's
* input object. If the argument is a JInputCli object that object will become
* the application's input object, otherwise a default input object is created.
* @param mixed $config An optional argument to provide dependency injection for the application's
* config object. If the argument is a JRegistry object that object will become
* the application's config object, otherwise a default config object is created.
* @param mixed $dispatcher An optional argument to provide dependency injection for the application's
* event dispatcher. If the argument is a JEventDispatcher object that object will become
* the application's event dispatcher, if it is null then the default event dispatcher
* will be created based on the application's loadDispatcher() method.
*
* @see loadDispatcher()
* @since 11.1
* @deprecated 12.3 Use JApplicationCli instead.
*/
public function __construct(JInputCli $input = null, JRegistry $config = null, JEventDispatcher $dispatcher = null)
{
JLog::add('JCli is deprecated. Use JApplicationCli instead.', JLog::WARNING, 'deprecated');
parent::__construct($input, $config, $dispatcher);
}
示例8: __construct
/**
* [__construct description]
* @param JInputCli|null $input [description]
* @param JRegistry|null $config [description]
* @param JDispatcher|null $dispatcher [description]
*/
public function __construct(JInputCli $input = null, JRegistry $config = null, JDispatcher $dispatcher = null)
{
// CLI Constructor
parent::__construct($input, $config, $dispatcher);
// Error Handlers
JError::setErrorHandling(E_NOTICE, 'callback', array($this, 'throwNotice'));
JError::setErrorHandling(E_WARNING, 'callback', array($this, 'throwWarning'));
JError::setErrorHandling(E_ERROR, 'callback', array($this, 'throwError'));
// Utilities
$this->db = JFactory::getDBO();
$this->updater = JUpdater::getInstance();
$this->installer = JComponentHelper::getComponent('com_installer');
// Validate Log Path
$logPath = $this->config->get('log_path');
if (!is_dir($logPath) || !is_writeable($logPath)) {
$logPath = JPATH_BASE . '/logs';
if (!is_dir($logPath) || !is_writeable($logPath)) {
$this->out('Log Path not found - ' . $logPath);
}
$this->config->set('log_path', JPATH_BASE . '/logs');
}
// Validate Tmp Path
$tmpPath = $this->config->get('tmp_path');
if (!is_writeable($tmpPath)) {
$tmpPath = JPATH_BASE . '/tmp';
if (!is_dir($tmpPath) || !is_writeable($tmpPath)) {
$this->out('Tmp Path not found - ' . $tmpPath);
}
$this->config->set('tmp_path', JPATH_BASE . '/tmp');
}
// Push to Global Config
$config = JFactory::getConfig();
$config->set('tmp_path', $this->config->get('tmp_path'));
$config->set('log_path', $this->config->get('log_path'));
}