/** * * @param databox_field $field * @return databox_descriptionStructure */ public function remove_element(databox_field $field) { if (isset($this->elements[$field->get_id()])) { unset($this->elements[$field->get_id()]); } return $this; }
public function testRenameField() { $AddedValue = 'scalar value'; self::$DI['record_1']->set_metadatas([['meta_id' => null, 'meta_struct_id' => $this->object_mono->get_id(), 'value' => $AddedValue]]); $this->object_mono->set_name('Bonobo yoyo')->save(); $data = self::$DI['record_1']->get_caption()->get_field('Bonoboyoyo')->get_values(); $value = array_pop($data); $this->assertEquals($value->getValue(), $AddedValue); }
/** * Part of the cache_cacheableInterface * * @param string $option * @return string */ public function get_cache_key($option = null) { return 'caption_field_' . $this->databox_field->get_id() . '_' . $this->record->get_serialize_key() . ($option ? '_' . $option : ''); }
public static function create(Application $app, databox_field $databox_field, record_Interface $record, $value, Vocabulary\ControlProvider\ControlProviderInterface $vocabulary = null, $vocabularyId = null) { $connbas = $databox_field->get_connection(); /** * Check consistency */ if (!$databox_field->is_multi()) { try { $field = $record->get_caption()->get_field($databox_field->get_name()); $values = $field->get_values(); $caption_field_value = array_pop($values); /* @var $value \caption_Field_Value */ $caption_field_value->set_value($value); if (!$vocabulary || !$vocabularyId) { $caption_field_value->removeVocabulary(); } else { $caption_field_value->setVocab($vocabulary, $vocabularyId); } return $caption_field_value; } catch (\Exception $e) { } } $sql_ins = 'INSERT INTO metadatas (id, record_id, meta_struct_id, value, VocabularyType, VocabularyId) VALUES (null, :record_id, :field, :value, :VocabType, :VocabId)'; $params = [':record_id' => $record->get_record_id(), ':field' => $databox_field->get_id(), ':value' => $value, ':VocabType' => $vocabulary ? $vocabulary->getType() : null, ':VocabId' => $vocabulary ? $vocabularyId : null]; $stmt_ins = $connbas->prepare($sql_ins); $stmt_ins->execute($params); $stmt_ins->closeCursor(); $meta_id = $connbas->lastInsertId(); $caption_field_value = new self($app, $databox_field, $record, $meta_id); $caption_field_value->update_cache_value($value); $record->get_caption()->delete_data_from_cache(); $databox_field->delete_data_from_cache(); $caption_field_value->delete_data_from_cache(); return $caption_field_value; }
/** * {@inheritdoc} */ public function asString() { return serialize(['id' => $this->databox_field->get_id(), 'sbas_id' => $this->databox_field->get_databox()->get_sbas_id(), 'value' => $this->value]); }
/** * Retrieve informations about one \databox metadata field * * @param \databox_field $databox_field * * @return array */ private function list_databox_metadata_field_properties(\databox_field $databox_field) { return ['id' => $databox_field->get_id(), 'namespace' => $databox_field->get_tag()->getGroupName(), 'source' => $databox_field->get_tag()->getTagname(), 'tagname' => $databox_field->get_tag()->getName(), 'name' => $databox_field->get_name(), 'labels' => ['fr' => $databox_field->get_label('fr'), 'en' => $databox_field->get_label('en'), 'de' => $databox_field->get_label('de'), 'nl' => $databox_field->get_label('nl')], 'separator' => $databox_field->get_separator(), 'thesaurus_branch' => $databox_field->get_tbranch(), 'type' => $databox_field->get_type(), 'indexable' => $databox_field->is_indexable(), 'multivalue' => $databox_field->is_multi(), 'readonly' => $databox_field->is_readonly(), 'required' => $databox_field->is_required()]; }