@param App $slim

@return App
551780
public function attach(App $slim)
    {
        $middlewares = array_reverse($this->middleware);

        foreach ($middlewares as $middleware) {
            $service = $this->getService($middleware);
            $slim->add($service);
        }

        return $slim;
    }
1358957
public function register(Application $app)
    {
        $app[UseCase::LOGIN] = $app->share(function () use ($app) {
            return new LoginUseCase(
                $app[Repository::USER],
                $app[Validator::LOGIN],
                $app[Service::PASSWORD_HASH]);
        });
        $app[UseCase::REGISTRATION] = $app->share(function () use ($app) {
            return new RegistrationUseCase(
                $app[Repository::USER],
                $app[Validator::REGISTRATION],
                $app[Service::PASSWORD_HASH]);
        });
        $app[UseCase::LIST_DIRECTIONS] = $app->share(function() use($app){
            return new ListDirectionsUseCase($app[Repository::DIRECTION]);
        });
    }
59422
protected function createApplication()
    {
        putenv('APP_ENV=' . $this->getEnv());

        $app = require $this->appPath;

        $app->make(Kernel::class)->bootstrap();

        Carbon::setTestNow(Carbon::now());

        return $app;
    }
1275876
public function boot(Application $app)
	{
		$assets = $this;
		$app->before(function(Request $request) use($app, $assets){
			$baseUrl = rtrim($request->getScheme().'://'.$request->getHttpHost().$request->getBasePath()).'/';
			$assets->setCoreUrl($baseUrl);
			$assets->setOption('baseUrl', $baseUrl);
			$assets->setOption('jsPosition',$assets::ON_BODY);
			return $assets;
		});

		// Registering preloaded options
		$options = isset($app['assets.options'])?$app['assets.options']:array();
		if(!empty($options))
			array_walk($options, function($optionValue, $optionName) use($assets){
				$assets->setOption($optionName, $optionValue);
			});	

		// Registering preloaded javascript files
		$js = isset($app['assets.js'])?$app['assets.js']:array();
		if(!empty($js))
			array_walk($js, function($value) use($assets){
				$assets->registerJs($value);
			});

		// Registering preloaded css files
		$css = isset($app['assets.css'])?$app['assets.css']:array();
		if(!empty($css))
			array_walk($css, function($value) use($assets){
				$assets->registerCss($value);
			});

		$app->after(function(Request $request, Response $response) use($app, $assets){
			// print_r($response->headers->get('content_type'));
			if($response->headers->get('content_type')!='application/json')
			{
				$content = $response->getContent();
				$assets->renderAssets($content);
				$response->setContent($content);
			}
			return $response;
		});
	}
871518
private static function hookError(App $cdl, Slim $app, string $method, array $options){
        $routing = $app->{$method}($options['url'], System::jsonResponse(function (){
            return Route::noRoute();
        }));
        self::applyMiddleware($cdl, $options, $routing);
    }
1185203
public function generateSlimRoutes(Slim $slim)
    {
        // if we are not on a resources's route, then dont generate any routes
        if (!$this->config->getCurrentResourceConfiguration()) {
            return;
        }

        $output = $this->newSlimOutput($slim->request, $slim->response);

        $generator = new SlimRouteGenerator($slim, $output, $this->config);

        $generator->generateRoutes();
    }
1219599
public function connect(Application $app)
    {
        /**
         * @var ControllerCollection $collection
         */
        $collection = $app['controllers_factory'];
        $collection
            ->match('/', Controller::INDEX . ':indexAction')
            ->method('GET')
            ->value('template', 'pages/landing');
        $collection
            ->match('/account/login', Controller::INDEX . ':indexAction')
            ->method('POST')
            ->value('template', 'pages/landing');
        $collection
            ->match('/account/create', Controller::ACCOUNT . ':indexAction')
            ->method('POST|GET')
            ->value('template', 'pages/registration');
        $collection
            ->match('/game', Controller::INDEX . ':indexAction')
            ->method('GET')
            ->value('template', 'pages/landing');
        $collection
            ->match('/cities',Controller::CITY.':listAction')
            ->method('GET')
            ->value('template','pages/game/cityList');
        $collection
            ->match('/city/create',Controller::CITY.':createAction')
            ->method('GET')
            ->value('template','pages/game/newcity');


        return $collection;
    }
1357493
public function register(Application $app)
    {
        $app['migrations.create-proxy'] = $app->share(function ($app) {
            $command = new CreateMigrationCommandProxy('migrations:create');
            $command->setFactory($app->raw('migrations.create'))
                ->setApp($app);
            return $command;
        });

        $app['migrations.create'] = $app->share(function ($app) {
            $view = new CreateMigrationView($app['mustache']);

            $command = new CreateMigrationCommand($view);

            $config = $app['config']->load('init');

            if (isset($config['migrations_namespace'])) {
                $command->setMigrationNamespace($config['migrations_namespace']);
            }

            return $command;
        });

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

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

            $command->setDatabaseAdapter($app['db']);

            $config = $app['config']->load('init');

            if (isset($config['migrations_namespace'])) {
                $command->setMigrationNamespace($config['migrations_namespace']);
            }

            return $command;
        });
    }
1088386
public function register(Application $app)
    {
        $app[Service::PASSWORD_HASH] = $app->share(function () use ($app) {
            return new Service\DefaultPasswordHashService();
        });
    }
234981
public function bootstrap(Application $app)
	{
		try
		{
			Dotenv::load($app->basePath(), $app->environmentFile());
		}
		catch (InvalidArgumentException $e)
		{
			//
		}

		$app->detectEnvironment(function()
		{
			return env('APP_ENV', 'production');
		});
	}
920014
public function bootModules(Application $app)
    {
        foreach ($this->getRegisteredModules() as $module) {
            $module->boot($app);
        }

        return $this;
    }
1131573
public function applyRoutes(App $cdl, Slim $app){
        $routes = System::getRoutesFromSettings($this->settings);
        foreach ($routes as $method => $data) {
            Dispatcher::run($cdl, $method, $app, $this, $data);
        }
    }
258553
function build(aSapi $app)
    {
        # Set Enabled Modules
        if ($this->modules)
            $app->setEnabledModules($this->modules);


        # Module Manager settings
        if ($this->moduleManager) {
            $mm = $app->moduleManager();
            $mm->with( $mm::parseWith($this->moduleManager) );
        }


        # Default Application Configs
        if ($this->default_config)
            $app->config()->import($this->default_config);

    }
893247
public static function repository(?string $app = null): Repository
    {
        self::initialize();
        if ($app === null) {
            $app = '*';
        }

        // Autoload default "config" in project root.
        if ($app === '*' && !isset(self::$repositories[$app])) {
            $path = Path::root('config');
            if (!is_dir($path)) {
                throw new ConfigException('Path ' . $path . ' does not exist.');
            }
            self::$repositories[$app] = new Repository($path);
        }

        if (!isset(self::$repositories[$app])) {
            throw new ConfigException('Application ' . $app . ' not registered.');
        }
        return self::$repositories[$app];
    }
1010551
public static function appPath(?string $app = null): ?string
    {
        self::initialize();
        if ($app === null) {
            $app = '*';
        }
        if (isset(self::$repositories[$app])) {
            return call_user_func([self::$repositories[$app], 'getPath']);
        }
        return null;
    }
494285
private static function registerViewExtension(Slim $app, Recaptcha $recaptcha)
    {
        $view = $app->view;
        if (!property_exists($view, 'parserExtensions')) {
            return;
        }

        $originalExtensions = $view->parserExtensions ?: [];
        $class = explode('\\', get_class($view));
        switch(end($class)) {
            case 'Twig':
                $view->parserExtensions = array_merge($originalExtensions, [new TwigExtension($recaptcha)]);
                break;
        }
    }
270496
public function bootstrap($app)
    {

        Event::on(ProductController::className(),
            ProductController::EVENT_AFTER_CREATE_PRODUCT, [$this, 'invalidateCache']);
        Event::on(ProductController::className(),
            ProductController::EVENT_AFTER_EDIT_PRODUCT, [$this, 'invalidateCache']);
        Event::on(ProductController::className(),
            ProductController::EVENT_AFTER_DELETE_PRODUCT, [$this, 'invalidateCache']);

        Event::on(CategoryController::className(),
            CategoryController::EVENT_AFTER_CREATE_CATEGORY, [$this, 'invalidateCache']);
        Event::on(CategoryController::className(),
            CategoryController::EVENT_AFTER_EDIT_CATEGORY, [$this, 'invalidateCache']);
        Event::on(CategoryController::className(),
            CategoryController::EVENT_AFTER_DELETE_CATEGORY, [$this, 'invalidateCache']);

        Event::on(Category::className(),
            Category::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Category::className(),
            Category::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Category::className(),
            Category::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(Product::className(),
            Product::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Product::className(),
            Product::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Product::className(),
            Product::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(Vendor::className(),
            Vendor::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ProductAvailability::className(),
            ProductAvailability::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(ProductAvailability::className(),
            ProductAvailability::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(ProductAvailability::className(),
            ProductAvailability::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ShopAttribute::className(),
            ShopAttribute::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(ShopAttribute::className(),
            ShopAttribute::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(ShopAttribute::className(),
            ShopAttribute::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ShopAttributeValue::className(),
            ShopAttributeValue::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(ShopAttributeValue::className(),
            ShopAttributeValue::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(ShopAttributeValue::className(),
            ShopAttributeValue::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(ProductCountry::className(),
            ProductCountry::EVENT_BEFORE_DELETE, [$this, 'invalidateCache']);
        Event::on(ProductCountry::className(),
            ProductCountry::EVENT_BEFORE_INSERT, [$this, 'invalidateCache']);
        Event::on(ProductCountry::className(),
            ProductCountry::EVENT_BEFORE_UPDATE, [$this, 'invalidateCache']);

        Event::on(FavoriteProduct::className(),
            FavoriteProduct::EVENT_AFTER_DELETE, [$this, 'invalidateCache']);
        Event::on(FavoriteProduct::className(),
            FavoriteProduct::EVENT_AFTER_INSERT, [$this, 'invalidateCache']);
        Event::on(FavoriteProduct::className(),
            FavoriteProduct::EVENT_AFTER_UPDATE, [$this, 'invalidateCache']);

        Event::on(CartComponent::className(),
            CartComponent::EVENT_AFTER_CLEAR, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_AFTER_ADD_PRODUCT, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_AFTER_REMOVE_PRODUCT, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_BEFORE_GET_ORDER, [$this, 'invalidateCache']);
        Event::on(CartComponent::className(),
            CartComponent::EVENT_BEFORE_GET_ORDER_FROM_DB, [$this, 'invalidateCache']);

    }