PHP code example of loadsys / cakephp-creatormodifier

1. Go to this page and download the library: Download loadsys/cakephp-creatormodifier library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

loadsys / cakephp-creatormodifier example snippets


Plugin::load('CreatorModifier', ['bootstrap' => false, 'routes' => false]);

bin/cake plugin load CreatorModifier

$this->addBehavior('CreatorModifier.CreatorModifier');

$this->addBehavior('CreatorModifier.CreatorModifier', [
	'events' => [
		'Model.beforeSave' => [
			// Field storing the User.id who created the record,
			// only triggers on beforeSave when the Entity is new.
			'user_who_created_me_id' => 'new',

			// Field storing the User.id who modified the record,
			// always triggers on beforeSave.
			'user_who_modified_me_id' => 'always'
		]
	],
	// The key to read from `\Cake\Network\Request->session()->read();`
	// to obtain the User.id value to set during saves.
	'sessionUserIdKey' => 'Auth.User.id',
]);