Ejemplo n.º 1
0
 public function testSet_dces_element()
 {
     $this->object_mono->set_dces_element(new \databox_Field_DCES_Contributor());
     $this->object_multi->set_dces_element(new \databox_Field_DCES_Format());
     $this->assertInstanceOf('\\databox_Field_DCESAbstract', $this->object_mono->get_dces_element());
     $this->assertInstanceOf('\\databox_Field_DCESAbstract', $this->object_multi->get_dces_element());
     $this->object_multi->set_dces_element(null);
     $this->assertNull($this->object_multi->get_dces_element());
 }
Ejemplo n.º 2
0
 private function updateFieldWithData(Application $app, \databox_field $field, array $data)
 {
     $field->set_name($data['name'])->set_thumbtitle($data['thumbtitle'])->set_tag(\databox_field::loadClassFromTagName($data['tag']))->set_business($data['business'])->set_aggregable($data['aggregable'])->set_indexable($data['indexable'])->set_required($data['required'])->set_separator($data['separator'])->set_readonly($data['readonly'])->set_type($data['type'])->set_tbranch($data['tbranch'])->set_report($data['report'])->setVocabularyControl(null)->setVocabularyRestricted(false);
     foreach ($data['labels'] as $code => $label) {
         $field->set_label($code, $label);
     }
     if (isset($data['sorter'])) {
         $field->set_position($data['sorter']);
     }
     try {
         $vocabulary = VocabularyController::get($app, $data['vocabulary-type']);
         $field->setVocabularyControl($vocabulary);
         $field->setVocabularyRestricted($data['vocabulary-restricted']);
     } catch (\InvalidArgumentException $e) {
     }
     if ('' !== ($dcesElement = (string) $data['dces-element'])) {
         $class = sprintf('\\databox_Field_DCES_%s', $dcesElement);
         if (!class_exists($class)) {
             throw new BadRequestHttpException(sprintf('DCES element %s does not exist.', $dcesElement));
         }
         $field->set_dces_element(new $class());
     }
 }