public function __construct(array $values = array()) { $this->application_name = ''; $this->session_segment_name = null; $this->basePath = null; $this->templatePath = null; $this->languagePath = null; $this->temporaryPath = null; $this->filesystemBase = null; $this->sqlPath = null; parent::__construct($values); // Application service if (!isset($this['application'])) { $this['application'] = function (Container $c) { return Application::getInstance($c->application_name, $c); }; } // Application Configuration service if (!isset($this['appConfig'])) { $this['appConfig'] = function (Container $c) { return new \Awf\Application\Configuration($c); }; } // Database Driver service if (!isset($this['db'])) { $this['db'] = function (Container $c) { return Driver::getInstance($c); }; } // Application Dispatcher service if (!isset($this['dispatcher'])) { $this['dispatcher'] = function (Container $c) { $className = '\\' . ucfirst($c->application_name) . '\\Dispatcher'; if (!class_exists($className)) { $className = '\\Awf\\Dispatcher\\Dispatcher'; } return new $className($c); }; } // Application Event Dispatcher service if (!isset($this['eventDispatcher'])) { $this['eventDispatcher'] = function (Container $c) { return new \Awf\Event\Dispatcher($c); }; } // Filesystem Abstraction Layer service if (!isset($this['fileSystem'])) { $this['fileSystem'] = function (Container $c) { return \Awf\Filesystem\Factory::getAdapter($c, true); }; } // Input Access service if (!isset($this['input'])) { $this['input'] = function (Container $c) { return new \Awf\Input\Input(); }; } // Mailer Object service if (!isset($this['mailer'])) { $this['mailer'] = $this->factory(function (Container $c) { return new \Awf\Mailer\Mailer($c); }); } // Application Router service if (!isset($this['router'])) { $this['router'] = function (Container $c) { return new \Awf\Router\Router($c); }; } // Session Manager service if (!isset($this['session'])) { $this['session'] = function () { return new Session\Manager(new Session\SegmentFactory(), new Session\CsrfTokenFactory(new Session\Randval(new Phpfunc())), $_COOKIE); }; } // Application Session Segment service if (!isset($this['segment'])) { $this['segment'] = function (Container $c) { if (empty($c->session_segment_name)) { $c->session_segment_name = 'Akeeba\\Awf\\' . $c->application_name; } return $c->session->newSegment($c->session_segment_name); }; } // User Manager service if (!isset($this['userManager'])) { $this['userManager'] = function (Container $c) { return new \Awf\User\Manager($c); }; } }
/** * Gets the date as an SQL datetime string. * * @param boolean $local True to return the date string in the local time zone, false to return it in GMT. * @param Driver $db The database driver or null to use JFactory::getDbo() * * @return string The date string in SQL datetime format. * * @link http://dev.mysql.com/doc/refman/5.0/en/datetime.html */ public function toSql($local = false, Driver $db = null) { if ($db === null) { $db = Driver::getInstance(); } return $this->format($db->getDateFormat(), $local); }
public function __construct(array $values = array()) { $appNameForPaths = $values['application_name']; if (Helper::isBackend() && substr($appNameForPaths, -5) == 'Admin') { $appNameForPaths = substr($appNameForPaths, 0, -5); } // Set up the filesystem path if (empty($values['filesystemBase'])) { $values['filesystemBase'] = JPATH_ROOT; } // Set up the base path if (empty($values['basePath'])) { $basePath = '/components/com_' . $appNameForPaths . '/' . $values['application_name']; $values['basePath'] = (Helper::isBackend() ? JPATH_ADMINISTRATOR : JPATH_ROOT) . $basePath; } // Set up the template path if (empty($values['templatePath'])) { $values['templatePath'] = __DIR__ . '/../templates'; } // Set up the temporary path if (empty($values['temporaryPath'])) { $values['temporaryPath'] = \JFactory::getConfig()->get('tmp_path', sys_get_temp_dir()); } // Set up the language path if (empty($values['languagePath'])) { $values['languagePath'] = (Helper::isBackend() ? JPATH_ADMINISTRATOR : JPATH_ROOT) . '/language'; } // Set up the SQL files path if (empty($values['sqlPath'])) { $values['sqlPath'] = JPATH_ADMINISTRATOR . '/components/com_' . $appNameForPaths . '/sql/xml'; } // Application service if (!isset($this['application'])) { $this['application'] = function (Container $c) { return Application::getInstance($c->application_name, $c); }; } // Session Manager service if (!isset($this['session'])) { $this['session'] = function () { return new \Awf\Platform\Joomla\Session\Manager(new \Awf\Platform\Joomla\Session\SegmentFactory(), new \Awf\Platform\Joomla\Session\CsrfTokenFactory()); }; } // Application Session Segment service if (!isset($this['segment'])) { $this['segment'] = function (Container $c) { if (empty($c->session_segment_name)) { $c->session_segment_name = $c->application_name; } return $c->session->newSegment($c->session_segment_name); }; } // Database Driver service if (!isset($this['db'])) { $this['db'] = function (Container $c) { $db = \JFactory::getDbo(); $options = array('connection' => $db->getConnection(), 'prefix' => $db->getPrefix(), 'driver' => 'mysqli'); switch ($db->name) { case 'mysql': $options['driver'] = 'Mysql'; break; default: case 'mysqli': $options['driver'] = 'Mysqli'; break; case 'sqlsrv': case 'mssql': case 'sqlazure': $options['driver'] = 'Sqlsrv'; break; case 'postgresql': $options['driver'] = 'Postgresql'; break; case 'pdo': $options['driver'] = 'Pdo'; break; case 'sqlite': $options['driver'] = 'Sqlite'; break; } return Driver::getInstance($options); }; } // Application Event Dispatcher service if (!isset($this['eventDispatcher'])) { $this['eventDispatcher'] = function (Container $c) { return new Dispatcher($c); }; } // Application Configuration service if (!isset($values['appConfig'])) { $values['appConfig'] = function (Container $c) { return new Configuration($c); }; } // Application Router service if (!isset($values['router'])) { $values['router'] = function (Container $c) { return new Router($c); }; } // User Manager service if (!isset($values['userManager'])) { $values['userManager'] = function (Container $c) { return new Manager($c); }; } parent::__construct($values); // Mailer Object service – returns a Joomla! JMail object // IMPORTANT! It has to appear AFTER the parent __construct method $this['mailer'] = $this->factory(function (Container $c) { return \JFactory::getMailer(); }); }