Problem/Motivation

Some research in #2931559: $sandwich_plugin_info should be passed by reference shows that we don't have a test that proves plugin_type_example_sandwich_info_alter() works.

Proposed resolution

  • Convert PluginTypeExampleTest::testPluginExample() to be a kernel test for speed's sake
  • Expand that kernel test to show that the alter hook is implemented correctly

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork examples-2985705

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

Mile23 created an issue. See original summary.

avpaderno’s picture

Title: Ensure plugin_type_example alter hooks work. » Ensure plugin_type_example alter hooks work
Version: 8.x-1.x-dev » 4.0.x-dev
Component: Plugin Type Example » Code

oily made their first commit to this issue’s fork.

avpaderno’s picture

Title: Ensure plugin_type_example alter hooks work » Ensure hook_plugin_type_example_sandwich_info_alter() works
Component: Code » Tests
Issue summary: View changes
oily’s picture

Status: Active » Needs work
avpaderno’s picture

Title: Ensure hook_plugin_type_example_sandwich_info_alter() works » Ensure hook_sandwich_info_alter() works
avpaderno’s picture

Issue summary: View changes
avpaderno’s picture

Status: Needs work » Closed (won't fix)

hook_sandwich_info_alter() implementations will be invoked because the plugin manager for sandwich plugins has the following line in its class constructor.

$this->alterInfo('sandwich_info');

The argument passed to hook_sandwich_info_alter() needs to be passed by reference because it is not an object; differently, any change done to that array would not be passed back to the code invoking hook_sandwich_info_alter(). That is how PHP works.

A test to check that the definition of plugin_type_example_sandwich_info_alter() will not be changed back to function plugin_type_example_sandwich_info_alter(&$sandwich_plugin_info) is not necessary.

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.