Beispiel #1
0
 /**
  * Get the path to a view on disk.
  *
  * @param $view
  *
  * @return string
  * @throws \Exception
  */
 protected function path($view)
 {
     $view = str_replace('.', '/', $view);
     $this->bundle_root = $root = Bundle::path(Bundle::name($view)) . 'views';
     $path = $root . DS . Bundle::element($view) . $this->template_ext;
     if (file_exists($path)) {
         $this->template = $view . $this->template_ext;
         return $path;
     }
     throw new \Exception("View [{$view}] does not exist.");
 }
 /**
  * Parse a language key into its bundle, file, and line segments.
  *
  * Language lines follow a {bundle}::{file}.{line} naming convention.
  *
  * @param  string  $key
  * @return array
  */
 protected function parse($key)
 {
     $bundle = Bundle::name($key);
     $segments = explode('.', Bundle::element($key));
     // If there are not at least two segments in the array, it means that
     // the developer is requesting the entire language line array to be
     // returned. If that is the case, we'll make the item "null".
     if (count($segments) >= 2) {
         $line = implode('.', array_slice($segments, 1));
         return array($bundle, $segments[0], $line);
     } else {
         return array($bundle, $segments[0], null);
     }
 }
Beispiel #3
0
 /**
  * Parse a key and return its bundle, file, and key segments.
  *
  * Configuration items are named using the {bundle}::{file}.{item} convention.
  *
  * @param  string  $key
  * @return array
  */
 protected static function parse($key)
 {
     // First, we'll check the keyed cache of configuration items, as this will
     // be the fastest method of retrieving the configuration option. After an
     // item is parsed, it is always stored in the cache by its key.
     if (array_key_exists($key, static::$cache)) {
         return static::$cache[$key];
     }
     $bundle = Bundle::name($key);
     $segments = explode('.', Bundle::element($key));
     // If there are not at least two segments in the array, it means that the
     // developer is requesting the entire configuration array to be returned.
     // If that is the case, we'll make the item field "null".
     if (count($segments) >= 2) {
         $parsed = array($bundle, $segments[0], implode('.', array_slice($segments, 1)));
     } else {
         $parsed = array($bundle, $segments[0], null);
     }
     return static::$cache[$key] = $parsed;
 }
Beispiel #4
0
 /**
  * Get the path to a given view on disk.
  *
  * @param  string  $view
  * @return string
  */
 protected function path($view)
 {
     $view = str_replace('.', '/', $view);
     $root = Bundle::path(Bundle::name($view)) . 'views/';
     // Views may have the normal PHP extension or the Blade PHP extension, so
     // we need to check if either of them exist in the base views directory
     // for the bundle and return the first one we find.
     foreach (array(EXT, BLADE_EXT) as $extension) {
         if (file_exists($path = $root . Bundle::element($view) . $extension)) {
             return $path;
         }
     }
     throw new \Exception("View [{$view}] does not exist.");
 }
Beispiel #5
0
 /**
  * Parse the filter string, returning the filter name and parameters.
  *
  * @param  string  $filter
  * @return array
  */
 public function get($filter)
 {
     // If the parameters were specified by passing an array into the collection,
     // then we will simply return those parameters. Combining passed parameters
     // with parameters specified directly in the filter attachment is not
     // currently supported by the framework.
     if (!is_null($this->parameters)) {
         return array($filter, $this->parameters());
     }
     // If no parameters were specified when the collection was created, we will
     // check the filter string itself to see if the parameters were injected
     // into the string as raw values, such as "role:admin".
     if (($colon = strpos(Bundle::element($filter), ':')) !== false) {
         $parameters = explode(',', substr(Bundle::element($filter), $colon + 1));
         // If the filter belongs to a bundle, we need to re-calculate the position
         // of the parameter colon, since we originally calculated it without the
         // bundle identifier because the identifier uses colons as well.
         if (($bundle = Bundle::name($filter)) !== DEFAULT_BUNDLE) {
             $colon = strlen($bundle . '::') + $colon;
         }
         return array(substr($filter, 0, $colon), $parameters);
     }
     // If no parameters were specified when the collection was created or
     // in the filter string, we will just return the filter name as is
     // and give back an empty array of parameters.
     return array($filter, array());
 }
 protected function parse($key)
 {
     $bundle = Bundle::name($key);
     $segments = explode('.', Bundle::element($key));
     if (count($segments) >= 2) {
         $line = implode('.', array_slice($segments, 1));
         return array($bundle, $segments[0], $line);
     } else {
         return array($bundle, $segments[0], null);
     }
 }
 public function get($filter)
 {
     if (!is_null($this->parameters)) {
         return array($filter, $this->parameters());
     }
     if (($colon = strpos(Bundle::element($filter), ':')) !== false) {
         $parameters = explode(',', substr(Bundle::element($filter), $colon + 1));
         if (($bundle = Bundle::name($filter)) !== DEFAULT_BUNDLE) {
             $colon = strlen($bundle . '::') + $colon;
         }
         return array(substr($filter, 0, $colon), $parameters);
     }
     return array($filter, array());
 }
Beispiel #8
0
 /**
  * Returns true if the template is still fresh
  *
  * @param  string     $name  The template name
  * @param  timestamp  $time  The last modification time of the cached template
  * @return bool
  */
 public function isFresh($name, $time)
 {
     return filemtime($this->getPath(Bundle::name($name), Bundle::element($name))) < $time;
 }