Since: 0.1.0
Inheritance: extends AbstractResource, use trait M1\Vars\Traits\ResourceFlagsTrait
Esempio n. 1
0
 /**
  * Import resource into the imported resources and merge contents
  *
  * @param ResourceProvider $provider The new imported resource
  * @param array            $imported_resources The imported resources
  *
  * @return array The modified imported resources
  */
 private function importResource(ResourceProvider $provider, $imported_resources)
 {
     $content = $provider->getContent();
     $parent_content = $provider->getParentContent();
     if (!empty($content)) {
         $imported_resources = array_replace_recursive($imported_resources, $content);
     }
     if (!empty($parent_content)) {
         $this->provider->addParentContent($parent_content);
     }
     return $imported_resources;
 }
Esempio n. 2
0
 /**
  * Creates the FileResource|ResourceProvider from the resource
  *
  * @param array  $resources The array of resources
  * @param string $type      The type of the resource
  */
 private function createResources(array $resources, $type)
 {
     foreach ($resources as $resource) {
         if ($type === "string") {
             $this->vars->pathsLoadedCheck($resource);
             if ($this->vars->cache->checkCache()) {
                 return;
             }
             if ($this->vars->resourceImported($resource)) {
                 continue;
             }
             $pos = $this->vars->addResource($resource);
             $resource = new FileResource($this, $resource);
             $this->vars->updateResource($resource, $pos);
         } else {
             $resource = new ResourceProvider($this->vars, $resource);
         }
         $this->addContent($resource->getContent());
     }
 }
Esempio n. 3
0
 /**
  * Creates a new instance of Vars
  *
  * @param string|array $resource The main configuration resource
  * @param array        $options  The options being used for Vars
  */
 public function __construct($resource, $options = array())
 {
     $options = $this->parseOptions($options);
     $this->makeCache($options, $resource);
     $this->makePaths($options);
     if (!$this->cache->checkCache()) {
         $this->makeLoader($options);
         $this->makeVariables($options);
         $resource = new ResourceProvider($this, $resource);
     }
     if ($this->cache->isHit()) {
         $this->loadFromCache();
     } else {
         $resource->mergeParentContent();
         $this->content = $resource->getContent();
         $this->cache->setTime(time());
         $this->cache->makeCache($this);
     }
 }