Пример #1
0
 /**
  * @return object
  */
 public static function get($type, $name)
 {
     $name = Inflector::camelize($name);
     $registry = GummRegistry::getRegistry();
     $regKey = $type . '_' . $name;
     if (isset($registry[$regKey])) {
         return $registry[$regKey];
     }
     App::import($type, $name);
     $objName = false;
     switch (strtolower($type)) {
         case 'model':
             $objName = $name . 'Model';
             break;
         case 'controller':
             $objName = $name . 'Controller';
             break;
         case 'helper':
             $objName = $name . 'Helper';
             break;
         case 'widget':
             $objName = $name;
             break;
         case 'component':
             $objName = $name . 'Component';
             break;
         case 'editor':
             $objName = $name . 'Editor';
             break;
     }
     $obj = new $objName();
     GummRegistry::updateRegistry($regKey, $obj);
     return $obj;
 }
Пример #2
0
 public function __construct()
 {
     parent::__construct();
     if (!$this->name) {
         $this->name = str_replace('Helper', '', get_class($this));
     }
     if (isset($this->data['_mergeonsave']) && (int) $this->data['_mergeonsave'] === 0) {
         $this->mergeOnSave = false;
     }
     foreach ($this->helpers as $helper) {
         $this->{$helper} = GummRegistry::get('Helper', $helper);
     }
     GummRegistry::updateRegistry('Helper_' . $this->name, $this);
 }
Пример #3
0
 /**
  * Constructor for the GummModel class
  * Initializes the $data parameter, cleans the security fields from the $_POST variable
  * 
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     if (!$this->name) {
         $this->name = str_replace('Model', '', get_class($this));
     }
     if (isset($this->data['_mergeonsave']) && (int) $this->data['_mergeonsave'] === 0) {
         $this->mergeOnSave = false;
     }
     GummRegistry::updateRegistry('Model_' . $this->name, $this);
     foreach ($this->inRelation as $modelInRelation) {
         if (!isset($this->{$modelInRelation})) {
             $this->{$modelInRelation} = GummRegistry::get('Model', $modelInRelation);
         }
     }
 }