abstract class RssPluginBase in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/src/Plugin/views/row/RssPluginBase.php \Drupal\views\Plugin\views\row\RssPluginBase
- 9 core/modules/views/src/Plugin/views/row/RssPluginBase.php \Drupal\views\Plugin\views\row\RssPluginBase
Base class for Views RSS row plugins.
Hierarchy
- class \Drupal\views\Plugin\views\row\RssPluginBase extends \Drupal\views\Plugin\views\row\RowPluginBase
Expanded class hierarchy of RssPluginBase
File
- core/
modules/ views/ src/ Plugin/ views/ row/ RssPluginBase.php, line 13
Namespace
Drupal\views\Plugin\views\rowView source
abstract class RssPluginBase extends RowPluginBase {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The entity display repository.
*
* @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface
*/
protected $entityDisplayRepository;
/**
* Constructs a RssPluginBase object.
*
* @param array $configuration
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository
* The entity display repository.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entity_type_manager, EntityDisplayRepositoryInterface $entity_display_repository) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->entityTypeManager = $entity_type_manager;
$this->entityDisplayRepository = $entity_display_repository;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('entity_type.manager'), $container
->get('entity_display.repository'));
}
/**
* The ID of the entity type for which this is an RSS row plugin.
*
* @var string
*/
protected $entityTypeId;
/**
* {@inheritdoc}
*/
protected function defineOptions() {
$options = parent::defineOptions();
$options['view_mode'] = [
'default' => 'default',
];
return $options;
}
/**
* {@inheritdoc}
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['view_mode'] = [
'#type' => 'select',
'#title' => $this
->t('Display type'),
'#options' => $this
->buildOptionsForm_summary_options(),
'#default_value' => $this->options['view_mode'],
];
}
/**
* Return the main options, which are shown in the summary title.
*/
public function buildOptionsForm_summary_options() {
$view_modes = $this->entityDisplayRepository
->getViewModes($this->entityTypeId);
$options = [];
foreach ($view_modes as $mode => $settings) {
$options[$mode] = $settings['label'];
}
return $options;
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
$dependencies = parent::calculateDependencies();
$view_mode = $this->entityTypeManager
->getStorage('entity_view_mode')
->load($this->entityTypeId . '.' . $this->options['view_mode']);
if ($view_mode) {
$dependencies[$view_mode
->getConfigDependencyKey()][] = $view_mode
->getConfigDependencyName();
}
return $dependencies;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RssPluginBase:: |
protected | property | The entity display repository. | |
RssPluginBase:: |
protected | property | The ID of the entity type for which this is an RSS row plugin. | |
RssPluginBase:: |
protected | property | The entity type manager. | |
RssPluginBase:: |
public | function | ||
RssPluginBase:: |
public | function | Return the main options, which are shown in the summary title. | |
RssPluginBase:: |
public | function | ||
RssPluginBase:: |
public static | function | ||
RssPluginBase:: |
protected | function | ||
RssPluginBase:: |
public | function | Constructs a RssPluginBase object. |