PHP code example of cebe / yii2-lifecycle-behavior

1. Go to this page and download the library: Download cebe/yii2-lifecycle-behavior 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/ */

    

cebe / yii2-lifecycle-behavior example snippets


	public function behaviors()
	{
		return [
			'lifecycle' => [
				'class' => cebe\lifecycle\LifecycleBehavior::class,
				'validStatusChanges' => [
					'draft'     => ['ready', 'delivered'],
					'ready'     => ['draft', 'delivered'],
					'delivered' => ['payed', 'archived'],
					'payed'     => ['archived'],
					'archived'  => [],
				],
			],
		];
	}

'events' => [
    BaseActiveRecord::EVENT_BEFORE_VALIDATE => 'handleBeforeValidate',
    BaseActiveRecord::EVENT_BEFORE_UPDATE => 'handleBeforeSave',
]