Exemple #1
0
 public function __construct(array $items = array(), Grav $grav = null, $environment = null)
 {
     $this->grav = $grav ?: Grav::instance();
     $this->finder = new ConfigFinder();
     $this->environment = $environment ?: 'localhost';
     $this->messages[] = 'Environment Name: ' . $this->environment;
     if (isset($items['@class'])) {
         if ($items['@class'] != get_class($this)) {
             throw new \InvalidArgumentException('Unrecognized config cache file!');
         }
         // Loading pre-compiled configuration.
         $this->timestamp = (int) $items['timestamp'];
         $this->checksum = $items['checksum'];
         $this->items = (array) $items['data'];
     } else {
         // Make sure that
         if (!isset($items['streams']['schemes'])) {
             $items['streams']['schemes'] = [];
         }
         $items['streams']['schemes'] += $this->streams;
         $items = $this->autoDetectEnvironmentConfig($items);
         $this->messages[] = $items['streams']['schemes']['config']['prefixes'][''];
         parent::__construct($items);
     }
     $this->check();
 }
Exemple #2
0
 /**
  * Construct.
  *
  * @param array $items
  * @param Blueprint $blueprint
  */
 public function __construct($items = [], Blueprint $blueprint = null)
 {
     parent::__construct($items, $blueprint);
     if (self::getGrav()['config']->get('system.media.enable_media_timestamp', true)) {
         $this->querystring('&' . self::getGrav()['cache']->getKey());
     }
     $this->def('mime', 'application/octet-stream');
     $this->reset();
 }
Exemple #3
0
 public function __construct($items = array(), Blueprint $blueprint = null)
 {
     parent::__construct($items, $blueprint);
     if ($this->get('type') == 'image') {
         $filePath = $this->get('path') . '/' . $this->get('filename');
         $image_info = getimagesize($filePath);
         $this->set('thumb', $filePath);
         $this->def('width', $image_info[0]);
         $this->def('height', $image_info[1]);
         $this->def('mime', $image_info['mime']);
         $this->reset();
     } else {
         $this->def('mime', 'application/octet-stream');
     }
 }
 public function __construct(array $setup = array(), Grav $grav = null, $environment = null)
 {
     $this->grav = $grav ?: Grav::instance();
     $this->finder = new ConfigFinder();
     $this->environment = $environment ?: 'localhost';
     $this->messages[] = 'Environment Name: ' . $this->environment;
     // Make sure that
     if (!isset($setup['streams']['schemes'])) {
         $setup['streams']['schemes'] = [];
     }
     $setup['streams']['schemes'] += $this->streams;
     $setup = $this->autoDetectEnvironmentConfig($setup);
     $this->setup = $setup;
     parent::__construct($setup);
     $this->check();
 }
Exemple #5
0
 public function __construct($environment = 'localhost')
 {
     // Pre-load setup.php which contains our initial configuration.
     // Configuration may contain dynamic parts, which is why we need to always load it.
     $file = GRAV_ROOT . '/setup.php';
     $setup = is_file($file) ? (array) (include $file) : [];
     // Add default streams defined in beginning of the class.
     if (!isset($setup['streams']['schemes'])) {
         $setup['streams']['schemes'] = [];
     }
     $setup['streams']['schemes'] += $this->streams;
     // Initialize class.
     parent::__construct($setup);
     // Set up environment.
     $this->def('environment', $environment);
     $this->def('streams.schemes.environment.prefixes', ['' => ["user://{$this->environment}"]]);
 }