Closed abdullah-almesbahi closed 9 years ago
I think you can already use It? Watch the docs - samples are working;)
Actually I didn't test it , I'll check it tomorrow. thanks
yes, just like @philippfrenzel says, samples from the guide already work, and tests coverage is ok. I will try to publish a first release in April.
I'm using yii2 advanced template , I followed quick-start.md but didn't work , here is the error :
Unable to find 'app\models\EvooyWorkflow' in file: C:\wamp\www\ws1\backend/models/EvooyWorkflow.php. Namespace missing?
here is the code
namespace backend\models;
use Yii;
class EvooyWorkflow implements \raoul2000\workflow\base\IWorkflowDefinitionProvider
{
public function getDefinition() {
return [
'initialStatusId' => 'draft',
'status' => [
'draft' => [
'transition' => ['publish','deleted']
],
'publish' => [
'transition' => ['draft','deleted']
],
'deleted' => [
'transition' => ['draft']
]
]
];
}
}
I had to change the default namespace in WorkflowPhpSource.php from
public $namespace = 'app\models';
To
public $namespace = 'backend\models';
To make it work. is it possible to change it from behaviors like this or there is another way?
public function behaviors()
{
return [
'simpleWorkflow' => [
'class' => \raoul2000\workflow\base\SimpleWorkflowBehavior::className(),
'namespace' => 'backend\models',
],
];
}
this is because you are using advanced template... use classmap feature to 'route'
I don't know if this is a bug or not , I have 3 statuses draft , publish and deleted . when I create new post , I should see the initial status which is draft instead of that I See the status in database is PostWorkflow/draft
I think that's the "value" that should be standing inside the status field. It's an reference to the model and the status... ?
like @philippfrenzel said the default namespace where workflow are searched is based on the yii2 basic template. If you need to use another namespace then you must declare your own workflowSource component with the correct namespace value. Note that namespace is an attribute that belongs to the WorkflowSource component and not to the behavior.
By default SimpleWorkflowBehavior uses a WorkflowSource component named workflowSource. So what you can do is :
1) in Yii config file, delcare your own workflow source component
@app/config/web.cfg
$config = [
// ....
'components' => [
// define the default workflow source component so it uses a specific namespace
'workflowSource' => [
'class' => '\raoul2000\workflow\source\php\WorkflowPhpSource',
'namespace' => 'backend\models'
]
// etc ...
2) Attach the behavior to the model without any other change.
public function behaviors()
{
return [
'simpleWorkflow' => [
'class' => \raoul2000\workflow\base\SimpleWorkflowBehavior::className(),
],
];
}
With this configuration all workflow are search in the 'backend\models' namespace.
I know this topic is not covered by the doc which is mainly based on default settings and conventions in the context of the Yii2 basic app template. I will do my best to complete this part of the guide as soon as possible.
Regarding the status Id PostWorkflow/draft this is not a bug but the way a status Id is stored. In order to garantee uniqueness a status Id is composed of the workflow Id and the *node" id.
Thank you for Your explanation.
how long do you think it will take till the first version to be release?