Example #1
0
 public static function cc($name, $actions = array())
 {
     // First Run
     if (empty(self::$cc)) {
         if (function_exists('apc_fetch') && ($cc = apc_fetch('Eyeem_Runtime_CC'))) {
             self::$cc = $cc;
         }
     }
     // Direct
     if (isset(self::$cc[$name])) {
         return self::$cc[$name];
     }
     // Iterate over actions passed as parameter
     foreach ($actions as $action) {
         // Found a match
         if (strpos($name, $action) === 0) {
             $key = substr($name, strlen($action));
             if (function_exists('lcfirst')) {
                 $key = lcfirst($key);
             } else {
                 $key[0] = strtolower($key[0]);
             }
             // Register shutdown function
             if (!self::$ccStoreRegistered) {
                 register_shutdown_function(array('Eyeem_Runtime', 'ccStore'));
                 self::$ccStoreRegistered = true;
             }
             // Return and store result
             return self::$cc[$name] = array($action, $key);
         }
     }
     // Return and store empty result
     return self::$cc[$name] = array(null, null);
 }
Example #2
0
 public function __call($name, $arguments)
 {
     $actions = array('get', 'set', 'flush');
     list($action, $key) = isset(Eyeem_Runtime::$cc[$name]) ? Eyeem_Runtime::$cc[$name] : Eyeem_Runtime::cc($name, $actions);
     // Get methods
     if ($action == 'get') {
         // Collection Objects
         if (isset(static::$collections[$key])) {
             $parameters = isset($arguments[0]) ? $arguments[0] : array();
             $collection = $this->getCollection($key);
             $collection->setQueryParameters($parameters);
             return $collection;
         }
         // Default (read object property)
         return $this->{$key};
     } elseif ($action == 'set') {
         // Default (write object property)
         $this->{$key} = $arguments[0];
         return $this;
     } elseif ($action == 'flush') {
         // Default (delete object property)
         if (isset($this->{$key})) {
             unset($this->{$key});
         }
         return $this;
     }
     throw new Exception("Unknown method ({$name}).");
 }
Example #3
0
 public function __call($name, $arguments)
 {
     $actions = array('get', 'set');
     list($action, $key) = isset(Eyeem_Runtime::$cc[$name]) ? Eyeem_Runtime::$cc[$name] : Eyeem_Runtime::cc($name, $actions);
     // Get methods
     if ($action == 'get') {
         // Ressource Objects
         if (in_array($key, $this->_ressources)) {
             return $this->getRessourceObject($key, $arguments[0]);
         }
         // Default (read object property)
         return $this->{$key};
     } elseif ($action == 'set') {
         // Default (write object property)
         $this->{$key} = $arguments[0];
         return $this;
     }
     throw new Exception("Unknown method ({$name}).");
 }
Example #4
0
 public function __call($name, $arguments)
 {
     $actions = array('get', 'set', 'flush');
     list($action, $key) = isset(Eyeem_Runtime::$cc[$name]) ? Eyeem_Runtime::$cc[$name] : Eyeem_Runtime::cc($name, $actions);
     // Get methods
     if ($action == 'get') {
         // Default (read object property)
         return $this->{$key};
     } elseif ($action == 'set') {
         // Default (write object property)
         $this->{$key} = $arguments[0];
         return $this;
     } elseif ($action == 'flush') {
         // Default (flush object property)
         $this->{$key} = null;
         unset($this->{$key});
         return $this;
     }
     throw new Exception("Unknown method ({$name}).");
 }