/** * {@inheritdoc} */ public function main(Application $app) { $app['angular'] = $this; $app['controllers']->map('template', array($this, 'templateAction')); $app->on('boot', array($this, 'boot')); }
/** * 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 load($name, array $config) { if (isset($config['events'])) { foreach ($config['events'] as $event => $listener) { $this->app->on($event, $listener); } } return $config; }
/** * Constructor. * * @param array $values */ public function __construct(array $values = array()) { parent::__construct($values); $this['content'] = new ContentProvider($this); $this['image'] = new ImageProvider($this); $this['shortcode'] = new Shortcode; $this['types'] = new Collection; $this['widgets'] = new Collection; $this->extend('locator', function ($locator, $app) { return $locator->addPath('', $app['path']); }); $this->extend('translator', function ($translator, $app) { return $translator->addResource('languages/'.$app['locale'].'.json'); }); $this->on('boot', function ($event, $app) { $app['plugins']->addPath($app['path'].'/plugins/*/*/plugin.php'); foreach ($app['templates'] as $path) { $app['locator']->addPath('plugins', $path); $app['plugins']->addPath($path.'/*/*/plugin.php'); } }); $this['events']->subscribe($this); }
/** * Registers Joomla component integration. */ protected function registerComponent(Application $app) { $app['joomla']->registerEvent('onAfterDispatch', function () use($app) { if ($app['component'] !== ($app['admin'] ? JAdministratorHelper::findOption() : $app['joomla']->input->get('option'))) { return; } $response = $app->handle(null, false); if ($response->getStatus() != 200) { $app['joomla']->setHeader('status', $response->getStatus()); } if ($response instanceof JsonResponse) { JRequest::setVar('format', 'json'); $app['joomla']->loadDocument(JDocument::getInstance('json')->setBuffer((string) $response)); } elseif ($response instanceof RawResponse) { JRequest::setVar('format', 'raw'); $app['joomla']->loadDocument(JDocument::getInstance('raw')->setBuffer((string) $response)); } else { $app['joomla.document']->setBuffer((string) $response, 'component'); } }); }
/** * {@inheritdoc} */ public function load(Application $app, array $config) { $app['angular'] = $this; $app->on('boot', array($this, 'boot')); $app->map('template', array($this, 'templateAction')); }
/** * Callback for 'boot' event. */ public function boot(Event $event, Application $app) { if (!is_dir($app['path.cache']) && !mkdir($app['path.cache'], 0777, true)) { throw new \RuntimeException(sprintf('Unable to create cache folder in "%s"', $app['path.cache'])); } $this->init(); $app->trigger('init', array($app)); $app['yii']->on(\yii\web\View::EVENT_BEGIN_BODY, function () use($app) { $app->trigger('view', array($app)); }); }