コード例 #1
0
ファイル: NavigationApi.php プロジェクト: symbb/symbb
 /**
  * save a Navigation
  * you can pass the Navigation object or an array with the fields
  * if you pass an array the keys must be with underscore and not with CamelCase
  * @param Navigation|array $object
  * @return Navigation
  */
 public function save($object)
 {
     if (is_array($object)) {
         $objectData = $object;
         if ($object['id'] > 0) {
             $object = $this->find($object['id']);
         } else {
             $object = new Navigation();
             $site = $this->siteManager->find($objectData['site']);
             $object->setSite($site);
         }
         if (isset($objectData['site'])) {
             unset($objectData['site']);
         }
         $this->assignArrayToObject($object, $objectData);
     } else {
         if (!$object instanceof Navigation) {
             $this->addErrorMessage(self::ERROR_WRONG_OBJECT);
         }
     }
     if (!$this->hasError()) {
         $check = $this->navigationManager->save($object);
         if ($check) {
             $this->addSuccessMessage(self::SUCCESS_SAVED);
             return $object;
         }
     }
     return null;
 }
コード例 #2
0
ファイル: SiteApi.php プロジェクト: symbb/symbb
 public function find($id)
 {
     $site = $this->siteManager->find($id);
     if (!is_object($site)) {
         $this->addErrorMessage(self::ERROR_ENTRY_NOT_FOUND);
     }
     return $site;
 }