mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
Implement the controller action to view the EntityworkflowSend
This commit is contained in:
@@ -13,9 +13,16 @@ namespace Chill\MainBundle\Workflow;
|
||||
|
||||
use Chill\DocStoreBundle\Entity\StoredObject;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflow;
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSend;
|
||||
use Chill\MainBundle\Workflow\Exception\HandlerNotFoundException;
|
||||
use Chill\MainBundle\Workflow\Exception\HandlerWithPublicViewNotFoundException;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
|
||||
/**
|
||||
* Manage the handler and performs some operation on handlers.
|
||||
*
|
||||
* Each handler must implement @{EntityWorkflowHandlerInterface::class}.
|
||||
*/
|
||||
class EntityWorkflowManager
|
||||
{
|
||||
/**
|
||||
@@ -63,4 +70,26 @@ class EntityWorkflowManager
|
||||
|
||||
return [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the public view for the given entity workflow send.
|
||||
*
|
||||
* @param EntityWorkflowSend $entityWorkflowSend the entity workflow send object
|
||||
*
|
||||
* @return string the rendered public view
|
||||
*
|
||||
* @throws HandlerWithPublicViewNotFoundException if no handler with public view is found
|
||||
*/
|
||||
public function renderPublicView(EntityWorkflowSend $entityWorkflowSend): string
|
||||
{
|
||||
$entityWorkflow = $entityWorkflowSend->getEntityWorkflowStep()->getEntityWorkflow();
|
||||
|
||||
foreach ($this->handlers as $handler) {
|
||||
if ($handler instanceof EntityWorkflowWithPublicViewInterface && $handler->supports($entityWorkflow)) {
|
||||
return $handler->renderPublicView($entityWorkflowSend);
|
||||
}
|
||||
}
|
||||
|
||||
throw new HandlerWithPublicViewNotFoundException();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSend;
|
||||
|
||||
interface EntityWorkflowWithPublicViewInterface
|
||||
{
|
||||
/**
|
||||
* Render the public view for EntityWorkflowSend.
|
||||
*
|
||||
* The public view must be a safe html string
|
||||
*/
|
||||
public function renderPublicView(EntityWorkflowSend $entityWorkflowSend): string;
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Workflow\Exception;
|
||||
|
||||
class HandlerWithPublicViewNotFoundException extends \RuntimeException {}
|
Reference in New Issue
Block a user