protected function edit(ModelObject $Context) { parent::edit($Context); if (($existing = $this->dao->getByID($Context->ContextID)) == false) { $this->getErrors()->reject('Context not found for: ' . $Context->ContextID)->throwOnError(); } }
protected function edit(ModelObject $site) { parent::edit($site); if (($existing = $this->dao->getByID($site->SiteID)) == false) { $this->getErrors()->reject('Site not found for: ' . $site->SiteID)->throwOnError(); } }
protected function edit(ModelObject $obj) { parent::edit($obj); if (($existing = $this->dao->getByID($obj->ElementID)) == false) { $this->getErrors()->reject('Element not found for: ' . $obj->ElementID)->throwOnError(); } if ($existing->Slug != $obj->Slug) { $this->getErrors()->reject('Element slug cannot be changed.')->throwOnError(); } $roles = array(); foreach ((array) $obj->Aspects as $aspect) { foreach ($aspect->getSchema()->getTagDefs() as $id => $tagDef) { if (array_key_exists($id, $roles)) { $aspectName = $roles[$id]; $this->getErrors()->reject('Aspect [' . $aspect->Name . '] ' . $tagDef->Direction . 'bound tag definition [#' . $id . '] conflicts with the [' . $aspectName . '] aspect')->throwOnError(); } $roles[$tagDef->Id] = $aspect->Name; } foreach ($aspect->getSchema()->getMetaDefs() as $id => $metaDef) { if (array_key_exists($id, $roles)) { $aspectName = $roles[$id]; $this->getErrors()->reject('Aspect [' . $aspect->Name . '] meta definition [#' . $id . '] conflicts with the [' . $aspectName . '] aspect')->throwOnError(); } $roles[$id] = $aspect->Name; } $elementMode = $aspect->ElementMode; $dto = $this->dao->findAll(new DTO(array('IncludesAspect' => $aspect->Slug))); $hasElements = $dto->hasResults(); if ($elementMode == 'one' || $elementMode == 'anchored') { if ($hasElements && $dto->getResult()->getSlug() != $obj->getSlug()) { $this->getErrors()->reject('Aspect [' . $aspect->Name . '] cannot be used by more than one Element')->throwOnError(); } // } else if ($elementMode == 'anchored') // { // if($hasElements && $dto->getResult()->getSlug() != $obj->getSlug()) // $this->getErrors()->reject('Aspect ['.$aspect->Name.'] cannot be used by more than one Element')->throwOnError(); // else if(!$obj->isAnchored()) // $this->getErrors()->reject('Element using Aspect ['.$aspect->Name.'] must be anchored')->throwOnError(); } } }