src/Charcoal/Admin/ServiceProvider/AdminServiceProvider.php
protected function registerAdminServices(Container $container)
    {
        /**
         * The admin configset.
         *
         * @param  Container $container The Pimple DI Container.
         * @return AdminConfig
         */
        $container['admin/config'] = function (Container $container) {
            $appConfig = $container['config'];

            // The `admin.json` file is not part of regular config
            $extraConfigs = (array)$appConfig['admin_config'];

            $moduleAdminConfigs = [];

            foreach ($container['module/classes'] as $module) {
                if (defined(sprintf('%s::ADMIN_CONFIG', $module))) {
                    $moduleAdminConfigs[] = $module::ADMIN_CONFIG;
                };
            }

            if (!empty($moduleAdminConfigs)) {
                $extraConfigs = array_merge(
                    $extraConfigs,
                    $moduleAdminConfigs
                );
            }

            if (!empty($extraConfigs)) {
                $basePath = $appConfig['base_path'];
                foreach ($extraConfigs as $path) {
                    $appConfig->addFile($basePath.$path);
                }
            }

            return new AdminConfig($appConfig['admin']);
        };

        if (!isset($container['admin/base-url'])) {
            /**
             * Base Admin URL as a PSR-7 UriInterface object for the current request
             * or the Charcoal application.
             *
             * @param  Container $container The Pimple DI Container.
             * @return \Psr\Http\Message\UriInterface
             */
            $container['admin/base-url'] = function (Container $container) {
                $adminConfig = $container['admin/config'];

                if (isset($adminConfig['base_url'])) {
                    $adminUrl = $adminConfig['base_url'];
                } else {
                    $adminUrl = clone $container['base-url'];
                    if ($adminConfig['base_path']) {
                        $basePath  = rtrim($adminUrl->getBasePath(), '/');
                        $adminPath = ltrim($adminConfig['base_path'], '/');
                        $adminUrl  = $adminUrl->withBasePath($basePath.'/'.$adminPath);
                    }
                }

                $adminUrl = Uri::createFromString($adminUrl)->withUserInfo('');

                /** Fix the base path */
                $path = $adminUrl->getPath();
                if ($path) {
                    $adminUrl = $adminUrl->withBasePath($path)->withPath('');
                }

                return $adminUrl;
            };
        }
    }
protected function registerAdminServices(Container $container)
    {
        /**
         * The admin configset.
         *
         * @param  Container $container The Pimple DI Container.
         * @return AdminConfig
         */
        $container['admin/config'] = function (Container $container) {
            $appConfig = $container['config'];

            // The `admin.json` file is not part of regular config
            $extraConfigs = (array)$appConfig['admin_config'];

            $moduleAdminConfigs = [];

            foreach ($container['module/classes'] as $module) {
                if (defined(sprintf('%s::ADMIN_CONFIG', $module))) {
                    $moduleAdminConfigs[] = $module::ADMIN_CONFIG;
                };
            }

            if (!empty($moduleAdminConfigs)) {
                $extraConfigs = array_merge(
                    $extraConfigs,
                    $moduleAdminConfigs
                );
            }

            if (!empty($extraConfigs)) {
                $basePath = $appConfig['base_path'];
                foreach ($extraConfigs as $path) {
                    $appConfig->addFile($basePath.$path);
                }
            }

            return new AdminConfig($appConfig['admin']);
        };

        if (!isset($container['admin/base-url'])) {
            /**
             * Base Admin URL as a PSR-7 UriInterface object for the current request
             * or the Charcoal application.
             *
             * @param  Container $container The Pimple DI Container.
             * @return \Psr\Http\Message\UriInterface
             */
            $container['admin/base-url'] = function (Container $container) {
                $adminConfig = $container['admin/config'];

                if (isset($adminConfig['base_url'])) {
                    $adminUrl = $adminConfig['base_url'];
                } else {
                    $adminUrl = clone $container['base-url'];
                    if ($adminConfig['base_path']) {
                        $basePath  = rtrim($adminUrl->getBasePath(), '/');
                        $adminPath = ltrim($adminConfig['base_path'], '/');
                        $adminUrl  = $adminUrl->withBasePath($basePath.'/'.$adminPath);
                    }
                }

                $adminUrl = Uri::createFromString($adminUrl)->withUserInfo('');

                /** Fix the base path */
                $path = $adminUrl->getPath();
                if ($path) {
                    $adminUrl = $adminUrl->withBasePath($path)->withPath('');
                }

                return $adminUrl;
            };
        }
    }
protected function registerAdminServices ( Container $ container ) { /**
         * The admin configset.
         *
         * @param  Container $container The Pimple DI Container.
         * @return AdminConfig
         */ $ container [ 'admin/config' ] = function ( Container $ container ) { $ appConfig = $ container [ 'config' ] ; // The `admin.json` file is not part of regular config $ extraConfigs = ( array ) $ appConfig [ 'admin_config' ] ; $ moduleAdminConfigs = [ ] ; foreach ( $ container [ 'module/classes' ] as $ module ) { if ( defined ( sprintf ( '%s::ADMIN_CONFIG' , $ module ) ) ) { $ moduleAdminConfigs [ ] = $ module :: ADMIN_CONFIG ; } ; } if ( ! empty ( $ moduleAdminConfigs ) ) { $ extraConfigs = array_merge ( $ extraConfigs , $ moduleAdminConfigs ) ; } if ( ! empty ( $ extraConfigs ) ) { $ basePath = $ appConfig [ 'base_path' ] ; foreach ( $ extraConfigs as $ path ) { $ appConfig -> addFile ( $ basePath . $ path ) ; } } return new AdminConfig ( $ appConfig [ 'admin' ] ) ; } ; if ( ! isset ( $ container [ 'admin/base-url' ] ) ) { /**
             * Base Admin URL as a PSR-7 UriInterface object for the current request
             * or the Charcoal application.
             *
             * @param  Container $container The Pimple DI Container.
             * @return \Psr\Http\Message\UriInterface
             */ $ container [ 'admin/base-url' ] = function ( Container $ container ) { $ adminConfig = $ container [ 'admin/config' ] ; if ( isset ( $ adminConfig [ 'base_url' ] ) ) { $ adminUrl = $ adminConfig [ 'base_url' ] ; } else { $ adminUrl = clone $ container [ 'base-url' ] ; if ( $ adminConfig [ 'base_path' ] ) { $ basePath = rtrim ( $ adminUrl -> getBasePath ( ) , '/' ) ; $ adminPath = ltrim ( $ adminConfig [ 'base_path' ] , '/' ) ; $ adminUrl = $ adminUrl -> withBasePath ( $ basePath . '/' . $ adminPath ) ; } } $ adminUrl = Uri :: createFromString ( $ adminUrl ) -> withUserInfo ( '' ) ; /** Fix the base path */ $ path = $ adminUrl -> getPath ( ) ; if ( $ path ) { $ adminUrl = $ adminUrl -> withBasePath ( $ path ) -> withPath ( '' ) ; } return $ adminUrl ; } ; } }
Registers admin services.

@param  Container $container The Pimple DI container.
@return void
Registers admin services .