コード例 #1
0
 /**
  * Create a asset instance.
  *
  * @param  string $name
  * @param  mixed $asset
  * @param  array $dependencies
  * @param  array $options
  * @throws \InvalidArgumentException
  * @return AssetInterface
  */
 protected function create($name, $asset, $dependencies = [], $options = [])
 {
     if (is_string($options)) {
         $options = ['type' => $options];
     }
     if (!isset($options['type'])) {
         $options['type'] = 'file';
     }
     if ($dependencies) {
         $options = array_merge($options, ['dependencies' => (array) $dependencies]);
     }
     if ('string' == $options['type']) {
         return new StringAsset($name, $asset, $options);
     }
     if ('file' == $options['type']) {
         if (isset($options['version'])) {
             $ver = $options['version'];
         } elseif ($this->version) {
             $ver = $options['version'] = $this->version;
         } else {
             $ver = null;
         }
         $options['path'] = $asset;
         return new FileAsset($name, $this->url->to($options['path'], $ver ? compact('ver') : []), $options);
     }
     throw new \InvalidArgumentException('Unable to determine asset type.');
 }
コード例 #2
0
 /**
  * Returns a redirect response.
  *
  * @param  string  $url
  * @param  array   $parameters
  * @param  int     $status
  * @param  array   $headers
  * @return RedirectResponse
  */
 public function redirect($url, $parameters = [], $status = 302, $headers = [])
 {
     return new RedirectResponse($this->url->to($url, $parameters), $status, $headers);
 }