Comments

berdir’s picture

Yes it is.

hook_ENTITY_TYPE_prepare_form()

andypost’s picture

Issue summary: View changes
Issue tags: +Novice
gerzenstl’s picture

If it's already documented on hook_ENTITY_TYPE_prepare_form(), do we need something else?

I could help.

andypost’s picture

@gerzenstl it's documented wrong
The proper way is
Implements hook_ENTITY_TYPE_prepare_form() for node entities.

andypost’s picture

Issue summary: View changes
gerzenstl’s picture

I thought it was about the documentation of the hook_ENTITY_TYPE_prepare_form().

I fixed the documentation on the implementation of this hook.

Currently is only used on menu_ui and book module. The implementation on datetime module was removed on #2333353

gerzenstl’s picture

Status: Active » Needs review
andypost’s picture

Status: Needs review » Needs work

Please add "for node entities" at the end as we use all over core.
PS: try git grep hook_ENTITY_TYPE_

gerzenstl’s picture

To find the hook_node_prepare_form() I used (on the root of the drupal code):
fgrep -Hrn --color=always 'hook_node_prepare_form' .

But the one you suggest is useful also.

I can add that for all hook_ENTITY_TYPE_* hooks.

pushpinderchauhan’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB

This hook found in book and menu_ui modules, not in datetime. Please review update patch that contains following doc.

+ * Implements hook_ENTITY_TYPE_prepare_form() for node entities.

andypost’s picture

@gerzenstl It would be great to check all hook_ENTITY_TYPE_* implementations doc blocks and make sure all fixed
I've no idea how to grep 'em all but #8 lists 221 lines and most of them points their entity types so manually is fine

core/modules/comment/comment.module:142: * Implements hook_ENTITY_TYPE_create() for 'field_instance_config'.
core/modules/comment/comment.module:163: * Implements hook_ENTITY_TYPE_update() for 'field_instance_config'.
core/modules/comment/comment.module:174: * Implements hook_ENTITY_TYPE_insert() for 'field_storage_config'.
core/modules/comment/comment.module:187: * Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'.

core/modules/system/tests/modules/entity_test/entity_test.module:315: * Implements hook_ENTITY_TYPE_insert().
core/modules/system/tests/modules/entity_test/entity_test.module:409: * Implements hook_ENTITY_TYPE_translation_insert().
core/modules/system/tests/modules/entity_test/entity_test.module:416: * Implements hook_ENTITY_TYPE_translation_delete().
core/modules/system/tests/modules/entity_test/entity_test.module:481: * Implements hook_ENTITY_TYPE_access().
core/modules/system/tests/modules/entity_test/entity_test.module:495: * Implements hook_ENTITY_TYPE_create_access().

core/modules/tour/tests/tour_test/tour_test.module:11: * Implements hook_ENTITY_TYPE_load() for tour.
core/modules/tour/tests/tour_test/tour_test.module:20: * Implements hook_ENTITY_TYPE_presave() for tour.

core/modules/views/views.module:465: * Implements hook_ENTITY_TYPE_create() for 'field_instance_config'.
core/modules/views/views.module:473: * Implements hook_ENTITY_TYPE_update() for 'field_instance_config'.
core/modules/views/views.module:481: * Implements hook_ENTITY_TYPE_delete() for 'field_instance_config'.

Let's file novice follow-up to unify them

gerzenstl’s picture

I checked all the ENTITY_TYPE hook implementations and added the proper entity on the doc blocks.

BFox’s picture

Assigned: Unassigned » BFox
BFox’s picture

Assigned: BFox » Unassigned
Status: Needs review » Reviewed & tested by the community

Checked through all ENTITY_TYPE hook implementations and all appear correct. Marking RBTC.

Status: Reviewed & tested by the community » Needs work
gerzenstl’s picture

Assigned: Unassigned » gerzenstl
gerzenstl’s picture

Seems that the testbot tested the patch against a revision with many changes. I created another one and I tested just in case:

$ git reset --hard HEAD
$ git apply --check d8-fix-documentation-hook-entities-implementation-2331783-17.patch
$

It should apply the patch without problem.

gerzenstl’s picture

Status: Needs work » Needs review
omessaoudi’s picture

I will test this

==> Sorry, but the patch doesn't work for me : it does not apply successfully on all modules :

 patch -p1<d8-fix-documentation-hook-entities-implementation-2331783-17.patch
patching file core/modules/block/block.module
Hunk #1 succeeded at 308 (offset -10 lines).
patching file core/modules/book/book.module
Hunk #1 succeeded at 294 (offset -15 lines).
patching file core/modules/comment/comment.module
Hunk #1 FAILED at 139.
Hunk #2 FAILED at 160.
Hunk #4 FAILED at 184.
3 out of 4 hunks FAILED -- saving rejects to file core/modules/comment/comment.module.rej
patching file core/modules/config/tests/config_entity_static_cache_test/config_entity_static_cache_test.module
patching file core/modules/config/tests/config_test/config_test.module
patching file core/modules/entity_reference/entity_reference.module
patching file core/modules/image/image.module
Hunk #1 succeeded at 367 (offset -14 lines).
Hunk #2 FAILED at 407.
Hunk #3 succeeded at 445 (offset -14 lines).
Hunk #4 FAILED at 461.
2 out of 4 hunks FAILED -- saving rejects to file core/modules/image/image.module.rej
patching file core/modules/language/language.module
Hunk #1 succeeded at 431 with fuzz 1 (offset -78 lines).
Hunk #2 succeeded at 445 (offset -78 lines).
patching file core/modules/locale/locale.module
Hunk #1 succeeded at 212 (offset -11 lines).
Hunk #2 succeeded at 223 (offset -11 lines).
Hunk #3 succeeded at 234 (offset -11 lines).
patching file core/modules/menu_ui/menu_ui.module
Hunk #1 succeeded at 155 (offset -11 lines).
Hunk #2 succeeded at 212 (offset -11 lines).
patching file core/modules/node/node.module
Hunk #1 succeeded at 1403 (offset -12 lines).
patching file core/modules/node/src/Tests/NodeEntityViewModeAlterTest.php
patching file core/modules/options/options.module
patching file core/modules/system/tests/modules/entity_test/entity_test.module
Hunk #1 succeeded at 306 (offset -14 lines).
Hunk #2 succeeded at 406 (offset -12 lines).
Hunk #3 succeeded at 482 (offset -8 lines).
Hunk #4 succeeded at 502 (offset -2 lines).
patching file core/modules/tour/tests/tour_test/tour_test.module
patching file core/modules/views/views.module
Hunk #1 FAILED at 476.
Hunk #2 FAILED at 484.
Hunk #3 FAILED at 492.
3 out of 3 hunks FAILED -- saving rejects to file core/modules/views/views.module.rej
omessaoudi’s picture

Issue tags: +Amsterdam2014
nlisgo’s picture

StatusFileSize
new12.51 KB

Re-roll

linl’s picture

Assigned: gerzenstl » Unassigned
Status: Needs review » Needs work
Issue tags: +Needs reroll

Patch no longer applies.

rpayanm’s picture

Status: Needs work » Needs review
Issue tags: -Needs reroll
StatusFileSize
new12.57 KB
andypost’s picture

Status: Needs review » Reviewed & tested by the community

Looks good

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/core/modules/config/tests/config_entity_static_cache_test/config_entity_static_cache_test.module
@@ -23,7 +23,7 @@ function config_entity_static_cache_test_config_test_load($entities) {
- * Implements hook_entity_type_alter().
+ * Implements hook_ENTITY_TYPE_load() for config_test entities.
  */
 function config_entity_static_cache_test_entity_type_alter(array &$entity_types) {

This looks like an incorrect change. hook_entity_type_alter() is a proper hook.

alexpott’s picture

Also the scope of the patch and the issue summary / issue title are not aligned - please the issue summary and title.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new835 bytes
new12.57 KB

Please review :)

alexpott’s picture

Status: Needs review » Needs work
+++ b/core/modules/config/tests/config_entity_static_cache_test/config_entity_static_cache_test.module
@@ -23,7 +23,7 @@ function config_entity_static_cache_test_config_test_load($entities) {
 /**
- * Implements hook_entity_type_alter().
+ * Implements hook_ENTITY_TYPE_alter() for config_test entities.
  */
 function config_entity_static_cache_test_entity_type_alter(array &$entity_types) {

The original documentation is correct. No change is necessary here.

rpayanm’s picture

Status: Needs work » Needs review
StatusFileSize
new811 bytes
new171.23 KB
rgristroph’s picture

StatusFileSize
new12.57 KB

I think #29 correctly addressed the comment from #27, but may have inadvertently included some other stuff in the patch file. I just re-rolled it, attached. I also read through all the changed comments and they look OK, and then I looked for missed places that might need changes with these commands:

grep -r hook_ENTITY_TYPE_ . | grep prepare_form

grep -r hook_ . | grep _prepare_form

I think this patch should pull everything above together.

lakshminp’s picture

Status: Needs review » Reviewed & tested by the community

#30 documents hook_node_prepare_form() in all places in the core.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

The patch in #30 also does far more than documenting hook_node_prepare_form(). Either we should remove the out-of-scope changes or re-scope the issue summary and title.

keopx’s picture

nlisgo’s picture

Status: Needs work » Needs review
rgristroph’s picture

StatusFileSize
new518 bytes

I looked at the patch in #33 and it seems to include some extraneous changes.

It also looks like some of the places that used to use hook_node_prepare_form() no longer do, for example in block and menu_ui. In fact it seems there is a single call left in code, in the book module. I am attaching a patch which addresses only that.

xano’s picture

Status: Needs review » Reviewed & tested by the community

I have checked the code base and there is indeed only one implementation of hook_ENTITY_TYPE_prepare_form() in core and the patch from #35 fixes its docblock.

Thanks!

rteijeiro’s picture

Status: Reviewed & tested by the community » Needs work

I think the correct documentation is Implements hook_ENTITY_TYPE_prepare_form() for node entities. as @andypost expressed in the IS.

jhodgdon’s picture

#37 is correct.

keopx’s picture

Status: Needs work » Needs review
StatusFileSize
new536 bytes
new456 bytes
rteijeiro’s picture

Status: Needs review » Reviewed & tested by the community

Good!

jhodgdon’s picture

+1

rteijeiro’s picture

Title: hook_node_prepare_form() is not documented » hook_ENTITY_TYPE_prepare_form() is not documented
Issue summary: View changes
Issue tags: -Needs issue summary update

Changing the title to the right hook.

rteijeiro’s picture

Issue summary: View changes
rteijeiro’s picture

I noticed that it's also wrong for hook_ENTITY_TYPE_update in core/modules/ckeditor/ckeditor.module file. Is there a issue or should I open a follow-up?

jhodgdon’s picture

New issue please, thanks! Maybe check to see if there are other spots?

rteijeiro’s picture

Sorry, forgot to post the issue number here: #2472669: Complete documentation for every implementation of hook_ENTITY_TYPE_*

It's also RTBC ;)

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Looks like Alex's feedback was addressed.

Committed and pushed to 8.0.x. Thanks!

webchick’s picture

oops.

  • webchick committed f8514fe on 8.0.x
    Issue #2331783 by rpayanm, gerzenstl, keopx, rgristroph, nlisgo, er....

Status: Fixed » Closed (fixed)

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