ParserBase.php in Feeds 8.3
File
src/Feeds/Parser/ParserBase.php
View source
<?php
namespace Drupal\feeds\Feeds\Parser;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Render\Element;
use Drupal\feeds\Plugin\Type\MappingPluginFormInterface;
use Drupal\feeds\Plugin\Type\Parser\ParserInterface;
use Drupal\feeds\Plugin\Type\PluginBase;
abstract class ParserBase extends PluginBase implements ParserInterface, MappingPluginFormInterface {
protected function configSourceLabel() {
return NULL;
}
protected function configSourceDescription() {
return NULL;
}
public function mappingFormAlter(array &$form, FormStateInterface $form_state) {
$source_label = $this
->configSourceLabel();
$description = $this
->configSourceDescription();
if ($source_label || $description) {
foreach (Element::children($form['mappings']) as $i) {
if (!isset($form['mappings'][$i]['map'])) {
continue;
}
foreach (Element::children($form['mappings'][$i]['map']) as $subtarget) {
if ($source_label) {
$form['mappings'][$i]['map'][$subtarget]['select']['#options']['__new'] = $this
->t('New @label...', [
'@label' => $source_label,
]);
}
if ($description) {
$form['mappings'][$i]['map'][$subtarget]['__new']['value']['#description'] = $description;
}
}
}
}
}
public function mappingFormValidate(array &$form, FormStateInterface $form_state) {
}
public function mappingFormSubmit(array &$form, FormStateInterface $form_state) {
}
}