lexik / lexikworkflowbundle Goto Github PK
View Code? Open in Web Editor NEWSimple workflow bundle for Symfony2
License: MIT License
Simple workflow bundle for Symfony2
License: MIT License
This is more of a support query. Once I've fully understood this bundle, I would love to contribute with a pull request to the README file.
The line $processHandler->start($model);
from your Usage example needs to be called once an entity is persisted for the first time. I hence thought I'd use an entity listener or lifecycle subscriber to handle it, but am getting a circular reference. Alternatively, I could implement checks in my form handler to call the method when the entity is first persisted.
What do you guys do in your projects โ where do you call it?
Is it possible that this bundle can keep track of the progress of a work flow?
What I mean; is it possible to save each action in a database table? Like John Doe created the first draft on yyyy/mm/dd. When someone approve it, another row gets added; Admin Jack approved draft on yyyy/mm/dd...
I am going to implement this work flow bundle, and I need to log all user actions as well, so I wonder if it can be accomplished with this or should I look for another bundle or develop that myself?
Thank you
Hi,
I just (rather accidentally) updated bundle today and stumbled upon new method to implement from ModelInterface - getWorkflowObject.
Its not documented right now (or i simply couldnt find it), so am I right to assume that getWorkflowObject simply returns my domain object?
Hi,
I tried to create a workflow inside a bundle but when I try to define the service for ProcessSuscriber, the only definition of the name tag (- { name: kernel.event_listener }) in services.yml file generates an error. It seems I must define at least the event attribute and the method that will be called when event is fired.
Error is :
InvalidArgumentException: Service "mybunlde.workflow.listener.myWorkflowName" must define the "event" attribute on "kernel.event_listener" tags.
Am I missing something ?
Hi,
I have gone through the Workflow example as it states but find it a little difficult to understand some sections. Would you be able to guide me through the following?
Thank you in advance.
Hi, I have an issue defining a conditional step in my workflow.
After my request has been validated by HR department, I'd like to check if the request needs to be validated by a director with a conditional step and if so, go to the step named "validation_director". If the request doesn't need to be validated by a director, just end the process.
My conditional step is defined as below :
lexik_workflow:
processes:
clearance_request:
start: clearance_request_created
steps:
....
validated_by_HR:
label: "Request validated by Human Resources"
model_status: [ setStatus, AppBundle\Entity\Request::STATUS_VALIDATED_HR ]
next_states:
check_direct_validation:
type: step_or
target:
validation_director: "resource:needDirectorValidation"
.......
I have then, an error when displaying any page :
InvalidTypeException: Invalid type for path "lexik_workflow.processes.clearance_request.steps.validated_by_HR.next_states.check_director_validation.target". Expected scalar, but got array.
Any idea of what's wrong with my workflow definition ?
Thank you :)
I'm seeking for such a package for laravel , can anyone help me with this?
At this moment, processes and steps are stored in the confiugration.
Is it possible to store processes and steps using Doctrine?
Hi,
when trying to use LexikWorkflowBundle for our project the need arose to be able to check whether a process can reach a next step without actually advancing the model to the next step. In more practical terms, I would like to know whether a user of my system is able to submit a certain web form before actually showing the form to the user. So I probably need something along the lines of:
if ($processHandler->canReachNextState($model, 'validate')) {...}
Like this we avoid duplicating code in the workflow validators and form controllers.
Is there a function like this? I didn't find one.
If there is not, I would probably simply copy $processHandler::reachNextState()
and adapt the method to my needs. This rises the next question:
What is the best way to extend the ProcessHandler?
Cheers,
Andreas
hello !
My error comes from my controller ($modelSate =$processHandler->start($model);).
I looked in the processHandler to identify the error but I don't know of or comes this error,
Thank you in advance for your help and I will be happy to resolve the error with you.
Is possible to the workflow wait for 2 steps acomplished?
Like this: http://symfony-workflow-demo.herokuapp.com/
Suggest: Can do twig extensions to facilite to manage step buttons
http://symfony.com/blog/new-in-symfony-3-2-workflow-component
It's such a shame for such poor documentation for a bundle that have so much potential...
Hi,
I started using your bundle this week and I got some troubles using it.
There is two things I would like to know :
Having a roles
attribute is an easy way to check permissions, but has some limitations. What if you want to allow users to edit their own posts/comments/whatever?
I think the Security Voters are the perfect way to check if a user has permissions to change the state of an object.
What about adding Security Voters to this bundle?
I have implemented 02 routes from draft creation to admin validation steps. Now I want to add a event subscriber so that after draft creation is reached, an email will trigger.
I am adding the event to subscribedEvents as:
public static function getSubscribedEvents()
{
return array(
'post_publication.draft_created.reached' => array(
'handleDraftCreated',
),
);
}
But unfortunately the handleDraftCreated function never called:
public function handleDraftCreated(StepEvent $event)
{
echo "handleDraftCreated called";
}
Anything I am missing here, need help, thanks in advance.
I have made a model for my entity which implements ModelInterface and ModelStateInterface
My model :
<?php
namespace myProject\myBundle\WorkFlow\Model;
use Lexik\Bundle\WorkflowBundle\Model\ModelInterface;
use Lexik\Bundle\WorkflowBundle\Model\ModelStateInterface;
use Lexik\Bundle\WorkflowBundle\Entity\ModelState;
use myProject\myBundle\Entity\myEntity;
class myModel implements ModelInterface, ModelStateInterface
{
...
public function addState(ModelState $modelState)
{
$this->myEntity->setStates[] = $modelState;
}
public function getStates()
{
return $this->myEntity->getStates;
}
}
Entity side added parameter (getter and setters by doctrine) :
/**
* @ORM\Column(nullable=true, name="States", type="array")
*/
protected $states = array();
/**
* @ORM\Column(nullable=true, name="Status", type="smallint")
*/
private $Status;
In my controller i do :
$em = $this->getDoctrine()->getManager();
$em->getConnection()->beginTransaction();
try {
// persist 1st my entity to get the entity id
$em->persist($myEntity);
$em->flush();
// next create modelstate and update status in my entity
$myEntityModel = new MyModel($myEntity);
$processHandler = $this->get('lexik_workflow.handler.myprocess');
$ModelState = $processHandler->start($myEntityModel)
$em->flush();
$em->getConnection()->commit();
} catch (WorkflowException $e) {
$em->getConnection()->rollback();
$em->close();
}
I have to implement addStates and getStates into the model or directly into the entity ?
Is it the best way in my controller to try / catch and reverse if WorkFlowException ?
My entity is ALWAYS saved in DB with States => empty array, why ?
// This code doesn't work :(
$myEntityModel->addState($ModelState)
Sorry for my bad english !
I have this error:
Invalid configuration for path "lexik_workflow.processes.post_publication.steps.draft_created.model_status": You must specify a valid constant name as second parameter
Can somebody help me with this???
thanks!!!
Is it possible to define an expiration date for a certain object state? To keep with the example of the documentation, let's assume I wish to delete all Post
objects whose model state have been Post::STATUS_DRAFT
for more than 30 days.
I could easily do this manually by calling a Symfony2 console command from a daily cronjob. But how would I properly do this within the workflow framework?
Can I perhaps get a functional demo of this workflow bundle somewhere? I understand how it it works but I don't understand how will a user with Admin roles see the post that require approval, and how does te Admin approve it then.
Can someone please help with a sample application where I can look how it works?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.