示例#1
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;
 }
示例#2
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);
     }
 }
示例#3
0
 /**
  * Checks if this is the current environment
  * 
  * @return boolean True if listed in this environment, false otherwise
  */
 public function isCurrent()
 {
     // Use Hosts to determine current environment
     if ($this->__hosts->count() >= 1) {
         return $this->__hosts->hasValue($_SERVER['SERVER_NAME']);
     } elseif (getenv('APP_ENV') && getenv('APP_ENV') == $this->__key) {
         return true;
     }
     return false;
 }
示例#4
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');
 }
示例#5
0
 /**
  * Returns all urls
  * 
  * @return array
  */
 public function getAll()
 {
     return $this->__urls->getAll();
 }
示例#6
0
 /**
  * Returns all paths
  * 
  * @return array
  */
 public function getAll()
 {
     return $this->__paths->getAll();
 }