public function getInterceptors($method = 'index')
 {
     $ret = array();
     $ret['before'] = array();
     $ret['after'] = array();
     $ret['around'] = array();
     if (!isset($this->_interceptor_objects)) {
         // Not initialized yet
         $this->_interceptor_objects = array();
         foreach ($this->interceptors as $key => $i) {
             $interceptor = copy_new($i, 'Interceptor');
             if ($key) {
                 // If it has refer
                 if (isset($this->define->{$key})) {
                     $interceptor = copy_object($this->define->{$key}, $interceptor);
                 }
             }
             $this->_interceptor_objects[] = $interceptor;
         }
     }
     foreach ($this->_interceptor_objects as $i) {
         if ($i->accept($method)) {
             $ret[$i->type][] = $i;
         }
     }
     return $ret;
 }
 public function setToken($token)
 {
     $CI =& get_instance();
     $CI->load->library('encryptor');
     $decrypted = $CI->encryptor->decrypt(urldecode($token));
     copy_object(json_decode($decrypted), $this);
     $this->token = $token;
 }
 public function testCopyObject()
 {
     $obj = array('name' => 'Jack', 'age' => 30, 'just.test' => 1);
     $dummy = copy_object($obj, new DummyExample());
     $this->assertEquals($obj['name'], $dummy->name);
     $dummy = copy_new($obj, 'DummyExample');
     $this->assertEquals($obj['name'], $dummy->name);
     $this->assertEquals($obj['just.test'], $dummy->just_test);
 }
 protected function doInit()
 {
     $meta = config('framework_meta');
     if ($meta) {
         $meta = $meta[0];
         copy_object($meta, $this);
     } else {
         $this->repository = $this->tool->library('repository');
         $this->git = $this->tool->library('git');
         $this->commit = $this->repository->getHeadCommit()->getShortHash();
         $this->branch = $this->repository->getBranch();
         $this->lastCommitterDate = $this->repository->lastCommitterDate();
     }
 }
Beispiel #5
0
/**
 * Create an new object using class, and copy all the data from src to it
 *
 * @author Jack
 * @date Sat Feb 21 11:07:08 2015
 * @param src
 * 		The src object or array
 * @param class
 * 		The class of the object, if null will use stdclass
 * @return The object
 */
function copy_new($src, $class = null)
{
    return copy_object($src, null, $class);
}
 private function fromJSON($json)
 {
     copy_object(json_decode($json), $this);
     $this->fixColumns();
     // Fix the columns if needed (when initialize from JSON)
     return $this;
 }
Beispiel #7
0
 public function toJson()
 {
     $obj = copy_object($this);
     if (isset($obj->security)) {
         unset($obj->security);
         unset($obj->_filtered_columns);
     }
     return json_encode($obj);
 }