Creates a new instance of XSendFile Factory according to the application
configuration.

@param  Application      $app
@return XSendFileFactory
439584
public static function create(Application $app)
    {
        $conf = $app['conf']->get('xsendfile');

        $mapping = [];

        if (isset($conf['mapping'])) {
            $mapping = $conf['mapping'];
        }

        return new self($app['monolog'], $conf['enabled'], $conf['type'], $mapping);
    }
707521
public function app($app)
    {
        $this->classRoute = Router::$defaultNameSpace . $app;
        
        $request = Router::$requestDriver;
        if (!empty($request)) {
            if (!$request->query->get("q")) {
                $request->query->set("q", "/");
            }
        } else {
            $_GET['q'] = "/";
        }
        
        if ($this->method === "ALL" ||
            ((!empty($request) && $this->method === $request->server->get("REQUEST_METHOD")) ||
                $_SERVER['REQUEST_METHOD'] === $this->method)
        ) {
            $this->useRoute($this->route);
        } else {
            $this->classRoute = false;
        }
        
        return new RouteMiddleware($this->route, $this->classRoute, $this->methodRoute);
    }
219735
public function register(Application $app)
    {
        // Required because the Silex provider is not up to date with Symfony Debug Toolbar
        $app['web_profiler.toolbar.listener'] = $app->share(
            $app->extend('web_profiler.toolbar.listener', function () use ($app) {
                return new WebDebugToolbarListener(
                    $app['twig'],
                    $app['web_profiler.debug_toolbar.intercept_redirects'],
                    2,
                    $app['web_profiler.debug_toolbar.position'],
                    $app['url_generator']
                );
            })
        );

        if (class_exists(AjaxDataCollector::class)) {
            $app['data_collector.templates'] = $app->share($app->extend('data_collector.templates', function (array $templates) {
                $templates[] = array('ajax', '@WebProfiler/Collector/ajax.html.twig');

                return $templates;
            }));

            $app['data_collectors'] = $app->share($app->extend('data_collectors', function (array $collectors, $app) {
                $collectors['ajax'] = $app->share(function () {
                    return new AjaxDataCollector();
                });

                return $collectors;
            }));
        }

        $app['dbal.config.register.loggers'] = $app->protect(function (Configuration $config, $name) use ($app) {
            $debugLogger = new DebugStack();

            $loggerChain = new LoggerChain();
            $loggerChain->addLogger($debugLogger);
            $loggerChain->addLogger($app['data_collectors.doctrine.logger']);

            $app['data_collectors.doctrine']->addLogger($name, $debugLogger);

            $config->setSQLLogger($loggerChain);
        });

        $app['data_collectors.doctrine.logger'] = $app->share(function ($app) {
            return new DbalLogger($app['logger'], $app['stopwatch']);
        });

        $app['data_collectors.doctrine'] = $app->share(function ($app) {
            return new DoctrineDataCollector(new LazyArrayAccess(new LazyLocator($app, 'dbs')));
        });

        $app['cache'] = $app->share($app->extend('cache', function (Cache $cache, $app) {
            $namespace = $app['conf']->get(['main', 'cache', 'options', 'namespace']);
            $cache = new TraceableCache($cache);

            $cache->setNamespace($namespace);

            return $cache;
        }));

        $app['data_collector.cache_subscriber'] = $app->share(function ($app) {
            return new CacheStatisticsSubscriber($app['cache']);
        });

        $app['data_collectors'] = $app->share($app->extend('data_collectors', function (array $collectors, $app) {
            $collectors['db'] = $app->share(function ($app) {
                return $app['data_collectors.doctrine'];
            });

            $collectors['cache'] = $app->share(function ($app) {
                return new CacheDataCollector($app['data_collector.cache_subscriber']);
            });

            return $collectors;
        }));

        $app['data_collector.templates'] = $app->share($app->extend('data_collector.templates', function (array $templates) {
            $templates[] = array('db', '@DoctrineBundle/Collector/db.html.twig');
            $templates[] = array('cache', '@PhraseaProfiler/cache.html.twig');

            return $templates;
        }));

        $app['twig.loader.filesystem'] = $app->share($app->extend('twig.loader.filesystem', function ($loader, $app) {
            $loader->addPath(
                $app['root.path'] . '/vendor/sorien/silex-dbal-profiler/src/Sorien/Resources/views',
                'DoctrineBundle'
            );
            $loader->addPath($app['root.path'] . '/templates-profiler/', 'PhraseaProfiler');
            return $loader;
        }));
    }
245572
protected function injectInitialServices(ApplicationInterface $app)
    {
        $app->getServicesFactory()->registerService(
            ['id' => 'application', 'instance' => $app],
            
            // all those are here for convenience only since 'application' gives access to all of them
            ['id' => 'config', 'instance' => $app->getConfig()],
            ['id' => 'events-handler', 'instance' => $app->getEventsHandler()]
        )
        ;
    }
1264297
public function register(Application $app)
    {
        $app[Controller::INDEX] = $app->share(function () use ($app) {
            return new Controller\IndexController($app[UseCase::LOGIN]);
        });
        $app[Controller::ACCOUNT] = $app->share(function () use ($app) {
            return new Controller\AccountController($app[UseCase::REGISTRATION], $app[Repository::USER]);
        });
        $app[Controller::CITY] = $app->share(function () use ($app) {
            return new Controller\CityController(
                $app[UseCase::LIST_DIRECTIONS],
                $app[Repository::USER],
                $app[Repository::CITY]);
        });
    }
6370
public static function Init(\Puzzlout\Framework\Core\Application $app) {
        $instance = new ArrayFilterFileSearch();
        $instance->FileList = array();
        $instance->ContextApp = $app;
        return $instance;
    }
882752
protected function createAppXmlFile()
    {
        $appName = self::APP_NAME;
        $appXmlFileContents = <<<EOD
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties">
    <Application>$appName</Application>
    <TotalTime>0</TotalTime>
</Properties>
EOD;

        $this->createFileWithContents($this->docPropsFolder, self::APP_XML_FILE_NAME, $appXmlFileContents);

        return $this;
    }
728741
public function connect(Application $app)
    {
        $controllers = $app['controllers_factory'];

        $handler = function ($resource) use ($app) {
            if ($app['logger']) {
                $app['logger']->debug(sprintf('Appending a trailing slash for the request to `/%s`.', $resource));
            }

            $currentRequest = $app['request_stack']->getCurrentRequest();
            $request = Request::create(
                '/' . $resource . '/',
                $currentRequest->getMethod(),
                [],
                $currentRequest->cookies->all(),
                $currentRequest->files->all(),
                $currentRequest->server->all(),
                $currentRequest->getContent()
            );
            $request = $request->duplicate(
                $currentRequest->query->all(),
                $currentRequest->request->all()
            );
            $request->headers->replace($currentRequest->headers->all());

            // Make an internal sub-request based off the request that would have 404'd.
            // http://silex.sensiolabs.org/doc/usage.html#forwards
            return $app->handle($request, HttpKernelInterface::SUB_REQUEST);
        };

        /**
         * Register the catch-all route.
         *
         * Use a look behind assertion to ensure we only match routes
         * with no trailing slash.
         *
         * @link https://stackoverflow.com/questions/16398471/regex-not-ending-with
         */
        $controllers->match('/{resource}', $handler)
                    ->assert('resource', '.*(?<!\/)$')
                    ->bind('no_trailing_slash_handler');

        return $controllers;
    }
566339
public function boot(Application $app)
    {
        $this->app = $app;

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

        return $this;
    }
468438
public function createConfig(Application $app)
    {
        $config = new Pimple;

        foreach ($app['ems.options'] as $name => $options) {
            $config[$name] = $config->share(
                function () use ($app, $name, $options) {
                    $config = new Configuration;

                    $config->setAutoGenerateProxyClasses(
                        $options['proxy_auto_generate']
                    );

                    $config->setMetadataCacheImpl($app['ems.cache'][$name]);
                    $config->setMetadataDriverImpl($app['ems.mapping'][$name]);
                    $config->setQueryCacheImpl($app['ems.cache'][$name]);
                    $config->setProxyDir($options['proxy_dir']);
                    $config->setProxyNamespace($options['proxy_namespace']);

                    return $config;
                }
            );
        }

        return $config;
    }
285237
public function setApp(Application $app)
    {
        $this->app = $app;
        AppSingleton::set($app);
        $this->pathResolver = $app['path_resolver'];

        // if RM is passed directly into Application c.v.a won't be set
        // but if called later then we don't want to override the value if someone else has changed it,
        // unless disableApacheChecks has been called.
        $default = true;
        if (isset($this->app['config.validator.apache_enabled'])) {
            $default = $this->app['config.validator.apache_enabled'];
        }
        $this->app['config.validator.apache_enabled'] = function () use ($default) {
            return $this->disableApacheChecks ? false : $default;
        };
    }
210028
public function bootstrap(Application $app)
    {
        if ($app->configurationIsCached()) {
            return;
        }

        $this->checkForSpecificEnvironmentFile($app);

        try {
            $this->createDotenv($app)->safeLoad();
        } catch (InvalidFileException $e) {
            $this->writeErrorAndDie($e);
        }
    }
1259184
public function register(Application $app)
    {
        $app['install.generate-proxy'] = $app->share(function ($app) {
            $command = new GenerateInstallCommandProxy('install:generate');
            $command->setFactory($app->raw('install.generate'))
                ->setApp($app);
            return $command;
        });

        $app['install.generate'] = $app->share(function ($app) {
            $command = new GenerateInstallCommand();

            $command->setDbConfig($app['config']->load('db'));
            $command->setInstallConfig($app['config']->load('install'));

            return $command;
        });

        $app['install.run-proxy'] = $app->share(function ($app) {
            $command = new RunInstallCommandProxy('install:run');
            $command->setFactory($app->raw('install.run'))
                ->setApp($app);
            return $command;
        });

        $app['install.run'] = $app->share(function ($app) {
            $command = new RunInstallCommand();

            $command->setDatabaseAdapter($app['db']);
            $command->setAppEnv($app['environment']);
            $command->setRunMigrationsCommand($app['migrations.run-proxy']);
            $command->setGenerateInstallCommand($app['install.generate-proxy']);

            return $command;
        });
    }
904574
public function bootstrap(Application $app)
    {
        $items = [];
        // First we will see if we have a cache configuration file. If we do, we'll load
        // the configuration items from that file so that it is very quick. Otherwise
        // we will need to spin through every configuration file and load them all.
//        if (file_exists($cached = $app->getCachedConfigPath())) {
//            $items = require $cached;
//            $loadedFromCache = true;
//        }

        // Next we will spin through all of the configuration files in the configuration
        // directory and load each one into the repository. This will make all of the
        // options available to the developer for use in various parts of this app.
        $app->share('config', $config = new Config($items, true));

//        if (!isset($loadedFromCache)) {
        $this->loadConfigurationFiles($app, $config);
//        }
        // Finally, we will set the application's environment based on the configuration
        // values that were loaded. We will pass a callback which will be used to get
        // the environment in a web context where an "--env" switch is not present.
//        $app->detectEnvironment(function () use ($config) {
//            return $config->get('app.env', 'production');
//        });
        date_default_timezone_set($config->get('app.timezone', 'UTC'));
        mb_internal_encoding('UTF-8');
    }
730680
public function bootstrap($app)
    {
        if (empty($this->applicationId) || empty($this->apiKey)) {
            throw new InvalidConfigException('applicationId and apiKey are required');
        }

        Yii::$container->set(AlgoliaManager::class, function () {
            return $this->createManager();
        });
    }
975559
public function createApplicationPassword(ApplicationPassword $application)
    {
        return $this->createCommand()
            ->setRequest($this->client->post('application'))
            ->setBodyEntity($application, 'json')
            ->setResponseClass('Maba\OAuthCommerceInternalClient\Entity\ApplicationPassword')
        ;
    }
1233109
public function bootstrap(Application $app)
    {
        $app->make('orchestra.memory')->extend('user', function ($app, $name) {
            return new UserProvider(
                new UserRepository($name, [], $app)
            );
        });
    }