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(); } } } }
function control() { parent::control(); $t = explode('_', substr(get_class($this), 6)); if ('new' === end($t)) { $new = true; array_pop($t); } else { $new = false; } $this->type || ($this->type = $t); if ($this->data || $new) { return; } if (!empty($this->get->__1__)) { $t = implode('_', $this->type); $sql = "SELECT * FROM `{$t}` WHERE {$t}_id=?"; $this->data = (object) DB()->fetchAssoc($sql, array($this->get->__1__)); $this->data || patchwork::forbidden(); } else { if ($this instanceof agent_pForm_record_indexable) { $this->template = implode('/', $this->type) . '/index'; } else { patchwork::forbidden(); } } }