示例#1
0
 /**
  * Returns a single URL using a key
  * with an optionally suffixed realtive URL
  * 
  * @param  string $key          Key for the target URL
  * @param  string $relative_url Optional relative URL
  * @return string               URL
  */
 public function get($key, $relative_url = null)
 {
     // Get URL without trailing slash
     $url = $this->__urls->get($key);
     // Concatenate relative URL
     if ($relative_url) {
         $url .= '/' . ltrim($relative_url, '/');
     }
     return $url;
 }
示例#2
0
 /**
  * Returns a single path using a key
  * with an optionally suffixed realtive path
  * 
  * @param  string $key           Key for the target path
  * @param  string $relative_path Optional relative path
  * @return string                path
  */
 public function get($key, $relative_path = null)
 {
     // Get path without trailing slash
     $path = $this->__paths->get($key);
     // Concatenate relative URL
     if ($relative_path) {
         $path .= '/' . ltrim($relative_path, '/');
     }
     return $path;
 }
示例#3
0
 /**
  * Gets data with target key
  * 
  * @param  string  $key       Key to get data from
  * @param  boolean $is_single False if we assume there is an array of values, true if only a single value
  * @return mixed              Data contained in target key
  */
 public function get($key, $is_single = false)
 {
     // Get data from container
     $data = $this->__data->get($key);
     // If array and single item is requested, try to unserialize it
     if ($data && is_array($data) && $is_single) {
         // Get first item
         $data = isset($data[0]) ? maybe_unserialize($data[0]) : '';
     } elseif (is_array($data) && !array_filter($data) && $is_single) {
         $data = $is_single ? '' : array();
     }
     // Return data
     return $data;
 }
示例#4
0
 /**
  * Calls the target plugin using its key
  * 
  * @param  string $name Key that identifies the target plugin
  * @param  array  $args Arguments to pass to target plugin
  * @return mixed        New instance of target plugin class
  */
 public function __call($name, $args)
 {
     $className = $this->__plugins->get($name);
     if (class_exists($className)) {
         return call_user_func_array([new \ReflectionClass($className), 'newInstance'], $args);
     }
 }
示例#5
0
 /**
  * Returns the current environment
  * 
  * @return Ponticlaro\Bebop\Env The current environment
  */
 public function getCurrent()
 {
     $envs = $this->__environments->getAll();
     foreach ($envs as $key => $env) {
         if ($env->isCurrent()) {
             return $env;
         }
     }
     return $this->__environments->get('development');
 }