Ejemplo n.º 1
0
 protected function _applyDecorators($dataset)
 {
     $toolkit = lmbToolkit::instance();
     foreach ($this->decorators as $decorator_data) {
         $class_path = new lmbClassPath($decorator_data[0]);
         $dataset = $class_path->createObject(array($dataset));
         $this->_addParamsToDataset($dataset, $decorator_data[1]);
     }
     return $dataset;
 }
Ejemplo n.º 2
0
 function _createDataSet()
 {
     if (!$this->class_path) {
         throw new lmbException('Class path is not defined!');
     }
     $class_path = new lmbClassPath($this->class_path);
     $class_path->import();
     $class_name = $class_path->getClassName();
     if (is_null($this->record_id) && is_null($this->record_ids)) {
         if (!$this->find) {
             return lmbActiveRecord::find($class_name);
         } else {
             $method = 'find' . lmb_camel_case($this->find);
             $callback = array($class_name, $method);
             if (!is_callable($callback)) {
                 throw new lmbException('Active record of class "' . $class_name . '" does not support method "' . $method . '"');
             }
             return call_user_func_array($callback, $this->find_params);
         }
     }
     if ($this->record_id) {
         try {
             if ($this->find) {
                 $method = 'find' . lmb_camel_case($this->find);
                 $callback = array($class_name, $method);
                 if (!is_callable($callback)) {
                     throw new lmbException('Active record of class "' . $class_name . '" does not support method "' . $method . '"');
                 }
                 $record = call_user_func_array($callback, array($this->record_id));
             } else {
                 $record = lmbActiveRecord::findById($class_name, $this->record_id);
             }
         } catch (lmbARNotFoundException $e) {
             $record = array();
         }
         return $this->_singleItemCollection($record);
     } elseif ($this->record_ids) {
         return lmbActiveRecord::findByIds($class_name, $this->record_ids);
     }
     return new lmbCollection();
 }
Ejemplo n.º 3
0
 protected function _createTableObjectByAlias($class_path_alias)
 {
     $class_path = new lmbClassPath($class_path_alias);
     return $class_path->createObject();
 }
Ejemplo n.º 4
0
 static function create($path, $args = array())
 {
     $class_path = new lmbClassPath($path);
     return $class_path->createObject($args);
 }
Ejemplo n.º 5
0
 function testExpandConstants()
 {
     file_put_contents(LIMB_VAR_DIR . '/FooBarZooTest2.class.php', "<?php\n class FooBarZooTest2{}\n ?>");
     $class_path = new lmbClassPath('{LIMB_VAR_DIR}/FooBarZooTest2');
     $this->assertEqual(get_class($class_path->createObject()), 'FooBarZooTest2');
     unlink(LIMB_VAR_DIR . '/FooBarZooTest2.class.php');
 }