class Type
Same name and namespace in other branches
- 11.x core/modules/node/src/Plugin/views/argument/Type.php \Drupal\node\Plugin\views\argument\Type
- 10 core/modules/node/src/Plugin/views/argument/Type.php \Drupal\node\Plugin\views\argument\Type
- 8.9.x core/modules/node/src/Plugin/views/argument/Type.php \Drupal\node\Plugin\views\argument\Type
Argument handler to accept a node type.
Plugin annotation
@ViewsArgument("node_type");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\argument\ArgumentPluginBase implements \Drupal\Core\Cache\CacheableDependencyInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\views\Plugin\views\argument\StringArgument extends \Drupal\views\Plugin\views\argument\ArgumentPluginBase
- class \Drupal\node\Plugin\views\argument\Type extends \Drupal\views\Plugin\views\argument\StringArgument
- class \Drupal\views\Plugin\views\argument\StringArgument extends \Drupal\views\Plugin\views\argument\ArgumentPluginBase
- class \Drupal\views\Plugin\views\argument\ArgumentPluginBase implements \Drupal\Core\Cache\CacheableDependencyInterface extends \Drupal\views\Plugin\views\HandlerBase
- class \Drupal\views\Plugin\views\HandlerBase implements \Drupal\views\Plugin\views\ViewsHandlerInterface extends \Drupal\views\Plugin\views\PluginBase
- class \Drupal\views\Plugin\views\PluginBase implements \Drupal\Core\Plugin\ContainerFactoryPluginInterface, \Drupal\views\Plugin\views\ViewsPluginInterface, \Drupal\Component\Plugin\DependentPluginInterface, \Drupal\Core\Security\TrustedCallbackInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of Type
298 string references to 'Type'
- ActionAddForm::buildForm in core/
modules/ action/ src/ Form/ ActionAddForm.php - AddHandler::buildForm in core/
modules/ views_ui/ src/ Form/ Ajax/ AddHandler.php - AreaEntityTest::doTestRender in core/
modules/ views/ tests/ src/ Kernel/ Handler/ AreaEntityTest.php - Tests rendering the entity area handler.
- AreaPluginBase::buildOptionsForm in core/
modules/ views/ src/ Plugin/ views/ area/ AreaPluginBase.php - ArgumentPluginBase::defaultArgumentForm in core/
modules/ views/ src/ Plugin/ views/ argument/ ArgumentPluginBase.php - Provides a form for selecting the default argument.
File
-
core/
modules/ node/ src/ Plugin/ views/ argument/ Type.php, line 14
Namespace
Drupal\node\Plugin\views\argumentView source
class Type extends StringArgument {
/**
* NodeType storage handler.
*
* @var \Drupal\Core\Entity\EntityStorageInterface
*/
protected $nodeTypeStorage;
/**
* Constructs a new Node Type 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\EntityStorageInterface $node_type_storage
* The entity storage class.
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $node_type_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->nodeTypeStorage = $node_type_storage;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$entity_type_manager = $container->get('entity_type.manager');
return new static($configuration, $plugin_id, $plugin_definition, $entity_type_manager->getStorage('node_type'));
}
/**
* {@inheritdoc}
*/
public function summaryName($data) {
return $this->node_type($data->{$this->name_alias});
}
/**
* {@inheritdoc}
*/
public function title() {
return $this->node_type($this->argument);
}
public function node_type($type_name) {
$type = $this->nodeTypeStorage
->load($type_name);
$output = $type ? $type->label() : $this->t('Unknown content type');
return $output;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.