Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

[SDPAP-7925]add config files #34

Merged
merged 18 commits into from
Sep 14, 2023
Merged
Prev Previous commit
Next Next commit
removed const
  • Loading branch information
yeniatencio committed Sep 4, 2023
commit 307b1187a9b7cc2e2a470f4c7e10da03665e18df
25 changes: 0 additions & 25 deletions src/TidePublicationOperation.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,6 @@
*/
class TidePublicationOperation {

/**
* The bundle name.
*/
const BUNDLE = 'publication';

/**
* The entity reference field type.
*/
const ENTITY_REFERENCE_FIELD_TYPE = 'entity_reference';

/**
* The publication authors field name.
*/
const PUBLICATION_AUTHORS_FIELD_NAME = 'field_publication_authors';

/**
* The publication authors field description.
*/
const PUBLICATION_AUTHORS_FIELD_DESCRIPTION = 'Start typing to choose one publication author.';

/**
* The publication authors field storage.
*/
const PUBLICATION_AUTHORS_FIELD_STORAGE = 'field.storage.node.field_publication_authors';

/**
* Creates a new vocabulary.
*
Expand Down
12 changes: 6 additions & 6 deletions tide_publication.install
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ function tide_publication_update_8016() {
$tidePublicationOperation = new TidePublicationOperation();
$vocabulary = 'organisation';
$config_factory = \Drupal::configFactory();
$config = $config_factory->getEditable($tidePublicationOperation::PUBLICATION_AUTHORS_FIELD_STORAGE);
$config = $config_factory->getEditable('field.storage.node.field_publication_authors');
$config->set('cardinality', 1);
$config->save();

Expand All @@ -1076,15 +1076,15 @@ function tide_publication_update_8016() {
$tidePublicationOperation->createVocabulary($vocabulary);
}

$field = FieldConfig::loadByName('node', $tidePublicationOperation::BUNDLE, $tidePublicationOperation::PUBLICATION_AUTHORS_FIELD_NAME);
if ($field->get('field_type') === $tidePublicationOperation::ENTITY_REFERENCE_FIELD_TYPE) {
$field = FieldConfig::loadByName('node', $tidePublicationOperation::'publication', $tidePublicationOperation::'field_publication_authors');
if ($field->get('field_type') === $tidePublicationOperation::'entity_reference') {
$new_field = $field->toArray();
$new_field['field_type'] = $tidePublicationOperation::ENTITY_REFERENCE_FIELD_TYPE;
$new_field['description'] = $tidePublicationOperation::PUBLICATION_AUTHORS_FIELD_DESCRIPTION;
$new_field['field_type'] = $tidePublicationOperation::'entity_reference';
$new_field['description'] = $tidePublicationOperation::'Start typing to choose one publication author.';
$new_field['dependencies'] = [
'config' => [
'field.storage.' . $config->get('id'),
'node.type.' . $tidePublicationOperation::BUNDLE,
'node.type.' . $tidePublicationOperation::'publication',
'taxonomy.vocabulary.' . $vocabulary,
],
];
Expand Down