Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
rules-3461953
Manage
Activity
Members
Labels
Plan
Custom issue tracker
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Issue forks
rules-3461953
Commits
2655876a
Commit
2655876a
authored
9 years ago
by
Klaus Purer
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2566063
: rules_entity_view() has wrong signature
parent
6a221467
No related branches found
Branches containing commit
Tags
7.x-2.10
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
rules.module
+2
-1
2 additions, 1 deletion
rules.module
tests/src/Kernel/EntityViewTest.php
+68
-0
68 additions, 0 deletions
tests/src/Kernel/EntityViewTest.php
with
70 additions
and
1 deletion
rules.module
+
2
−
1
View file @
2655876a
...
...
@@ -6,6 +6,7 @@
*/
use
Drupal\Core\Entity\ContentEntityInterface
;
use
Drupal\Core\Entity\Display\EntityViewDisplayInterface
;
use
Drupal\Core\Entity\EntityInterface
;
use
Drupal\rules\Event\EntityEvent
;
use
Drupal\rules\Event\UserLoginEvent
;
...
...
@@ -36,7 +37,7 @@ function rules_user_logout($account) {
/**
* Implements hook_entity_view().
*/
function
rules_entity_view
(
EntityInterface
$entity
)
{
function
rules_entity_view
(
array
&
$build
,
EntityInterface
$entity
,
EntityViewDisplayInterface
$display
,
$view_mode
,
$langcode
)
{
// Only handle content entities and ignore config entities.
if
(
$entity
instanceof
ContentEntityInterface
)
{
$entity_type_id
=
$entity
->
getEntityTypeId
();
...
...
This diff is collapsed.
Click to expand it.
tests/src/Kernel/EntityViewTest.php
0 → 100644
+
68
−
0
View file @
2655876a
<?php
/**
* @file
* Contains \Drupal\rules\Tests\EntityViewTest.
*/
namespace
Drupal\Tests\rules\Kernel
;
/**
* Tests that rules_entity_view() does not throw fatal errors.
*
* @group rules
*/
class
EntityViewTest
extends
RulesDrupalTestBase
{
/**
* Modules to enable.
*
* @var array
*/
public
static
$modules
=
[
'field'
,
'node'
,
'text'
,
'user'
];
/**
* {@inheritdoc}
*/
public
function
setUp
()
{
parent
::
setUp
();
$this
->
installConfig
([
'system'
]);
$this
->
installConfig
([
'field'
]);
$this
->
installConfig
([
'node'
]);
$this
->
installSchema
(
'system'
,
[
'router'
,
'sequences'
]);
$this
->
installEntitySchema
(
'user'
);
$this
->
installEntitySchema
(
'node'
);
// Make sure that the node routes get picked when used during rendering.
$this
->
container
->
get
(
'router.builder'
)
->
rebuild
();
}
/**
* Tests that rules_entity_view() can be invoked correctly.
*/
public
function
testEntityViewHook
()
{
// Create a node.
$entity_manager
=
$this
->
container
->
get
(
'entity.manager'
);
$entity_manager
->
getStorage
(
'node_type'
)
->
create
([
'type'
=>
'page'
,
'display_submitted'
=>
FALSE
,
])
->
save
();
$node
=
$entity_manager
->
getStorage
(
'node'
)
->
create
([
'title'
=>
'test'
,
'type'
=>
'page'
,
]);
$node
->
save
();
// Build the node render array and render it, so that hook_entity_view() is
// invoked.
$view_builder
=
$entity_manager
->
getViewBuilder
(
'node'
);
$build
=
$view_builder
->
view
(
$node
);
$this
->
container
->
get
(
'renderer'
)
->
renderPlain
(
$build
);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment