Initial Commit
This commit is contained in:
commit
e3d6978239
4 changed files with 58 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*~
|
5
keymaster/keymaster.info.yml
Normal file
5
keymaster/keymaster.info.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
name: 'Keymaster'
|
||||
type: module
|
||||
description: 'Syncs user data with other Duensing Digital services.'
|
||||
package: Duensing Digital
|
||||
core_version_requirement: ^11
|
9
keymaster/keymaster.module
Normal file
9
keymaster/keymaster.module
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
/*
|
||||
Chad Peppers
|
||||
hook_entity_insert, hook_entity_update, hook_entity_presave
|
||||
will be what runs on entities such as users and nodes on the site. The rest
|
||||
I do not believe there are specific hooks that would encapsulate all of what
|
||||
you are doing. However, if its a form that is being submitted then you
|
||||
would use hook_form_alter to add a custom submit handler.
|
||||
*/
|
43
keymaster/src/Hook/KeymasterHooks.php
Normal file
43
keymaster/src/Hook/KeymasterHooks.php
Normal file
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\keymaster\Hook;
|
||||
|
||||
use Drupal\Core\Hook\Attribute\Hook;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
|
||||
|
||||
define("DD_LOG_FILE", "/var/www/cms/web/modules/keymaster/keymaster.log");
|
||||
|
||||
|
||||
function dd_log($data) {
|
||||
if (true === WP_DEBUG) {
|
||||
if (is_array($data) || is_object($data)) {
|
||||
file_put_contents(DD_LOG_FILE, print_r($data, true) . "\n", FILE_APPEND);
|
||||
} else {
|
||||
file_put_contents(DD_LOG_FILE, $data . "\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class KeymasterHooks {
|
||||
|
||||
#[Hook('hook_entity_insert')]
|
||||
public function insert(EntityInterface $entity) {
|
||||
dd_log("Insert");
|
||||
dd_log($entity);
|
||||
}
|
||||
|
||||
#[Hook('hook_entity_update')]
|
||||
public function update(EntityInterface $entity) {
|
||||
dd_log("Insert");
|
||||
dd_log($entity);
|
||||
}
|
||||
|
||||
#[Hook('hook_entity_presave')]
|
||||
public function presave(EntityInterface $entity) {
|
||||
dd_log("Insert");
|
||||
dd_log($entity);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue