Example #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.");
 }
Example #2
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.");
 }
 /**
  * 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);
     }
 }
Example #4
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;
 }
 /**
  * Find the route that uses the given action.
  *
  * @param  string  $action
  * @return array
  */
 public static function uses($action)
 {
     // If the action has already been reverse routed before, we'll just
     // grab the previously found route to save time. They are cached
     // in a static array on the class.
     if (isset(static::$uses[$action])) {
         return static::$uses[$action];
     }
     Bundle::routes(Bundle::name($action));
     // To find the route, we'll simply spin through the routes looking
     // for a route with a "uses" key matching the action, and if we
     // find one, we cache and return it.
     foreach (static::routes() as $method => $routes) {
         foreach ($routes as $key => $value) {
             if (isset($value['uses']) and $value['uses'] === $action) {
                 return static::$uses[$action] = array($key => $value);
             }
         }
     }
 }
Example #6
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());
 }
Example #7
0
 public static function uses($action)
 {
     if (isset(static::$uses[$action])) {
         return static::$uses[$action];
     }
     Bundle::routes(Bundle::name($action));
     foreach (static::routes() as $method => $routes) {
         foreach ($routes as $key => $value) {
             if (isset($value['uses']) and $value['uses'] === $action) {
                 return static::$uses[$action] = array($key => $value);
             }
         }
     }
 }
Example #8
0
 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);
     }
 }
Example #9
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;
 }