Loading eva.info.yml +1 −2 Original line number Diff line number Diff line name: Eva description: Provides a Views display type that can be attached to entities. core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^8 || ^9 || ^10 type: module package: Views dependencies: Loading eva.module +3 −4 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Module implementing EVA extra field and views display. */ use Drupal\views\ViewEntityInterface; use Drupal\views\Views; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; Loading Loading @@ -59,9 +60,6 @@ function eva_entity_view(array &$build, EntityInterface $entity, EntityViewDispl $view->setDisplay($info['display']); if ((empty($info['bundles']) || in_array($display->getTargetBundle(), $info['bundles'])) && $view->access($info['display'])) { // Save the entity for path calculation. $view->current_entity = $entity; // Gather info about the attached-to entity. $entity_type = $view->display_handler->getOption('entity_type'); $arg_mode = $view->display_handler->getOption('argument_mode'); Loading Loading @@ -98,6 +96,7 @@ function eva_entity_view(array &$build, EntityInterface $entity, EntityViewDispl // Now that arguments are set, build the exposed form. if ($info['uses exposed'] && $display->getComponent($longname . '_form')) { $view->initHandlers(); /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form */ $exposed_form = $view->display_handler->getPlugin('exposed_form'); $build[$longname . '_form'] = $exposed_form->renderExposedForm(TRUE); } Loading Loading @@ -134,7 +133,7 @@ function eva_modules_disabled($modules) { * Address https://www.drupal.org/node/2922112: if Eva displays are removed, * remove the module dependency from the View. */ function eva_view_presave(EntityInterface $view) { function eva_view_presave(ViewEntityInterface $view) { $dependencies = $view->get('dependencies'); if (in_array('eva', $dependencies['module'] ?? [])) { $eva_count = 0; Loading src/Plugin/views/display/Eva.php +6 −8 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class Eva extends DisplayPluginBase { * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entityTypeManager, EntityTypeBundleInfoInterface $bundleInfo, CurrentPathStack $currentPathStack, ViewDisplays $evaViewDisplays) { parent::__construct([], $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition); $this->entityTypeManager = $entityTypeManager; $this->bundleInfo = $bundleInfo; $this->currentPathStack = $currentPathStack; Loading Loading @@ -183,7 +183,7 @@ class Eva extends DisplayPluginBase { '#required' => TRUE, '#validated' => TRUE, '#title' => $this->t('Attach this display to the following entity type'), '#options' => $entity_names, '#options' => $entity_names ?? [], '#default_value' => $this->getOption('entity_type'), ]; break; Loading Loading @@ -240,11 +240,9 @@ class Eva extends DisplayPluginBase { if (\Drupal::service('module_handler')->moduleExists('token')) { $token_types = [$entity_type => $entity_type]; $token_mapper = \Drupal::service('token.entity_mapper'); if (!empty($token_types)) { $token_types = array_map(function ($type) use ($token_mapper) { return $token_mapper->getTokenTypeForEntityType($type); }, (array) $token_types); } $form['token']['browser'] = [ '#theme' => 'token_tree_link', '#token_types' => $token_types, Loading Loading @@ -354,8 +352,8 @@ class Eva extends DisplayPluginBase { /** @var \Drupal\Core\Entity\EntityInterface $current_entity */ $current_entity = $this->view->current_entity; /** @var \Drupal\Core\Url $uri */ if ($current_entity->hasLinkTemplate('canonical')) { /** @var \Drupal\Core\Url $uri */ $uri = $current_entity->toUrl('canonical'); if ($uri) { $uri->setAbsolute(TRUE); Loading src/ViewDisplays.php +3 −3 Original line number Diff line number Diff line Loading @@ -15,21 +15,21 @@ class ViewDisplays { /** * The default cache bin. * * @var Drupal\Core\Cache\CacheBackendInterface * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $defaultCache; /** * The render cache bin. * * @var Drupal\Core\Cache\CacheBackendInterface * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $renderCache; /** * Handle module configuration. * * @var [rupal\Core\Config\ConfigFactoryInterface * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; Loading tests/eva_test/eva_test.info.yml +0 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ name: Eva test type: module description: Support module for testing. package: Testing core: 8.x core_version_requirement: ^8 || ^9 dependencies: - drupal:eva - drupal:node Loading Loading
eva.info.yml +1 −2 Original line number Diff line number Diff line name: Eva description: Provides a Views display type that can be attached to entities. core: 8.x core_version_requirement: ^8 || ^9 core_version_requirement: ^8 || ^9 || ^10 type: module package: Views dependencies: Loading
eva.module +3 −4 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ * Module implementing EVA extra field and views display. */ use Drupal\views\ViewEntityInterface; use Drupal\views\Views; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\Display\EntityViewDisplayInterface; Loading Loading @@ -59,9 +60,6 @@ function eva_entity_view(array &$build, EntityInterface $entity, EntityViewDispl $view->setDisplay($info['display']); if ((empty($info['bundles']) || in_array($display->getTargetBundle(), $info['bundles'])) && $view->access($info['display'])) { // Save the entity for path calculation. $view->current_entity = $entity; // Gather info about the attached-to entity. $entity_type = $view->display_handler->getOption('entity_type'); $arg_mode = $view->display_handler->getOption('argument_mode'); Loading Loading @@ -98,6 +96,7 @@ function eva_entity_view(array &$build, EntityInterface $entity, EntityViewDispl // Now that arguments are set, build the exposed form. if ($info['uses exposed'] && $display->getComponent($longname . '_form')) { $view->initHandlers(); /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form */ $exposed_form = $view->display_handler->getPlugin('exposed_form'); $build[$longname . '_form'] = $exposed_form->renderExposedForm(TRUE); } Loading Loading @@ -134,7 +133,7 @@ function eva_modules_disabled($modules) { * Address https://www.drupal.org/node/2922112: if Eva displays are removed, * remove the module dependency from the View. */ function eva_view_presave(EntityInterface $view) { function eva_view_presave(ViewEntityInterface $view) { $dependencies = $view->get('dependencies'); if (in_array('eva', $dependencies['module'] ?? [])) { $eva_count = 0; Loading
src/Plugin/views/display/Eva.php +6 −8 Original line number Diff line number Diff line Loading @@ -69,7 +69,7 @@ class Eva extends DisplayPluginBase { * {@inheritdoc} */ public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityTypeManagerInterface $entityTypeManager, EntityTypeBundleInfoInterface $bundleInfo, CurrentPathStack $currentPathStack, ViewDisplays $evaViewDisplays) { parent::__construct([], $plugin_id, $plugin_definition); parent::__construct($configuration, $plugin_id, $plugin_definition); $this->entityTypeManager = $entityTypeManager; $this->bundleInfo = $bundleInfo; $this->currentPathStack = $currentPathStack; Loading Loading @@ -183,7 +183,7 @@ class Eva extends DisplayPluginBase { '#required' => TRUE, '#validated' => TRUE, '#title' => $this->t('Attach this display to the following entity type'), '#options' => $entity_names, '#options' => $entity_names ?? [], '#default_value' => $this->getOption('entity_type'), ]; break; Loading Loading @@ -240,11 +240,9 @@ class Eva extends DisplayPluginBase { if (\Drupal::service('module_handler')->moduleExists('token')) { $token_types = [$entity_type => $entity_type]; $token_mapper = \Drupal::service('token.entity_mapper'); if (!empty($token_types)) { $token_types = array_map(function ($type) use ($token_mapper) { return $token_mapper->getTokenTypeForEntityType($type); }, (array) $token_types); } $form['token']['browser'] = [ '#theme' => 'token_tree_link', '#token_types' => $token_types, Loading Loading @@ -354,8 +352,8 @@ class Eva extends DisplayPluginBase { /** @var \Drupal\Core\Entity\EntityInterface $current_entity */ $current_entity = $this->view->current_entity; /** @var \Drupal\Core\Url $uri */ if ($current_entity->hasLinkTemplate('canonical')) { /** @var \Drupal\Core\Url $uri */ $uri = $current_entity->toUrl('canonical'); if ($uri) { $uri->setAbsolute(TRUE); Loading
src/ViewDisplays.php +3 −3 Original line number Diff line number Diff line Loading @@ -15,21 +15,21 @@ class ViewDisplays { /** * The default cache bin. * * @var Drupal\Core\Cache\CacheBackendInterface * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $defaultCache; /** * The render cache bin. * * @var Drupal\Core\Cache\CacheBackendInterface * @var \Drupal\Core\Cache\CacheBackendInterface */ protected $renderCache; /** * Handle module configuration. * * @var [rupal\Core\Config\ConfigFactoryInterface * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; Loading
tests/eva_test/eva_test.info.yml +0 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,6 @@ name: Eva test type: module description: Support module for testing. package: Testing core: 8.x core_version_requirement: ^8 || ^9 dependencies: - drupal:eva - drupal:node Loading