Пример #1
0
 /**
  * @see AbstractTheme::init()
  */
 protected function init()
 {
     $gantry = static::gantry();
     // Add particles, styles and defaults into DI.
     $gantry['particles'] = function ($c) {
         return new Particles($c);
     };
     $gantry['styles'] = function ($c) {
         return new Styles($c);
     };
     $gantry['defaults'] = function ($c) {
         /** @var UniformResourceLocator $locator */
         $locator = $c['locator'];
         $cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
         $paths = $locator->findResources('gantry-config://default');
         $files = (new ConfigFileFinder())->locateFiles($paths);
         $config = new CompiledConfig($cache, $files, function () use($c) {
             return $c['blueprints'];
         });
         return $config->load(true);
     };
     // Initialize admin streams.
     /** @var Platform $patform */
     $patform = $gantry['platform'];
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     $nucleus = $patform->getEnginePaths('nucleus')[''];
     $relpath = Folder::getRelativePath($this->path);
     $patform->set('streams.gantry-admin.prefixes', ['' => ['gantry-theme://admin', $relpath, $relpath . '/common', 'gantry-engine://admin'], 'assets/' => array_merge([$relpath, $relpath . '/common'], $nucleus, ['gantry-assets://'])]);
     // Add admin paths.
     foreach ($patform->get('streams.gantry-admin.prefixes') as $prefix => $paths) {
         $locator->addPath('gantry-admin', $prefix, $paths);
     }
 }
Пример #2
0
 public function __construct($path, $name = '')
 {
     $gantry = \Gantry\Framework\Gantry::instance();
     $relpath = Folder::getRelativePath($path);
     // Initialize admin streams.
     /** @var Platform $patform */
     $patform = $gantry['platform'];
     $nucleus = $patform->getEnginePaths('nucleus')[''];
     $patform->set('streams.gantry-admin.prefixes', ['' => ['gantry-theme://admin', $relpath, $relpath . '/common', 'gantry-engine://admin'], 'assets/' => array_merge([$relpath, $relpath . '/common'], $nucleus, ['gantry-assets://'])]);
     $gantry['particles'] = function ($c) {
         return new Particles($c);
     };
     $gantry['styles'] = function ($c) {
         return new Styles($c);
     };
     $gantry['defaults'] = function ($c) {
         /** @var UniformResourceLocator $locator */
         $locator = $c['locator'];
         $cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
         $paths = $locator->findResources('gantry-config://default');
         $files = (new ConfigFileFinder())->locateFiles($paths);
         $config = new CompiledConfig($cache, $files, function () use($c) {
             return $c['blueprints'];
         });
         return $config->load(true);
     };
     parent::__construct($path, $name);
     $this->boot();
 }
Пример #3
0
 public function loadAssignments()
 {
     $gantry = Gantry::instance();
     /** @var UniformResourceLocator $locator */
     $locator = $gantry['locator'];
     // Find all the assignment files.
     $paths = $locator->findResources("gantry-config://");
     $files = (new ConfigFileFinder())->locateFileInFolder('assignments', $paths);
     $cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
     $config = new CompiledConfig($cache, [$files]);
     return $config->load();
 }
 public static function load(Container $container, $name = 'default')
 {
     /** @var UniformResourceLocator $locator */
     $locator = $container['locator'];
     // Merge current configuration with the default.
     $uris = array_unique(["gantry-config://{$name}", 'gantry-config://default']);
     $paths = [];
     foreach ($uris as $uri) {
         $paths = array_merge($paths, $locator->findResources($uri));
     }
     // Locate all configuration files to be compiled.
     $files = (new ConfigFileFinder())->locateFiles($paths);
     $cache = $locator->findResource('gantry-cache://compiled/config', true, true);
     $config = new CompiledConfig($cache, $files, function () use($container) {
         return $container['blueprints'];
     });
     return $config->load();
 }
Пример #5
0
 public static function load(Container $container, $name = 'default')
 {
     /** @var UniformResourceLocator $locator */
     $locator = $container['locator'];
     // Merge current configuration with the default.
     $uris = array_unique(["gantry-config://{$name}", 'gantry-config://default']);
     $paths = [];
     foreach ($uris as $uri) {
         $paths = array_merge($paths, $locator->findResources($uri));
     }
     // Locate all configuration files to be compiled.
     $files = (new ConfigFileFinder())->locateFiles($paths);
     $cache = $locator->findResource('gantry-cache://theme/compiled/config', true, true);
     if (!$cache) {
         throw new \RuntimeException('Who just removed Gantry 5 cache folder? Try reloading the page if it fixes the issue');
     }
     $config = new CompiledConfig($cache, $files, function () use($container) {
         return $container['blueprints'];
     });
     return $config->load();
 }