Version 1
[yaffs-website] / web / core / modules / system / tests / modules / entity_test / src / EntityTestViewsData.php
diff --git a/web/core/modules/system/tests/modules/entity_test/src/EntityTestViewsData.php b/web/core/modules/system/tests/modules/entity_test/src/EntityTestViewsData.php
new file mode 100644 (file)
index 0000000..3bb0d24
--- /dev/null
@@ -0,0 +1,28 @@
+<?php
+
+namespace Drupal\entity_test;
+
+use Drupal\Component\Utility\NestedArray;
+use Drupal\views\EntityViewsData;
+
+/**
+ * Provides a view to override views data for test entity types.
+ */
+class EntityTestViewsData extends EntityViewsData {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function getViewsData() {
+    $views_data = parent::getViewsData();
+
+    if ($this->entityType->id() != 'entity_test') {
+      return $views_data;
+    }
+
+    $views_data = NestedArray::mergeDeep($views_data, \Drupal::state()->get('entity_test.views_data', []));
+
+    return $views_data;
+  }
+
+}