1. Go to this page and download the library: Download roaresearch/yii2-workflow 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/ */
roaresearch / yii2-workflow example snippets
class Api extends \roaresearch\yii2\roa\modules\ApiContainer
{
public $versions = [
// other versions
'w1' => ['class' => 'roaresearch\yii2\workflow\roa\modules\Version'],
];
}
class m170101_010101_credit extends EntityTable
{
public function getTableName(): string
{
return 'credit';
}
public function columns(): array
{
return [
'id' => $this->primaryKey(),
'workflow_id' => $this->normalKey(),
// other columns
];
}
public function foreignKeys(): array
{
return [
'workflow_id' => ['table' => 'workflow'];
];
}
}
class m170101_010102_credit_worklog extends \roaresearch\yii2\workflow\migrations\WorkLog
{
public function getProcessTableName(): string
{
return 'credit';
}
}
class Credit extends \roaresearch\yii2\workflow\models\Process
{
protected function workflowClass(): string
{
return CreditWorkLog::class;
}
public function getWorkflowId(): int
{
return $this->workflow_id;
}
public function rules()
{
return \yii\helpers\ArrayHelper::merge(parent::rules(), [
// other rules here
]);
}
}
class CreditWorkLog extends \roaresearch\yii2\workflow\models\WorkLog
{
public static function processClass(): string
{
return Credit::class;
}
}