factory() публичный статический Метод

public static factory ( $type, $name, $documentId, null $config = null, null $controller = null, null $view = null, null $editmode = null ) : mixed
$type
$name
$documentId
$config null
$controller null
$view null
$editmode null
Результат mixed
Пример #1
0
 /**
  * @param $type
  * @param $realName
  * @param array $options
  * @return Model\Document\Tag
  */
 public function tag($type, $realName, $options = array())
 {
     $type = strtolower($type);
     $document = $this->document;
     $name = Model\Document\Tag::buildTagName($type, $realName, $document);
     try {
         if ($document instanceof Model\Document\PageSnippet) {
             $tag = $document->getElement($name);
             if ($tag instanceof Model\Document\Tag && $tag->getType() == $type) {
                 // call the load() method if it exists to reinitialize the data (eg. from serializing, ...)
                 if (method_exists($tag, "load")) {
                     $tag->load();
                 }
                 // set view & controller, editmode
                 $tag->setController($this->controller);
                 $tag->setView($this);
                 $tag->setEditmode($this->editmode);
                 $tag->setOptions($options);
             } else {
                 $tag = Model\Document\Tag::factory($type, $name, $document->getId(), $options, $this->controller, $this, $this->editmode);
                 $document->setElement($name, $tag);
             }
             // set the real name of this editable, without the prefixes and suffixes from blocks and areablocks
             $tag->setRealName($realName);
         }
         return $tag;
     } catch (\Exception $e) {
         \Logger::warning($e);
     }
 }
 /**
  * @param $object
  * @param bool $disableMappingExceptions
  * @param null $idMapper
  * @throws \Exception
  */
 public function reverseMap($object, $disableMappingExceptions = false, $idMapper = null)
 {
     parent::reverseMap($object, $disableMappingExceptions, $idMapper);
     $object->childs = null;
     $object->elements = array();
     if (is_array($this->elements)) {
         foreach ($this->elements as $element) {
             $tag = Model\Document\Tag::factory($element->type, $element->name, $this->id);
             $tag->getFromWebserviceImport($element, $idMapper);
             $object->elements[$element->name] = $tag;
         }
     }
 }
Пример #3
0
 /**
  * @return bool
  */
 public function checkValidity()
 {
     $sane = true;
     if (is_array($this->data) && $this->data["internal"]) {
         if ($this->data["internalType"] == "document") {
             $doc = Document::getById($this->data["internalId"]);
             if (!$doc) {
                 $sane = false;
                 \Logger::notice("Detected insane relation, removing reference to non existent document with id [" . $this->getDocumentId() . "]");
                 $new = Document\Tag::factory($this->getType(), $this->getName(), $this->getDocumentId());
                 $this->data = $new->getData();
             }
         } elseif ($this->data["internalType"] == "asset") {
             $asset = Asset::getById($this->data["internalId"]);
             if (!$asset) {
                 $sane = false;
                 \Logger::notice("Detected insane relation, removing reference to non existent asset with id [" . $this->getDocumentId() . "]");
                 $new = Document\Tag::factory($this->getType(), $this->getName(), $this->getDocumentId());
                 $this->data = $new->getData();
             }
         }
     }
     return $sane;
 }