hook_post_action_example.module in Hook Post Action 8
Same filename and directory in other branches
A working example for hook_post_action module.
File
hook_post_action_example/hook_post_action_example.moduleView source
<?php
/**
* @file
* A working example for hook_post_action module.
*/
use Drupal\Core\Entity\EntityInterface;
/**
* Implements hook_entity_postsave().
*/
function hook_post_action_example_entity_postsave(EntityInterface $entity, $op) {
$id = $entity
->id();
$entity_type = $entity
->getEntityTypeId();
\Drupal::logger('hook_post_action_test')
->info("The {$op}d entity {$entity_type} id is {$id} from " . __FUNCTION__);
}
/**
* Implements hook_entity_postinsert().
*/
function hook_post_action_example_entity_postinsert(EntityInterface $entity) {
$id = $entity
->id();
$entity_type = $entity
->getEntityTypeId();
\Drupal::logger('hook_post_action_test')
->info("The inserted entity {$entity_type} id is {$id} from " . __FUNCTION__);
}
/**
* Implements hook_entity_postupdate().
*/
function hook_post_action_example_entity_postupdate(EntityInterface $entity) {
$id = $entity
->id();
$entity_type = $entity
->getEntityTypeId();
\Drupal::logger('hook_post_action_test')
->info("The updated entity {$entity_type} id is {$id} from " . __FUNCTION__);
}
/**
* Implements hook_entity_postdelete().
*/
function hook_post_action_example_entity_postdelete(EntityInterface $entity) {
$id = $entity
->id();
$entity_type = $entity
->getEntityTypeId();
\Drupal::logger('hook_post_action_test')
->info("The deleted entity {$entity_type} id is {$id} from " . __FUNCTION__);
}
/**
* Implements hook_ENTITY_TYPE_postsave().
*/
function hook_post_action_example_node_postsave(EntityInterface $entity, $op) {
$id = $entity
->id();
$bundle = $entity
->bundle();
\Drupal::logger('hook_post_action_test')
->info("The {$op}d node {$bundle} id is {$id} from " . __FUNCTION__);
}
/**
* Implements hook_ENTITY_TYPE_postinsert().
*/
function hook_post_action_example_node_postinsert(EntityInterface $entity) {
$id = $entity
->id();
$bundle = $entity
->bundle();
\Drupal::logger('hook_post_action_test')
->info("The inserted node {$bundle} id is {$id} from " . __FUNCTION__);
}
/**
* Implements hook_ENTITY_TYPE_postupdate().
*/
function hook_post_action_example_node_postupdate(EntityInterface $entity) {
$id = $entity
->id();
$bundle = $entity
->bundle();
\Drupal::logger('hook_post_action_test')
->info("The updated node {$bundle} id is {$id} from " . __FUNCTION__);
}
/**
* Implements hook_ENTITY_TYPE_postdelete().
*/
function hook_post_action_example_node_postdelete(EntityInterface $entity) {
$id = $entity
->id();
$bundle = $entity
->bundle();
\Drupal::logger('hook_post_action_test')
->info("The deleted node {$bundle} id is {$id} from " . __FUNCTION__);
}
Functions
Name | Description |
---|---|
hook_post_action_example_entity_postdelete | Implements hook_entity_postdelete(). |
hook_post_action_example_entity_postinsert | Implements hook_entity_postinsert(). |
hook_post_action_example_entity_postsave | Implements hook_entity_postsave(). |
hook_post_action_example_entity_postupdate | Implements hook_entity_postupdate(). |
hook_post_action_example_node_postdelete | Implements hook_ENTITY_TYPE_postdelete(). |
hook_post_action_example_node_postinsert | Implements hook_ENTITY_TYPE_postinsert(). |
hook_post_action_example_node_postsave | Implements hook_ENTITY_TYPE_postsave(). |
hook_post_action_example_node_postupdate | Implements hook_ENTITY_TYPE_postupdate(). |