コード例 #1
0
 function control()
 {
     parent::control();
     if ($this->entity) {
         return;
     }
     $u = empty($this->entityUrl) ? explode('_', substr(get_class($this), 6)) : explode('/', $this->entityUrl);
     if ('new' === end($u)) {
         $this->entityIsNew = true;
         array_pop($u);
     }
     $this->entityUrl = implode('/', $u);
     $this->entityClass = self::$entityNs . "\\";
     foreach ($u as $u) {
         $this->entityClass .= ucfirst($u);
         //TODO: Ugly
     }
     if ($this->entityIsNew) {
         $this->entity = new $this->entityClass();
     } else {
         if (!empty($this->get->__1__)) {
             // Use this to manage composite primary keys
             $id = !empty($this->entityIdentifier) ? $this->entityIdentifier : $this->get->__1__;
             $this->entity = EM()->find($this->entityClass, $id);
             $this->entity || Patchwork::forbidden();
         } else {
             if ($this instanceof agent_pForm_entity_indexable) {
                 $this->template = $this->entityUrl . '/index';
             } else {
                 Patchwork::forbidden();
             }
         }
     }
 }