Exemple #1
0
 /**
  * {@inheritdoc}
  */
 public function load($name, array $config)
 {
     if (isset($config['events'])) {
         foreach ($config['events'] as $event => $listener) {
             $this->app->on($event, $listener);
         }
     }
     return $config;
 }
 /**
  * {@inheritdoc}
  */
 public function load(Application $app, array $config)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.application.component.helper');
     $app['db'] = function () {
         return new Database(JFactory::getDBO());
     };
     $app['url'] = function ($app) {
         return new UrlGenerator($app['request'], $app['locator']);
     };
     $app['request'] = function ($app) {
         $baseUrl = rtrim(JURI::root(false), '/');
         $basePath = rtrim(strtr(JPATH_ROOT, '\\', '/'), '/');
         $baseRoute = 'index.php';
         if (isset($app['component'])) {
             $baseRoute .= '?option=' . $app['component'];
         }
         return new Request($baseUrl, $basePath, $baseRoute);
     };
     $app['response'] = function ($app) {
         return new ResponseProvider($app['url']);
     };
     $app['csrf'] = function () {
         return new CsrfProvider();
     };
     $app['users'] = function ($app) {
         return new UserProvider($app['component'], isset($app['permissions']) ? $app['permissions'] : array());
     };
     $app['option'] = function ($app) {
         return new Option($app['path.cache'], $app['name']);
     };
     $app['locale'] = function ($app) {
         return str_replace('-', '_', $app['joomla.language']->get('tag'));
     };
     $app['admin'] = function ($app) {
         return $app['joomla']->isAdmin();
     };
     $app['joomla'] = function () {
         return JFactory::getApplication();
     };
     $app['joomla.config'] = function () {
         return JFactory::getConfig();
     };
     $app['joomla.language'] = function () {
         return JFactory::getLanguage();
     };
     $app['joomla.document'] = function () {
         return JFactory::getDocument();
     };
     $app['joomla.article'] = function () {
         return new ArticleHelper();
     };
     $app->on('boot', array($this, 'boot'));
     $app->on('view', array($this, 'registerAssets'), -10);
 }
Exemple #3
0
 /**
  * Loads all plugins.
  *
  * @param Application $app
  */
 public function load(Application $app)
 {
     foreach ($this->loadConfigs() as $name => $config) {
         if (isset($this->plugins[$name])) {
             continue;
         }
         if (isset($config['autoload'])) {
             foreach ($config['autoload'] as $namespace => $path) {
                 $app['autoloader']->addPsr4($namespace, $config['path'] . "/{$path}");
             }
         }
         if (isset($config['events'])) {
             foreach ($config['events'] as $event => $listener) {
                 $app->on($event, $listener);
             }
         }
         if (is_string($class = $config['main'])) {
             $plugin = new $class();
             if ($plugin instanceof ApplicationAware) {
                 $plugin->setApplication($app);
             }
             if ($plugin instanceof PluginInterface) {
                 $plugin->load($app, $config);
             }
             $this->plugins[$name] = $plugin;
         } elseif (is_callable($config['main'])) {
             $this->plugins[$name] = call_user_func($config['main'], $app, $config) ?: true;
         }
     }
 }
    /**
     * {@inheritdoc}
     */
    public function main(Application $app)
    {
        $app['angular'] = $this;
        $app['controllers']->map('template', array($this, 'templateAction'));

        $app->on('boot', array($this, 'boot'));
    }
Exemple #5
0
 /**
  * {@inheritdoc}
  */
 public function main(Application $app)
 {
     jimport('joomla.filesystem.folder');
     jimport('joomla.application.component.helper');
     $app['db'] = function () {
         return new Database(JFactory::getDBO());
     };
     $app['url'] = function ($app) {
         return new UrlGenerator($app['request'], $app['locator']);
     };
     $app['request'] = function ($app) {
         $baseUrl = rtrim(JURI::root(false), '/');
         $basePath = rtrim(strtr(JPATH_ROOT, '\\', '/'), '/');
         $baseRoute = 'index.php';
         if (isset($app['component'])) {
             $baseRoute .= '?option=' . $app['component'];
         }
         return new Request($baseUrl, $basePath, $baseRoute);
     };
     $app['response'] = function ($app) {
         return new ResponseProvider($app['url']);
     };
     $app['csrf'] = function () {
         return new CsrfProvider();
     };
     $app['users'] = function ($app) {
         return new UserProvider($app['component'], isset($app['permissions']) ? $app['permissions'] : array());
     };
     $app['date'] = function () {
         $date = new DateHelper();
         $date->setFormats(array('full' => JText::_('DATE_FORMAT_LC2'), 'long' => JText::_('DATE_FORMAT_LC3'), 'medium' => JText::_('DATE_FORMAT_LC1'), 'short' => JText::_('DATE_FORMAT_LC4')));
         return $date;
     };
     $app['locale'] = function ($app) {
         return str_replace('-', '_', $app['joomla.language']->get('tag'));
     };
     $app['admin'] = function ($app) {
         return $app['joomla']->isAdmin();
     };
     $app['session'] = function () {
         return JFactory::getSession();
     };
     $app['joomla'] = function () {
         return JFactory::getApplication();
     };
     $app['joomla.config'] = function () {
         return JFactory::getConfig();
     };
     $app['joomla.language'] = function () {
         return JFactory::getLanguage();
     };
     $app['joomla.document'] = function () {
         return JFactory::getDocument();
     };
     $app['joomla.article'] = function () {
         return new ArticleHelper();
     };
     $app->extend('filter', function ($filter) {
         return $filter->register('content', new ContentFilter());
     });
     $app->on('boot', array($this, 'boot'));
     $app->on('view', array($this, 'registerAssets'), -10);
 }
Exemple #6
0
 /**
  * {@inheritdoc}
  */
 public function load(Application $app, array $config)
 {
     $app['angular'] = $this;
     $app->on('boot', array($this, 'boot'));
     $app->map('template', array($this, 'templateAction'));
 }
Exemple #7
0
 /**
  * {@inheritdoc}
  */
 public function main(Application $app)
 {
     $app['db'] = function () {
         return new Database(\Yii::$app->db);
     };
     $app['url'] = function ($app) {
         return new UrlGenerator($app['request'], $app['locator'], $app['name']);
     };
     $app['request'] = function () {
         //$baseUrl  = ltrim(\Yii::$app->homeUrl, '/');
         $baseUrl = rtrim(Url::home(true), '/');
         $basePath = rtrim(strtr(\Yii::getAlias('@webroot'), '\\', '/'), '/');
         $request = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() ? array_map('stripslashes_deep', $_REQUEST) : $_REQUEST;
         return new Request($baseUrl, $basePath, $request);
     };
     $app['response'] = function ($app) {
         return new ResponseProvider($app['url']);
     };
     $app['csrf'] = function () {
         return new CsrfProvider();
     };
     $app['locale'] = function () {
         return str_replace('-', '_', \Yii::$app->language);
     };
     $app['users'] = function () {
         return new UserProvider();
     };
     $app['option'] = function ($app) {
         return new Option($app['name'] . '-');
     };
     $app['yii'] = function () {
         return \Yii::$app->view;
     };
     $app['admin'] = function ($app) {
         return $app['yii']->isAdmin();
     };
     $app['update'] = function () {
         return new Update();
     };
     $app->extend('filter', function ($filter) {
         return $filter->register('content', new ContentFilter());
     });
     $app->on('boot', array($this, 'boot'));
     $app->on('view', array($this, 'registerAssets'), -10);
 }