You are here

protected function ValidFacebookInstantArticles::enabledNodeBundlesSetValues in Facebook Instant Articles 8.2

Same name and namespace in other branches
  1. 3.x modules/fb_instant_articles_views/src/Plugin/views/filter/ValidFacebookInstantArticles.php \Drupal\fb_instant_articles_views\Plugin\views\filter\ValidFacebookInstantArticles::enabledNodeBundlesSetValues()

Set the values for this filter.

This applies to all node bundles that implement custom settings for the fb_instant_articles view mode.

1 call to ValidFacebookInstantArticles::enabledNodeBundlesSetValues()
ValidFacebookInstantArticles::query in modules/fb_instant_articles_views/src/Plugin/views/filter/ValidFacebookInstantArticles.php
Add this filter to the query.

File

modules/fb_instant_articles_views/src/Plugin/views/filter/ValidFacebookInstantArticles.php, line 130

Class

ValidFacebookInstantArticles
Simple filter that checks if a node implements the FIA custom view mode.

Namespace

Drupal\fb_instant_articles_views\Plugin\views\filter

Code

protected function enabledNodeBundlesSetValues() {
  $entity_storage = $this->entityTypeManager
    ->getStorage('entity_view_display');
  $node_types = [];
  foreach ($this->entityTypeBundleInfo
    ->getBundleInfo('node') as $id => $bundle) {
    $view_mode_id = 'node.' . $id . '.' . EntityViewDisplayEditForm::FBIA_VIEW_MODE;
    $view_mode = $entity_storage
      ->load($view_mode_id);
    if ($view_mode instanceof EntityViewDisplayInterface && $view_mode
      ->status()) {
      $node_types[$id] = $id;
    }
  }
  if (count($node_types) > 0) {
    $this->value = $node_types;
    $this->operator = 'IN';
  }
}