raoul2000 / yii2-workflow

A simple workflow engine for Yii2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

where to change namspace

philippfrenzel opened this issue · comments

failed to load workflow definition : Class app\models\ProspectingWorkflow does not exist

as the namespace should be app\modules\prospecting\ProspectingWorkflow

I see you have an option inside WorkflowSource.php but where to "setup" ?

Thanks!

<?php

namespace app\modules\prospecting\models;

use Yii;
use yii\behaviors\TimestampBehavior;
use yii\behaviors\BlameableBehavior;

/**
 * This is the model class for table "prospecting".
 */
class Prospecting extends \app\modules\prospecting\models\base\Prospecting
{

    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            TimestampBehavior::className(),
            BlameableBehavior::className(),
            'simpleWorkflow' => [
                'class' => \raoul2000\workflow\base\SimpleWorkflowBehavior::className(),
                'source' => 'ProspectingWorkflow',
            ]
        ];
    }
}
commented

if you want to use another namespace than the default one with WorkflowPhpSource, you must declare the workflow source component and set the namespace option to the namespace you want to use.

Example :

$config = [
    // ....
    'components' => '
        'workflowSource' => [
          'class' => '\raoul2000\workflow\source\php\WorkflowPhpSource',
          'namespace' => ' \app\modules\prospecting\ProspectingWorkflow' 
        ]
   // ...

I'm consedering allowing namespace definition in a more easy way, when attaching the behavior to the model ....

yeah, would be great! my solution looks like this:

<?php 

namespace app\modules\prospecting\models;

class ProspectingWorkflowSource extends \raoul2000\workflow\source\php\WorkflowPhpSource
{
    public $namespace = 'app\modules\prospecting\models';
} 

And then added this one as "mySource" in components and used it in "source" attribute within behaviour...

Thanks for your support! merci beaucoupe!

I have the same problem please can you resolve it

"name": "Workflow Exception",
"message": "failed to load workflow definition : Class api\modules\v1\models\UploadresultWorkflow does not exist",
"code": 0,
"type": "raoul2000\workflow\base\WorkflowException",
"file": "C:\wamp\www\businesssetup\vendor\raoul2000\yii2-workflow\src\source\file\PhpClassLoader.php",
"line": 38,

my namespace is :namespace api\modules\v1\models;
Thank's

i also done changes with my config file but it not working
after changes in config file its give me
"message": "Class \raoul2000\workflow\source\file\WorkflowPhpSource does not exist",

and here is my config change :

'workflowSource' => [
'class' => '\raoul2000\workflow\source\file\WorkflowPhpSource',
'namespace' => 'api\modules\v1\models',
],

commented

Hi,
if your workflow is stored as a php Class, then using the default configuration should be ok and if you want to define your own namespace fo worflow classes, Then you have 2 options :

OPTION 1 : declare the WorkflowPhpSource AND its definitionLoader. The namespace property belongs to the definitionLoader component and not the WorkflowPhpSource like you did (see the documentation )

OPTION 2: use the magic alias @workflowDefinitionNamespace to set the namespace (see documentation)

ciao
😎

Thanks for replay i has done ..