raoul2000 / yii2-workflow

A simple workflow engine for Yii2
BSD 3-Clause "New" or "Revised" License
171 stars 48 forks source link

Call to undefined method ::attach() #26

Closed ferllings closed 8 years ago

ferllings commented 8 years ago

Hello,

I was using your workflow plugin with Yii1, and now I'm trying to move on yii2.

I updated my model and Workflow description, but I'm receiving an error:

Call to undefined method app\models\workflows\InternalWorkflow::attach() in /app/vendor/yiisoft/yii2/base/Component.php at line 672

Any idea?

ferllings commented 8 years ago

More details, It works fine if I use the default naming convention: "app\models\swInternal" (My model is Internal)

But if I use "app\models\workflows\InternalWorkflow" I receive the error above.

How should I declare my workflow path in the behaviour ?

raoul2000 commented 8 years ago

Hi @ferllings and sorry for the late reply (I'm on holiday right now :sunglasses:). To use a custom namespace for your workflows, the simplest solution is to initialise the reserved alias @workflowDefinitionNamespace as follows :

Yii::setAlias('@workflowDefinitionNamespace','app\\models\\workflows');

Another option is to declare explicitly the WorkflowSource component to use and more important, the class loader component. You can find a detailed description in the Documentation.

ciao

ferllings commented 8 years ago

Thanks,

I found another way, adding that in the main.conf

        'workflowSource' => [
          'class' => 'raoul2000\workflow\source\file\WorkflowFileSource',
          'definitionLoader' => [
              'class' => 'raoul2000\workflow\source\file\PhpArrayLoader',
              'path'  => '@common/models/workflows'
           ]
        ],

Thanks for your hard work, your components is great!!