Problem/Motivation

We want to support all core content entity types!

This issue is to add a 'PanelizerEntity' plugin to provide support for 'taxonomy_term' entities.

Proposed resolution

  • Add a 'PanelizerEntity' plugin to provide support for 'taxonomy_term' entities.

Remaining tasks

  • Create the plugin class in src/Plugin/PanelizerEntity/ directory
  • See src/Plugin/PanelizerEntity/PanelizerNode.php for an example!
  • If the entity has a 'view_builder', look at it's code for anything that makes the entity special
  • If this entity needs any special blocks for it's default display, for example, like the 'node links' block, create issues in the CTools queue (so Page Manager could use them, if it wanted)
  • Check for a hook_entity_extra_field_info() which could have some things that need special blocks
  • Check for a hook_ENTITY_TYPE_view_alter() for other rendering wierdness we might need to replicate
  • Check the support code in Panelizer for D7 (and CTools for D7, for special blocks) to see if we did anything special there that makes sense in D8 too
  • Add description field block to default display by default Should get added by PanelizerEntityBase by default

User interface changes

API changes

Data model changes

Comments

dsnopek created an issue. See original summary.

dsnopek’s picture

Issue summary: View changes

Oops! Forgot to remove a bit of text added by Dreditor.

dsnopek’s picture

artreaktor’s picture

I implemented integration plugin, but stuck having 403 error when accessing PanelsIPEPageController::getBlockPlugins
route: panels_ipe.block_plugins
url: /admin/panels_ipe/variant/panelizer_field/taxonomy_term:40:full/block_plugins

I'm able to add first block (whatever type) to the term panelizer, as well as save the changes. But the error appears when I'm trying to add one more block (Manage Content) or change layout.

UPD: the panelizer stops working after the panel was saved as custom. Till that point I can add any number of blocks. In other words: it is fully-functional until first save-as-custom.
Also it's not possible to save the panel as default: the changes are lost on page refresh.

artreaktor’s picture

This patch fixes the #4 "403" issue

floretan’s picture

Status: Active » Needs work
StatusFileSize
new2.91 KB

Rerolling the patch from comment #4 so that it applies cleanly with git. This doesn't provide the full functionality described in the issue description, but it's a usable starting point.

jlandfried’s picture

Status: Needs work » Needs review
StatusFileSize
new5.63 KB

I've been using #6 for some time and have only had to make one minor change, and that is that the token for the page title should be [term:name] rather than [taxonomy_term:name]. Other than that this has been working well for several months for me.

I did adjust how the page title gets set so it mirrors how PanelizerNode does it, and added a functional test similar to the PanelizerNodeFunctionalTest.

The d7 version of the term display doesn't have any special handling for the default display (http://cgit.drupalcode.org/panelizer/tree/plugins/entity/PanelizerEntity...), so I don't really think anything's needed here, at least not for the initial implementation.

Status: Needs review » Needs work

The last submitted patch, 7: add_support_for-2664574-7.patch, failed testing.

jlandfried’s picture

Status: Needs work » Needs review

Fwiw, the test failure is related to the node functional test. In the interest of not muddling the issue at hand I've created https://www.drupal.org/node/2820562 to address that.

The last submitted patch, 4: taxonomy-panelizer-integration-2664574.patch, failed testing.

The last submitted patch, 5: 2664574-Taxonomy-panelizer-update-403.patch, failed testing.

The last submitted patch, 6: taxonomy-panelizer-integration-2664574-6.patch, failed testing.

hctom’s picture

Status: Needs review » Needs work

I took a look at patch from #7. Here are some notes/questions:

diff --git a/src/Panelizer.php b/src/Panelizer.php
index 864191d..5cbc4a9 100644
--- a/src/Panelizer.php
+++ b/src/Panelizer.php
@@ -247,7 +247,7 @@ class Panelizer implements PanelizerInterface {
       $panelizer_item->default = $default;
 
       // Create a new revision if possible.
-      if ($entity instanceof RevisionableInterface) {
+      if ($entity->getEntityType()->hasKey('revision')) {
         if ($entity->isDefaultRevision()) {
           $entity->setNewRevision(TRUE);
         }
@@ -564,4 +564,4 @@ class Panelizer implements PanelizerInterface {
     return $this->hasOperationPermission($op, $entity_type_id, $bundle, $account);
   }
 
-}
\ No newline at end of file
+}
  • Why do you change $entity instanceof RevisionableInterface? If this is really necessary, there are several more places in the module that use the same pattern
  • Newline is missing at end of file
  • Plugin class docblock says 'nodes'
  • Use 'name' block... in // Remove 'title' block... comment
  • The test class also has some occurences of node(s)
hctom’s picture

Status: Needs work » Needs review
StatusFileSize
new4.97 KB
new2.27 KB

And here is an updated patch with the noted changes (also with the unchanged $entity instanceof RevisionableInterface part).

hctom’s picture

Issue summary: View changes
Status: Needs review » Needs work

Use issue template to be able to outline remaining tasks better

jlandfried’s picture

Hey @hctom, thanks for taking a look at this, and catching the references to node in the comments!

Why do you change $entity instanceof RevisionableInterface? If this is really necessary, there are several more places in the module that use the same pattern

\Drupal\taxonomy\Entity\Term is an instance of RevisionableInterface, since it extends ContentEntityBase, even though terms aren't revisionable themselves.

setNewRevision throws an exception when it's called for an entity that isn't capable of using revisions.

With #14 applied, I receive the following error when trying to update the panelizer display for a taxonomy term:

LogicException: Entity type taxonomy_term does not support revisions. in Drupal\Core\Entity\ContentEntityBase->setNewRevision() (line 263 of /{DOCROOT}/core/lib/Drupal/Core/Entity/ContentEntityBase.php).
hctom’s picture

Issue summary: View changes

Remove description field task, because it should be handled by the PanelizerEntityBase base class already

hctom’s picture

@jiff Ah thanx for the explanation. So this is really a bug itself in the whole panelizer project ;) I created a new issue to keep this separated, because it also affects other parts of the code: #2828840: Handle revisionable entities better

phenaproxima’s picture

Issue summary: View changes

Did a little research and updated the remaining tasks:

If the entity has a 'view_builder', look at it's code for anything that makes the entity special

Taxonomy terms do have a view builder, but it only implements alterBuild()...and the Panelizer plugin in the latest patch does the same exact thing.

If this entity needs any special blocks for it's default display, for example, like the 'node links' block, create issues in the CTools queue (so Page Manager could use them, if it wanted)

Taxonomy does not provide any block plugins of its own, so it seems safe to assume that there are no special blocks we need to handle.

Check for a hook_entity_extra_field_info() which could have some things that need special blocks

Taxonomy does not implement this hook.

Check for a hook_ENTITY_TYPE_view_alter() for other rendering wierdness we might need to replicate

Grepping for "_view_alter" in taxonomy.module produces no results.

phenaproxima’s picture

Status: Needs work » Needs review

Marking for review so we can see if the tests passeth.

phenaproxima’s picture

StatusFileSize
new4.97 KB

Re-upping the patch to trigger testing.

damienmckenna’s picture

Status: Needs review » Needs work

... why didn't the tests trigger?

damienmckenna’s picture

Status: Needs work » Needs review

The last submitted patch, 14: add_support_for-2664574-14.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 21: 2664574-21.patch, failed testing.

phenaproxima’s picture

Status: Needs work » Needs review
StatusFileSize
new1.18 KB
new6.2 KB

Famous last words, but this should pass the tests.

damienmckenna’s picture

PS I've added a new issue for refactoring the entity tests: #2834851: Add generic entity tests, extend for each entity type

Seeing as this issue already has tests the refactoring can be done later.

damienmckenna’s picture

Status: Fixed » Closed (fixed)

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