Problem/Motivation

Both methods have a second parameter in their implementations, but only ::hasHandlerClass() has it documented in the interface.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

Comments

hchonov created an issue. See original summary.

hchonov’s picture

StatusFileSize
new805 bytes
hardik_patel_12’s picture

Status: Needs review » Reviewed & tested by the community

Make sense , LGTM.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/lib/Drupal/Core/Entity/EntityTypeInterface.php
@@ -168,11 +168,13 @@ public function hasHandlerClass($handler_type, $nested = FALSE);
+   * @param bool $nested
+   *   (optional) If this handler has a nested definition. Defaults to FALSE.

So this is not a boolean. I was wondering what on earth does nested mean...

But it's normally a string when it is actually used... for example:

$operation = $entity->getEntityType()->hasHandlerClass('form', 'add') ? 'add' : 'default';

Nested handlers are like the form and route_provider ones below...

 *   handlers = {
 *     "storage" = "Drupal\node\NodeStorage",
 *     "storage_schema" = "Drupal\node\NodeStorageSchema",
 *     "view_builder" = "Drupal\node\NodeViewBuilder",
 *     "access" = "Drupal\node\NodeAccessControlHandler",
 *     "views_data" = "Drupal\node\NodeViewsData",
 *     "form" = {
 *       "default" = "Drupal\node\NodeForm",
 *       "delete" = "Drupal\node\Form\NodeDeleteForm",
 *       "edit" = "Drupal\node\NodeForm",
 *       "delete-multiple-confirm" = "Drupal\node\Form\DeleteMultiple"
 *     },
 *     "route_provider" = {
 *       "html" = "Drupal\node\Entity\NodeRouteProvider",
 *     },
 *     "list_builder" = "Drupal\node\NodeListBuilder",
 *     "translation" = "Drupal\node\NodeTranslationHandler"
 *   },
ravi.shankar’s picture

Status: Needs work » Needs review
StatusFileSize
new989 bytes
new601 bytes

Here I have tried to made changes as per comment #4.

alexpott’s picture

Status: Needs review » Needs work

Well it's string|false and we should update \Drupal\Core\Entity\EntityTypeInterface::hasHandlerClass() too.

hchonov’s picture

Status: Needs work » Needs review
StatusFileSize
new1.35 KB
joachim’s picture

Status: Needs review » Reviewed & tested by the community

LGTM!

alexpott’s picture

Version: 9.0.x-dev » 8.9.x-dev
Status: Reviewed & tested by the community » Fixed

Committed and pushed fd8c922277 to 9.0.x and e6fcece5ee to 8.9.x. Thanks!

As the only implementation in core has the param even though it's not on the interface I think this is an okay under the 1-1 interface to class rule.

  • alexpott committed fd8c922 on 9.0.x
    Issue #3114909 by hchonov, ravi.shankar, alexpott: Inconsistency between...

  • alexpott committed e6fcece on 8.9.x
    Issue #3114909 by hchonov, ravi.shankar, alexpott: Inconsistency between...

Status: Fixed » Closed (fixed)

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

quietone’s picture

I just closed #2203357: Inconstancies in getHandlerClass and hasHandlerClass as a duplicate of this which is unfortunate as it was opened earlier than this, in 2014. A good reminder to all of us to search for existing issues.