Run the given event.

@param Application $app

@return mixed
969498
public function run(Application $app)
    {
        $response = call_user_func_array($this->callback, array_merge($this->parameters, [$app]));
        parent::callAfterCallbacks($app);

        return $response;
    }
834054
protected function registerAnalytics(Application $app)
    {
        $app->singleton('gamp', function ($app) {
            $config = $app['config'];

            $analytics = new Analytics($config->get('gamp.is_ssl', false), $config->get('gamp.is_disabled', false));

            $analytics->setProtocolVersion($config->get('gamp.protocol_version', 1))
                ->setTrackingId($config->get('gamp.tracking_id'));

            if ($config->get('gamp.anonymize_ip', false)) {
                $analytics->setAnonymizeIp('1');
            }

            if ($config->get('gamp.async_requests', false)) {
                $analytics->setAsyncRequest(true);
            }

            return $analytics;
        });

        $app->alias('gamp', Analytics::class);
    }
703217
public function run($app)
    {
        foreach ($app->getApplicationModules() as $id => $module) {
            $folder = $module->basePath . DIRECTORY_SEPARATOR . 'commands';
            if (file_exists($folder) && is_dir($folder)) {
                foreach (FileHelper::findFiles($folder) as $file) {
                    $module->controllerNamespace = $module->namespace . '\commands';
                    
                    $className = '\\'.$module->getNamespace().'\\commands\\' . pathinfo($file, PATHINFO_FILENAME);

                    $command = str_replace('-controller', '', $module->id . '/' . Inflector::camel2id(pathinfo($file, PATHINFO_FILENAME)));
                    
                    Yii::$app->controllerMap[$command] = ['class' => $className];
                }
            }
        }
    }
84157
public function bootstrap(Application $app)
    {
        /** @var Container $container */
        $container = $app->getContainer();

        $container->share('app', $app);
        $container->alias('app', Application::class);
        $container->alias('app', ApplicationInterface::class);

        $container->share('container', $container);

        $container->share('kernel.http', function () use ($container) {
            return $container->get(Kernel::class);
        });
        $container->alias('kernel.http', KernelInterface::class);

        $container->alias('router', Router::class);
        $container->alias('dispatcher', Dispatcher::class);
    }
1281739
public function route(Application $app, Request $request)
    {
        $url = $request->getPathInfo();
        $method = $request->getMethod();

        /** @var $route Route */
        foreach ($this->routes as $route) {

            // Match by method
            if ($route->getMethod() == $method) {

                // Match by URL
                $matches = $route->matches($url);
                if ($matches !== false) {

                    // Emit match event
                    $app['emitter']->emit(self::EVENT_MATCH, [$app, $request, $route]);

                    // Execute the route
                    return $route->run($app, $request, $matches);
                }
            }
        }

        // Emit no_match event
        $app['emitter']->emit(self::EVENT_NO_MATCH, [$app, $request]);

        // Return HTTP 404
        return new Response("Page not found", Response::HTTP_NOT_FOUND);
    }
1251412
public function apply(Application $app)
    {
        $applied = [];

        foreach ($this->upgrades as $upgrade) {
            if ($upgrade->isApplyable($app)) {
                try {
                    $upgrade->apply(
                        $app['orm.em'],
                        $app['phraseanet.appbox'],
                        $app['doctrine-migration.configuration']
                    );
                    $applied[] = $upgrade;
                } catch (\Exception $e) {
                    $upgrade->rollback(
                        $app['orm.em'],
                        $app['phraseanet.appbox'],
                        $app['doctrine-migration.configuration']
                    );
                    foreach (array_reverse($applied) as $done) {
                        $done->rollback(
                            $app['orm.em'],
                            $app['phraseanet.appbox'],
                            $app['doctrine-migration.configuration']
                        );
                    }
                    throw $e;
                }
            }
        }
    }
368059
public function register(Application $app)
    {
        if ($this->registered) {
            throw new \RuntimeException('Can not re-register extensions.');
        }
        foreach ($this->extensions as $extension) {
            if ($extension->isEnabled() !== true) {
                continue;
            }
            $extension->getInnerExtension()->setContainer($app);
            foreach ($extension->getInnerExtension()->getServiceProviders() as $provider) {
                $app->register($provider);
            }
        }
        $this->registered = true;

        // @deprecated Deprecated since 3.0, to be removed in 4.0.
        $this->app = $app;
    }
1332794
public function boot(Application $app)
    {
        // Reference to $this, it's used for closure in anonymous function (PHP 5.3.x)
        $self = &$this;
        $app->get($app['swaggerui.path'], function(Request $request) use ($app) {
            return str_replace(
                array('{{swaggerui-root}}', '{{swagger-docs}}'),
                array($request->getBasePath() . $app['swaggerui.path'], $request->getBasePath() . $app['swaggerui.apiDocPath']),
                file_get_contents(__DIR__ . '/../../../../public/index.html')
            );
        });

        $app->get($app['swaggerui.path'] . '/{resource}', function($resource) use ($app) {
            $file = __DIR__ . '/../../../../public/' . $resource;
            if (is_file($file)) {
                return file_get_contents($file);
            }

            return '';
        });

        $app->get($app['swaggerui.path'] . '/lib/{resource}', function($resource) use ($app, $self) {
            return $self->getFile(
                __DIR__ . '/../../../../public/lib/' . $resource,
                'text/javascript'
            );
        });

        $app->get($app['swaggerui.path'] . '/css/{resource}', function($resource) use ($app, $self) {
            return $self->getFile(
                __DIR__ . '/../../../../public/css/' . $resource,
                'text/css'
            );
        });

        $app->get($app['swaggerui.path'] . '/images/{resource}', function($resource) use ($app, $self) {
            return $self->getFile(
                __DIR__ . '/../../../../public/images/' . $resource,
                'image/png'
            );
        });
    }
688744
public function register(Application $app)
    {
        foreach ($this->services as $key => $class) {
            if (is_numeric($key)) {
                $key = $class;
            }
            $app[$key] = $app->share(function() use ($class, $app) {
                $result = new $class();
                $app->initialize($result);
                return $result;
            });
        }

        if (!empty($this->doctrineEventSubscribers)) {
            $config = $app['config'];
            foreach ($this->doctrineEventSubscribers as $class) {
                $config['orm.subscribers'][] = $class;
            }
        }

        if (!empty($this->entityFolders)) {
            if (!isset($config)) {
                $config = $app['config'];
            }
            foreach ($this->entityFolders as $namespace => $path) {
                $config['orm.options']['orm.em.options']['mappings'][] = [
                    'type' => 'annotation',
                    'namespace' => $namespace,
                    'path' => $path,
                    'use_simple_annotation_reader' => false,
                ];
            }
        }

        if (isset($config)) {
            $app['config'] = $config;
        }

        if (php_sapi_name() === 'cli' && !empty($this->commands)) {
            $app['base_commands'] = $app->extend('base_commands', function(array $commands) {
                return array_merge($commands, $this->commands);
            });
        }
    }
724246
public function connect(Application $app)
    {
        $ctrl = $app['controllers_factory'];



        /**
         * Homepage
         */
        $ctrl
            ->get(
                '/',
                function () use ($app) {
                    $root = str_replace('index.php/', '', $app['url_generator']->generate('home'));

                    if ($app['request']->getRequestURI() != $root) {
                        return $app->redirect($root, Response::HTTP_MOVED_PERMANENTLY);
                    }

                    return $app['twig']->render('front/partials/home.twig');
                }
            )
            ->bind('home');



        /**
         * Admin root
         */
        $ctrl
            ->get(
                '/admin',
                function () use ($app) {
                    return $app->redirect($app['url_generator']->generate($app['config']['admin']['root']));
                }
            );


        /**
         * robots.txt
         */
        $ctrl
            ->get(
                '/robots.txt',
                function () use ($app) {
                    $response = new Response(
                        'User-agent: *'.PHP_EOL.(
                            $app['debug']
                                ? 'Disallow: /'
                                : 'Sitemap: '.$app['url_generator']->generate('home').'sitemap.xml'
                        )
                    );

                    $response->headers->set('Content-Type', 'text/plain');
                    return $response;
                }
            );



        return $ctrl;
    }
720230
public function register(Application $app)
    {
        $app['db'] = $app->share(function ($app) {
            return new Adapter($app['config']->load('db'));
        });

        $app['db.transaction'] = $app->share(function ($app) {
            return new Transaction($app['db']);
        });

        $app->initializer(
            'Synapse\\Db\\TransactionAwareInterface',
            function ($object, $app) {
                $object->setTransaction($app['db.transaction']);
                return $object;
            }
        );

        $this->registerMapperInitializer($app);
    }
934449
public function events($app = NULL)
    {
        try {

            if (is_null($app))
                throw new Exception("App name is not provided or is null", 503);

            $uri = "/events";
            $getObj = array('app' => $app);

            $result = $this->pestObject->get($uri, $getObj);
            return $result;


        } catch (Exception $e) {
            $this->phpariObject->lasterror = $e->getMessage();
            $this->phpariObject->lasttrace = $e->getTraceAsString();
            return false;
        }
    }
990443
protected function callAfterCallbacks(Application $app)
    {
        foreach ($this->_afterCallbacks as $callback) {
            call_user_func($callback, $app);
        }
    }
635679
public function run()
    {
        try {
            $response = $this->resolveResponse();
        } catch (ForbiddenException $e) {
            $response = $this->fire('kernel.403', $e, $this->eventMsg($e));
        } catch (NotFoundException $e) {
            $response = $this->fire('kernel.404', $e, $this->eventMsg($e));
        } catch (\Exception $e) {
            $response = $this->fire('kernel.500', $e, $this->eventMsg($e));
        }

        if (isset($e) && (empty($response) || $response instanceof \Exception)) {
            throw $e;
        }

        if ($evtResponse = $this->fire('kernel.send', $response)) {
            $response = $evtResponse;
        }

        if (!$response instanceof ResponseInterface) {
            throw new AppException(sprintf('Received response is not an instance of ResponseInterface, got "%s"', $this->getType($response)));
        }

        return $response;
    }
81030
public function register(Application $app)
    {
        $app[Validator::LOGIN] = $app->share(function () use ($app) {
            return new Validator\SymfonyLoginValidator($app['validator']);
        });
        $app[Validator::REGISTRATION] = $app->share(function () use ($app) {
            return new Validator\SymfonyRegistrationValidator($app['validator']);
        });
    }
416486
protected function requireAuthorization(Application $app)
    {
        /** @var ResourceServer $server */
        $server = $app[ResourceServer::class];
        try {
            $server->isValidRequest(false);
        } catch(OAuthException $e) {
            return new JsonResponse(
                [
                    'error' => $e->errorType,
                    'message' => $e->getMessage(),
                ],
                $e->httpStatusCode,
                $e->getHttpHeaders()
            );
        }
        return null;
    }
566339
public function boot(Application $app)
    {
        $this->app = $app;

        $this->config = $app->make('config');

        return $this;
    }