Example #1
0
 public function test06ExecConstructArray()
 {
     $this->assertTrue(function_exists('exec_construct_array'));
     $class = __NAMESPACE__ . '\\Sample';
     $result = exec_construct_array($class, range(11, 14));
     $this->assertEquals(range(11, 14), $result->data);
     $result = exec_construct_array($class, range(11, 15));
     $this->assertEquals(range(11, 15), $result->data);
 }
Example #2
0
 /**
  * 生产对象
  */
 public function create($name, $key = 'default')
 {
     $section = $this->storage->getSectionOnce($name);
     $class = $this->normalize($section->getItem('class'));
     $data = $section->getArray($key);
     if ($key !== 'default') {
         $data = array_merge($section->getArray('default'), $data);
     }
     if (class_exists($class)) {
         foreach ($data as $field => &$value) {
             if (starts_with($field, '@')) {
                 $value = $this->load(trim($field, '@'), $value);
             }
         }
         return exec_construct_array($class, array_values($data));
     }
 }
Example #3
0
 /**
  * 生产对象
  */
 public function create($class, $name = 'default')
 {
     $class = $this->normalize($class);
     $section = $this->storage->getSectionOnce($class);
     $data = $section->getArray($name);
     if ($name !== 'default') {
         $data = array_merge($section->getArray('default'), $data);
     }
     if (class_exists($class)) {
         foreach ($data as $key => &$value) {
             if (starts_with($key, '\\')) {
                 $value = $this->load($key, $value);
             }
         }
         return exec_construct_array($class, array_values($data));
     }
 }
Example #4
0
 public function join($name = '*')
 {
     $model = exec_construct_array($this->getModel());
     $behaviors = $model->getBehaviors();
     $names = is_array($name) ? $name : func_get_args();
     if ($name === '*') {
         $this->behaviors =& $behaviors;
         array_shift($names);
     }
     foreach ($names as $name) {
         if ($pos = strpos($name, '.')) {
             $this->deep_joins[substr($name, 0, $pos)] = substr($name, $pos + 1);
         } else {
             if (isset($behaviors[$name])) {
                 $this->behaviors[$name] =& $behaviors[$name];
             }
         }
     }
     return $this;
 }
Example #5
0
 public function join($name = '*')
 {
     $model = exec_construct_array($this->model);
     $relations = $model->getRelations();
     if ($name === '*') {
         $this->relations =& $relations;
     } else {
         $names = func_get_args();
         foreach ($names as $name) {
             if ($name && isset($relations[$name])) {
                 $this->relations[$name] =& $relations[$name];
             }
         }
     }
     return $this;
 }
Example #6
0
 function join($A = '*')
 {
     $c = exec_construct_array($this->model);
     $uC = $c->getRelations();
     if ($A === '*') {
         $this->relations =& $uC;
     } else {
         $zE = func_get_args();
         foreach ($zE as $A) {
             if ($A && isset($uC[$A])) {
                 $this->relations[$A] =& $uC[$A];
             }
         }
     }
     return $this;
 }