Creates the mapping instances for the entity managers.

@param Application $app The application.

@return Pimple The mapping instance manager.
322207
public function createMapping(Application $app)
    {
        $mapping = new Pimple;

        foreach ($app['ems.options'] as $name => $options) {
            $mapping[$name] = $mapping->share(
                function () use ($app, $options) {
                    $class = 'Doctrine\ORM\Mapping\Driver\\'
                           . $options['mapping_driver'];

                    switch ($options['mapping_driver'])
                    {
                        case 'AnnotationDriver':
                            $config = new Configuration;

                            return $config->newDefaultAnnotationDriver(
                                $options['mapping_paths']
                            );
                        case 'XmlDriver':
                            return new $class (
                                $options['mapping_paths']
                            );
                        case 'YamlDriver':
                            $driver = new $class (
                                $options['mapping_paths'],
                                '.yml'
                            );

                            return $driver;
                        default:
                            throw new InvalidArgumentException (
                                "Unsupported mapping class: $class"
                            );
                    }
                }
            );
        }

        return $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);
    }
1345454
public function register(Application $app)
    {
        $app['mongo'] = $app->share(
            function () use ($app) {

                // Assert MongoDB Server
                if (empty($app['mongo.server'])) {
                    $app['mongo.server'] = 'mongodb://127.0.0.1:27017';
                }
                if (! isset($app['mongo.options']) || ! is_array($app['mongo.options'])) {
                    $app['mongo.options'] = array();
                }

                // Connect to Database
                $client = new Client($app['mongo.server'], $app['mongo.options']);

                // Apply Schema Options
                if (! empty($app['mongominify.schema_dir'])) {
                    $client->schema_dir = $app['mongominify.schema_dir'];
                }
                if (! empty($app['mongominify.schema_format'])) {
                    $client->schema_format = $app['mongominify.schema_format'];
                }

                // Figure out DB Name
                if (! empty($app['mongo.options']['db'])) {
                    $db_name = $app['mongo.options']['db'];
                } else {
                    $uri = parse_url($app['mongo.server']);
                    $db_name = isset($uri['path']) ? substr($uri['path'], 1) : 'test';
                }

                // Return Database Instance
                return new Db($db_name, $client, $app);

            }
        );
    }
1297222
public function register(Application $app)
    {
        if (!isset($app['descriptor.builder'])) {
            throw new Exception\MissingDependencyException(
                'The builder object that is used to construct the ProjectDescriptor is missing'
            );
        }

        $app['parser'] = $app->share(
            function ($app) {
                $parser = new Parser();
                $parser->setStopwatch($app['kernel.stopwatch']);
                $parser->setLogger($app['monolog']);

                return $parser;
            }
        );

        $app['markdown'] = $app->share(
            function () {
                return \Parsedown::instance();
            }
        );

        /** @var Translator $translator  */
        $translator = $app['translator'];
        $translator->addTranslationFolder(__DIR__ . DIRECTORY_SEPARATOR . 'Messages');

        $app['parser.files'] = new Collection();
        $app->command(new ParseCommand($app['descriptor.builder'], $app['parser'], $translator, $app['parser.files']));
    }
643754
protected function registerManager(Application $app)
    {
        $app->singleton('opensearch', function ($app) {
            $config = $app['config'];
            $factory = $app['opensearch.factory'];
            return new OpensearchManager($config, $factory);
        });
        $app->alias('opensearch', 'Orzcc\Opensearch\OpensearchManager');
    }
656349
public function register(Application $app)
    {
        $this->em = new ClientEntityManager($app);

        $this->modelManagerFactory = $app['clients.model_manager.factory'];

        // Default options.
        $app['clients.options.default'] = array(
            // Specify custom view templates here.
            'templates' => array(
                'view' => '@clients/view.twig',
                'edit' => '@clients/edit.twig',
                'list' => '@clients/list.twig',
                'create' => '@clients/create.twig',
                'remove' => '@clients/remove.twig',
            )
        );


        // Initialize $app['clients.options'].
        $app['clients.options.init'] = $app->protect(function() use ($app) {
            $options = $app['clients.options.default'];

            if (isset($app['clients.options'])) {
                $options = array_replace_recursive($options, $app['clients.options']);
            }

            $app['clients.options'] = $options;
        });

        // User controller service.
        $app['clients.controller'] = $app->share(function ($app) {
            //$app['clients.options.init']();
            $controller = new ClientController($app['clients.model_manager.factory']);

            return $controller;
        });

        /*
         *  Not sure it goes there
         */
        $app->before(function () use ($app) {
            $app['twig']->addGlobal('layout', null);
            $app['twig']->addGlobal('layout', $app['twig']->loadTemplate('layout.twig'));
        });

    }
1343460
public function registerStorageBindings(Application $app)
    {
        $provider = $this;

        $app->singleton(FluentAccessToken::class, function () use ($provider) {
            $storage = new FluentAccessToken($provider->app['db']);
            $storage->setConnectionName($provider->getConnectionName());

            return $storage;
        });

        $app->singleton(FluentAuthCode::class, function () use ($provider) {
            $storage = new FluentAuthCode($provider->app['db']);
            $storage->setConnectionName($provider->getConnectionName());

            return $storage;
        });

        $app->singleton(FluentClient::class, function ($app) use ($provider) {
            $limitClientsToGrants = $app['config']->get('oauth2.limit_clients_to_grants');
            $storage = new FluentClient($provider->app['db'], $limitClientsToGrants);
            $storage->setConnectionName($provider->getConnectionName());

            return $storage;
        });

        $app->singleton(FluentRefreshToken::class, function () use ($provider) {
            $storage = new FluentRefreshToken($provider->app['db']);
            $storage->setConnectionName($provider->getConnectionName());

            return $storage;
        });

        $app->singleton(FluentScope::class, function ($app) use ($provider) {
            $limitClientsToScopes = $app['config']->get('oauth2.limit_clients_to_scopes');
            $limitScopesToGrants = $app['config']->get('oauth2.limit_scopes_to_grants');
            $storage = new FluentScope($provider->app['db'], $limitClientsToScopes, $limitScopesToGrants);
            $storage->setConnectionName($provider->getConnectionName());

            return $storage;
        });

        $app->singleton(FluentSession::class, function () use ($provider) {
            $storage = new FluentSession($provider->app['db']);
            $storage->setConnectionName($provider->getConnectionName());

            return $storage;
        });
    }
201279
public static function make($app)
	{
		$app->boot();

		$console = with($console = new static('WEL. A w.eloquent console by artisan.', $app::VERSION))
			->setLaravel($app)
			->setExceptionHandler($app['exception'])
			->setAutoExit(false);

		$app->instance('artisan', $console);

		return $console;
	}
389411
public function register(Application $app)
    {
        /** @var ApplicationConfiguration $config */
        $config = $app['config'];

        $app['translator.locale'] = $config->getTranslator()->getLocale();

        $app['translator'] = $app->share(
            function ($app) {
                $translator = new Translator();
                $translator->setLocale($app['translator.locale']);

                return $translator;
            }
        );
    }
975559
public function createApplicationPassword(ApplicationPassword $application)
    {
        return $this->createCommand()
            ->setRequest($this->client->post('application'))
            ->setBodyEntity($application, 'json')
            ->setResponseClass('Maba\OAuthCommerceInternalClient\Entity\ApplicationPassword')
        ;
    }
901976
protected function startBindingsPlugin($app)
    {
        /* @var \Illuminate\Foundation\Application $app */
        $this->requiresPlugins(Commands::class, Events::class);

        $this->onRegister('bindings', function (Application $app) {

            // Container bindings and aliases
            $legacy = ! class_exists('Illuminate\Foundation\Application') || version_compare(\Illuminate\Foundation\Application::VERSION, '5.7.0', '<');
            if ($legacy) {
                foreach ($this->bindings as $binding => $class) {
                    $this->app->bind($binding, $class);
                }
            }

            foreach ($this->weaklings as $binding => $class) {
                $this->bindIf($binding, $class);
            }

            foreach ([ 'share' => $this->share, 'shared' => $this->shared ] as $type => $bindings) {
                foreach ($bindings as $binding => $class) {
                    $this->share($binding, $class, [], $type === 'shared');
                }
            }

            if ($legacy) {
                foreach ($this->singletons as $binding => $class) {
                    if ($this->strict && ! class_exists($class) && ! interface_exists($class)) {
                        throw new \Exception(get_called_class() . ": Could not find alias class [{$class}]. This exception is only thrown when \$strict checking is enabled");
                    }
                    $this->app->singleton($binding, $class);
                }
            }

            foreach ($this->aliases as $alias => $full) {
                if ($this->strict && ! class_exists($full) && ! interface_exists($full)) {
                    throw new \Exception(get_called_class() . ": Could not find alias class [{$full}]. This exception is only thrown when \$strict checking is enabled");
                }
                $this->app->alias($alias, $full);
            }
        });
    }
75349
public function setup(Application $app)
    {
        $app['oauth.storage'] = $app->share(function ($app) {
            // Create the storage object
            $storage = new OAuth2ZendDb($app['db']);
            $storage->setUserMapper($app['user.mapper']);

            return $storage;
        });

        $app['oauth_server'] = $app->share(function ($app) {
            $storage = $app['oauth.storage'];
            $authConfig = $app['config']->load('auth');

            $grantTypes = [
                'authorization_code' => new AuthorizationCode($storage),
                'refresh_token'      => new RefreshToken($storage),
                'user_credentials'   => new UserCredentials($storage),
            ];

            $accessTokenResponseType = new AccessToken($storage, $storage, $authConfig);
            $authCodeResponseType = new AuthorizationCodeResponse($storage);

            return new OAuth2Server(
                $storage,
                [
                    'enforce_state'  => false,
                    'allow_implicit' => true,
                ],
                $grantTypes,
                [
                    'token' => $accessTokenResponseType,
                    'code'  => $authCodeResponseType,
                ]
            );
        });

        $app['oauth.controller'] = $app->share(function ($app) {
            $loginConfiguration = $app['config']->load('login');

            return new OAuthController(
                $app['oauth_server'],
                $app['user.service'],
                $app['oauth-access-token.mapper'],
                $app['oauth-refresh-token.mapper'],
                $app['mustache'],
                $app['session'],
                $loginConfiguration['requireVerification']
            );
        });

        $app['oauth-access-token.mapper'] = $app->share(function ($app) {
            return new AccessTokenMapper($app['db'], new AccessTokenEntity);
        });

        $app['oauth-refresh-token.mapper'] = $app->share(function ($app) {
            return new RefreshTokenMapper($app['db'], new RefreshTokenEntity);
        });
    }
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);
    }
1028728
public function setApplication(ApplicationInterface $application)
    {
        $this->setParam('application', $application);
        $this->application = $application;
        return $this;
    }
948075
public function register(Application $app)
    {
        $app['guzzle.base_url'] = '/';
        if(!isset($app['guzzle.plugins'])){
            $app['guzzle.plugins'] = array();
        }

        // Register a Guzzle ServiceBuilder
        $app['guzzle'] = $app->share(function () use ($app) {
            if (!isset($app['guzzle.services'])) {
                $builder = new ServiceBuilder(array());
            } else {
                $builder = ServiceBuilder::factory($app['guzzle.services']);
            }

            return $builder;
        });

        // Register a simple Guzzle Client object (requires absolute URLs when guzzle.base_url is unset)
        $app['guzzle.client'] = $app->share(function() use ($app) {
            $client = new Client($app['guzzle.base_url']);

            foreach ($app['guzzle.plugins'] as $plugin) {
                $client->addSubscriber($plugin);
            }

            return $client;
        });
    }
556307
public function register(Application $app)
    {
        $app['rest_normalizer.version'] = '0.1.0';
        $app['rest_normalizer.builder'] = $app->protect(
            function ($object = null) use ($app) {
                $version = $app['rest_normalizer.version'];
                $request = $app['request'];
                /** @var $request \Symfony\Component\HttpFoundation\Request */

                $builder = ResponseBuilder::create(
                    $version,
                    HttpMethod::valueOf($request->getMethod()),
                    $object
                );

                foreach ($request->request->all() as $key => $value) {
                    $parameter = Parameter::create($key, $value);
                    $builder->addParameter($parameter);
                }

                return $builder;
            }
        );
    }
548191
public function register(Application $app)
    {
        $this->eloquent = new EloquentCapsule();
        $config = Database::getDatabaseConfiguration();

        /*
         | We will loop over all connections
         | and set connection
         */
        foreach ($config as $key => $c) {
            $this->setConnection($c);
        }

        $this->eloquent->setEventDispatcher(new Dispatcher(new Container()));
        // Make this Capsule instance available globally via static methods... (optional)
        $this->eloquent->setAsGlobal();
        // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher())
        $this->eloquent->bootEloquent();
    }