X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fsrc%2FFeeds%2FTarget%2FParagraphs.php;fp=web%2Fmodules%2Fcontrib%2Fparagraphs%2Fsrc%2FFeeds%2FTarget%2FParagraphs.php;h=0000000000000000000000000000000000000000;hp=b71cd84ead3cd425258c8e2ae88bcc5a8a8d29eb;hb=059867c3f96750652c80f39e44c442a58c2549ee;hpb=f8fc16ae6b862bef59baaad5d051dd37b7ff11b2 diff --git a/web/modules/contrib/paragraphs/src/Feeds/Target/Paragraphs.php b/web/modules/contrib/paragraphs/src/Feeds/Target/Paragraphs.php deleted file mode 100644 index b71cd84ea..000000000 --- a/web/modules/contrib/paragraphs/src/Feeds/Target/Paragraphs.php +++ /dev/null @@ -1,133 +0,0 @@ -paragraphStorage = $entity_type_manager->getStorage('paragraph'); - $this->paragraphsTypeStorage = $entity_type_manager->getStorage('paragraphs_type'); - $this->fieldConfigStorage = $entity_type_manager->getStorage('field_config'); - } - - /** - * {@inheritdoc} - */ - public function defaultConfiguration() { - return parent::defaultConfiguration() + [ - 'paragraphs_type' => NULL, - 'paragraph_field' => NULL, - ]; - } - - /** - * {@inheritdoc} - */ - public function buildConfigurationForm(array $form, FormStateInterface $form_state) { - $form['paragraphs_type'] = [ - '#type' => 'select', - '#title' => $this->t('Paragraphs type'), - '#required' => TRUE, - '#options' => array_map(function(EntityInterface $paragraphs_type) { - return $paragraphs_type->label(); - }, $this->paragraphsTypeStorage->loadMultiple()), - '#default_value' => $this->configuration['paragraphs_type'], - ]; - - // Load and filter field configs to create options. - /** @var \Drupal\field\FieldConfigInterface[] $field_configs */ - $field_configs = $this->fieldConfigStorage->loadByProperties([ - 'entity_type' => 'paragraph', - 'bundle' => $this->configuration['paragraphs_type'], - ]); - $field_options = []; - foreach ($field_configs as $field_config) { - if (in_array($field_config->getType(), ['text', 'text_long', 'text_with_summary'])) { - $field_options[$field_config->getName()] = $field_config->label(); - } - } - - $form['paragraph_field'] = [ - '#type' => 'select', - '#title' => $this->t('Paragraph field'), - '#description' => $this->t('Note: Field options do not appear until a type has been chosen and saved.'), - '#options' => $field_options, - ]; - - $form = parent::buildConfigurationForm($form, $form_state); - - return $form; - } - - /** - * {@inheritdoc} - */ - public function getSummary() { - $summary = $this->t('Not yet configured.'); - $paragraphs_type_id = $this->configuration['paragraphs_type']; - $paragraph_field_name = $this->configuration['paragraph_field']; - if ($paragraphs_type_id && $paragraphs_type = $this->paragraphsTypeStorage->load($paragraphs_type_id)) { - if ($paragraph_field_name && $paragraph_field = $this->fieldConfigStorage->load('paragraph.' . $paragraphs_type_id . '.' . $paragraph_field_name)) { - $summary = $this->t('Using the %field field on a %type paragraph.', [ - '%field' => $paragraph_field->label(), - '%type' => $paragraphs_type->label(), - ]); - } - } - return $summary . '
' . parent::getSummary(); - } - - /** - * {@inheritdoc} - */ - protected function prepareValue($delta, array &$values) { - parent::prepareValue($delta, $values); - $paragraph = $this->paragraphStorage->create([ - 'type' => $this->configuration['paragraphs_type'], - $this->configuration['paragraph_field'] => $values, - ]); - $values = ['entity' => $paragraph]; - } - -}