Bolt\Configuration\ResourceManager::__construct PHP Method

__construct() public method

Constructor initialises on the app root path.
public __construct ( ArrayAccess $container )
$container ArrayAccess ArrayAccess compatible DI container that must contain one of: 'classloader' of instance a ClassLoader will use introspection to find root path or 'rootpath' will be treated as an existing directory as string. Optional ones: 'request' - Symfony\Component\HttpFoundation\Request
    public function __construct(\ArrayAccess $container)
    {
        $this->pathManager = $container['pathmanager'];
        if (!empty($container['classloader']) && $container['classloader'] instanceof ClassLoader) {
            $this->root = $this->useLoader($container['classloader']);
        } else {
            $this->root = $this->setPath('root', $container['rootpath']);
        }
        if (!$container instanceof Application && !empty($container['request'])) {
            $this->requestObject = $container['request'];
        }
        $this->setUrl('root', '/');
        $this->setUrl('app', '/app/');
        $this->setPath('apppath', 'app');
        $this->setUrl('extensions', '/extensions/');
        $this->setPath('extensionsconfig', 'app/config/extensions');
        $this->setPath('extensionspath', 'extensions');
        $this->setUrl('files', '/files/');
        $this->setPath('filespath', 'files');
        $this->setUrl('async', '/async/');
        $this->setUrl('upload', '/upload/');
        $this->setUrl('bolt', '/bolt/');
        $this->setUrl('theme', '/theme/');
        $this->setUrl('themes', '/theme/');
        // Needed for filebrowser. See #5759
        $this->setPath('web', '');
        $this->setPath('cache', 'app/cache');
        $this->setPath('config', 'app/config');
        $this->setPath('src', dirname(__DIR__));
        $this->setPath('database', 'app/database');
        $this->setPath('themebase', 'theme');
        $this->setPath('view', 'app/view');
        $this->setUrl('view', '/app/view/');
    }

Usage Example

Example #1
0
 /**
  * @param ClassLoader|string $loader  ClassLoader or root path
  * @param Request            $request
  */
 public function __construct($loader, Request $request = null)
 {
     $container = new \Pimple();
     if ($loader instanceof ClassLoader) {
         $container['classloader'] = $loader;
     } else {
         $container['rootpath'] = $loader;
     }
     $container['pathmanager'] = new PlatformFileSystemPathFactory();
     $container['request'] = $request;
     parent::__construct($container);
 }