Beispiel #1
0
 protected function retrieveValues()
 {
     try {
         $datas = $this->get_data_from_cache();
         $this->value = $datas['value'];
         $this->VocabularyType = $datas['vocabularyType'] ? Vocabulary\Controller::get($this->app, $datas['vocabularyType']) : null;
         $this->VocabularyId = $datas['vocabularyId'];
         return $this;
     } catch (\Exception $e) {
     }
     $connbas = $this->databox_field->get_databox()->get_connection();
     $sql = 'SELECT record_id, value, VocabularyType, VocabularyId
         FROM metadatas WHERE id = :id';
     $stmt = $connbas->prepare($sql);
     $stmt->execute([':id' => $this->id]);
     $row = $stmt->fetch(PDO::FETCH_ASSOC);
     $stmt->closeCursor();
     $this->value = $row ? $row['value'] : null;
     try {
         $this->VocabularyType = $row['VocabularyType'] ? Vocabulary\Controller::get($this->app, $row['VocabularyType']) : null;
         $this->VocabularyId = $row['VocabularyId'];
     } catch (\InvalidArgumentException $e) {
     }
     if ($this->VocabularyType) {
         /**
          * Vocabulary Control has been deactivated
          */
         if (!$this->databox_field->getVocabularyControl()) {
             $this->removeVocabulary();
         } elseif ($this->databox_field->getVocabularyControl()->getType() !== $this->VocabularyType->getType()) {
             $this->removeVocabulary();
         } elseif (!$this->VocabularyType->validate($this->VocabularyId)) {
             $this->removeVocabulary();
         } elseif ($this->VocabularyType->getValue($this->VocabularyId) !== $this->value) {
             $this->set_value($this->VocabularyType->getValue($this->VocabularyId));
         }
     }
     $datas = ['value' => $this->value, 'vocabularyId' => $this->VocabularyId, 'vocabularyType' => $this->VocabularyType ? $this->VocabularyType->getType() : null];
     $this->set_data_to_cache($datas);
     return $this;
 }