/**
  * @param Application $app
  */
 public function boot(Application $app)
 {
     $options = $this->options;
     $app->getDI()->setShared('aws', function () use($options) {
         $aws = Aws::factory($options);
         $aws->getEventDispatcher()->addListener('service_builder.create_client', function (Event $event) {
             $clientConfig = $event['client']->getConfig();
             $commandParams = $clientConfig->get(Client::COMMAND_PARAMS) ?: array();
             $clientConfig->set(Client::COMMAND_PARAMS, array_merge_recursive($commandParams, array(UserAgentListener::OPTION => 'Phalcon/' . Application::VERSION)));
         });
         return $aws;
     });
 }
示例#2
0
 /**
  * 自定义服务注入
  *
  */
 protected function customServices()
 {
     $di = $this->application->getDI();
     // 自定义服务
     $this->application->setDI($di);
 }
示例#3
0
 public function beforeStartModule(Event $event, PhalconApp $app, $moduleName)
 {
     $di = $app->getDI();
     $config = $di->get('config');
     $this->setViewService($di, $config, $moduleName)->setUrlService($di, $config, $moduleName);
 }
示例#4
0
 /**
  * Setup the phalcon application.
  *
  * @param null $uri
  * @return string
  */
 protected function applicationSetup($uri = null)
 {
     $app = new Application($this->di);
     $app->useImplicitView('null' === $this->config['view']['default'] ? false : true);
     // set event manager for application
     $eventManager = $app->getDI()->getShared('eventsManager');
     $this->setEventsManager($eventManager);
     $this->registerEvents();
     /*
      * TODO This is bug on phalcon 2.0.4
      */
     $app->setEventsManager($this->getEventsManager());
     return $app->handle($uri)->getContent();
 }
示例#5
0
$debug->listen();
/**
 * Include services
 */
require __DIR__ . '/../config/services.php';
/**
 * Include loaders
 */
require __DIR__ . '/../config/loader.php';
/**
 * Handle the request
 */
$application = new Application();
$eventsManager = new Phalcon\Events\Manager();
$application->setEventsManager($eventsManager);
$eventsManager->attach('application:viewRender', function ($event, $application) {
    $dispatcher = $application->getDI()->getDispatcher();
    $controllerName = strtolower($dispatcher->getControllerName());
    if (substr($controllerName, 0, 1) == '\\') {
        $dispatcher->setControllerName(substr($controllerName, 1));
    }
});
/**
 * Assign the DI
 */
$application->setDI($di);
/**
 * Include modules
 */
require __DIR__ . '/../config/modules.php';
echo $application->handle()->getContent();