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();
     }
 }
예제 #2
0
 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();
     }
 }
 /**
  * Prevent deleting items that have children
  *
  * @param string $slug The slug of the item to remove
  *
  * @return void
  */
 public function delete($slug)
 {
     parent::delete($slug);
     // Children are just orphaned.
     // $item = $this->dao->getBySlug($slug);
     // if ($item) {
     //     // Look up items by parent slug
     //     $dto = new DTO();
     //     $dto->setParameter('ParentSlug', $slug);
     //     $dto_result = $this->dao->findAll($dto);
     //
     //     if (count($dto_result->getResults()) > 0)
     //         $this->getErrors()->reject('Cannot delete CMSNavItem that has child items!');
     // }
 }
 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();
         }
     }
 }
 /**
  * Creates the Validator
  *
  * @param DAOInterface $AspectDAO AspectDAO
  */
 public function __construct(DAOInterface $AspectDAO)
 {
     parent::__construct($AspectDAO);
 }
 /**
  * [IoC] Creates the PluginValidator
  *
  * @param DAOInterface $PluginDAO PluginDAO
  */
 public function __construct(DAOInterface $PluginDAO)
 {
     parent::__construct($PluginDAO);
 }