In D7 we have an entity type filter handler that we can use for bundle filtering, Let's port that to D8. Then nodes/taxonomy etc... can just use this and we can remove any others.

Comments

damiankloip’s picture

Issue tags: +Needs tests

Probably needs tests too.

dawehner’s picture

Issue tags: -Needs tests

There are just nitpicks:

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/EntityType.phpundefined
@@ -0,0 +1,85 @@
+ * Definition of views_handler_filter_entity_bundle

ups :)

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/EntityType.phpundefined
@@ -0,0 +1,85 @@
+  public $entityType;
...
+  public $entityInfo;

This should be better protected

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/EntityType.phpundefined
@@ -0,0 +1,85 @@
+    // Set the entity type from the definition data, if it's there.
+    if (isset($this->definition['entity_type'])) {
+      $this->entityType = $this->definition['entity_type'];
+    }

Should we just ignore it, if it's not needed/used here?

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/EntityType.phpundefined
@@ -0,0 +1,85 @@
+        $options[$type] = t($info['label']);

Isn't the label already runned through t()?

+++ b/core/modules/views/lib/Drupal/views/Plugin/views/filter/EntityType.phpundefined
@@ -0,0 +1,85 @@
+    $this->ensureMyTable();

A comment might be helpful.

Status: Needs review » Needs work

The last submitted patch, vdc.entity-type-filter.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new2.13 KB
new5.18 KB

Thanks for the review! Here are those changes, see interdiff.

damiankloip’s picture

StatusFileSize
new5.17 KB

Sorry, complete fail on the protected properties, here we go.

Status: Needs review » Needs work

The last submitted patch, 1891214-4.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new704 bytes
new5.17 KB
dawehner’s picture

Issue tags: +Needs tests

Ups

damiankloip’s picture

StatusFileSize
new14.15 KB

Here are some tests too, I have also modified entity_test module to use a bundle too.

Status: Needs review » Needs work

The last submitted patch, d8.entity-type-filter-with-tests.patch, failed testing.

damiankloip’s picture

Assigned: Unassigned » damiankloip

Need to fix the other tests that rely on entity_test module.

dawehner’s picture

+++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/Plugin/Core/Entity/EntityTest.phpundefined
@@ -64,6 +73,13 @@ class EntityTest extends EntityNG {
+   * The bundle type.

You might be able to improve that comment.

Additional isn't the type a scalar value, like "test_1" aka. a string?

+++ b/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityTest.phpundefined
@@ -0,0 +1,99 @@
+class FilterEntityTest extends ViewTestBase {

I'm wondering whether we could use unit tests for that.

+++ b/core/modules/views/lib/Drupal/views/Tests/Entity/FilterEntityTest.phpundefined
@@ -0,0 +1,99 @@
+   * @todo.

He, at least that's honest :)

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new10.84 KB

I have re worked this to use node instead for now. Adding a bundle to entity_test module requires quite alot of work with alot of tests having to be changed.

Here is the handler with tests using node as the base table, and some custom bundles. I think this means we can't use unittests too, which is a shame.

What do you think?

dawehner’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs tests

Let's get that in, we have tests.

We can always try to rework existing tests to use DrupalUnitTests

chx’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs tests

Why are you calling the bundle filter entity type filter? You are not filtering on entity type (that wouldn't make any sense!)

chx’s picture

Status: Needs review » Needs work
Issue tags: -Needs tests

Sorry x-post but also , IMO this is CNW.

damiankloip’s picture

Status: Needs work » Needs review
StatusFileSize
new1.89 KB
new10.77 KB

Yep, fair comments. I have changed the filter class to Bundle, and also the test class to FilterEntityBundleTest.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

Noone knows yet what will happen if we have proper typed data support in views, but for now this looks really good!

dawehner’s picture

Title: Introduce a generic entity type filter handler » Introduce a generic entity bundle filter handler

Fix title

chx’s picture

That's great.( I almost got a heart attack from the earlier title thinking Views invented some super base that can be filtered on entity type. Phew.)

damiankloip’s picture

AHAHA :) Sorry about that...

dawehner’s picture

So that's what people always wanted to have: support for UNION.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Looks great. I had to write one of these in Drupal 7 for a custom entity type and couldn't believe it didn't exist there. Committed/pushed to 8.x.

damiankloip’s picture

Super.

tim.plunkett’s picture

Title: Introduce a generic entity bundle filter handler » HEAD BROKEN: Introduce a generic entity bundle filter handler

This was never retested after #1822458: Move dynamic parts (view modes, bundles) out of entity_info(), and broke HEAD.

git revert 44cedfa

webchick’s picture

Status: Fixed » Needs work

Rolled back.

webchick’s picture

Title: HEAD BROKEN: Introduce a generic entity bundle filter handler » Introduce a generic entity bundle filter handler
damiankloip’s picture

Title: Introduce a generic entity bundle filter handler » HEAD BROKEN: Introduce a generic entity bundle filter handler
Status: Needs work » Fixed
StatusFileSize
new2.65 KB

Here is a patch that unbreaks it.

damiankloip’s picture

Status: Fixed » Needs review
StatusFileSize
new10.85 KB

ok, a new patch.

damiankloip’s picture

Title: HEAD BROKEN: Introduce a generic entity bundle filter handler » Introduce a generic entity bundle filter handler

oops

Status: Needs review » Needs work
Issue tags: -VDC

The last submitted patch, 1891214-29.patch, failed testing.

damiankloip’s picture

Status: Needs work » Needs review
Issue tags: +VDC

#29: 1891214-29.patch queued for re-testing.

dawehner’s picture

Status: Needs review » Reviewed & tested by the community

I guess we can move that back to RTBC?

catch’s picture

#29: 1891214-29.patch queued for re-testing.

catch’s picture

Status: Reviewed & tested by the community » Fixed

Let's try that again. Committed/pushed to 8.x.

Automatically closed -- issue fixed for 2 weeks with no activity.