예제 #1
0
파일: View.php 프로젝트: ejailesb/repo
 /**
  * Loads a template.
  *
  * @param  string $name
  * @return string
  */
 protected function load($name)
 {
     if (isset($this->cache[$name])) {
         return $this->cache[$name];
     }
     $template = $this->loader->load($name);
     if ($template === false) {
         throw new \InvalidArgumentException(sprintf('The template "%s" does not exist.', $name));
     }
     return $this->cache[$name] = $template;
 }
예제 #2
0
 /**
  * Create an asset instance.
  *
  * @param  string $name
  * @param  mixed  $source
  * @param  mixed  $dependencies
  * @param  mixed  $options
  * @return AssetInterface
  * @throws \InvalidArgumentException
  */
 public function create($name, $source, $dependencies = array(), $options = array())
 {
     if (is_string($dependencies)) {
         $dependencies = array($dependencies);
     }
     if (is_string($options)) {
         $options = array('type' => $options);
     }
     if (!isset($options['type'])) {
         $options['type'] = 'file';
     }
     if ($options['type'] == 'file') {
         $options['path'] = $this->loader->load($source);
     }
     if (isset($this->types[$options['type']])) {
         $class = $this->types[$options['type']];
         return new $class($name, $source, $dependencies, $options);
     }
     throw new \InvalidArgumentException('Unable to determine asset type.');
 }
예제 #3
0
 /**
  * Create an asset instance.
  *
  * @param  string $name
  * @param  mixed  $asset
  * @param  array  $dependencies
  * @param  array  $options
  * @throws \InvalidArgumentException
  * @return AssetInterface
  */
 protected function create($name, $asset, $dependencies = array(), $options = array())
 {
     if (is_string($options)) {
         $options = array('type' => $options);
     }
     if (!isset($options['type'])) {
         $options['type'] = 'file';
     }
     if (!isset($options['version'])) {
         $options['version'] = $this->version;
     }
     if ($dependencies) {
         $options = array_merge($options, array('dependencies' => (array) $dependencies));
     }
     if ('string' == $options['type']) {
         return new StringAsset($name, $asset, $options);
     }
     if ('file' == $options['type']) {
         $options['path'] = $this->loader->load($asset);
         return new FileAsset($name, $asset, $options);
     }
     throw new \InvalidArgumentException('Unable to determine asset type.');
 }