mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-29 19:13:49 +00:00
Add public workflow view functionality
Introduced the ability to render public views for workflows, including new templates, handlers, and metadata support. Updated entity interfaces and translations to enhance the public sharing of workflow documents.
This commit is contained in:
@@ -16,6 +16,7 @@ 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 Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO;
|
||||
use Symfony\Component\Workflow\Registry;
|
||||
|
||||
/**
|
||||
@@ -80,13 +81,13 @@ class EntityWorkflowManager
|
||||
*
|
||||
* @throws HandlerWithPublicViewNotFoundException if no handler with public view is found
|
||||
*/
|
||||
public function renderPublicView(EntityWorkflowSend $entityWorkflowSend): string
|
||||
public function renderPublicView(EntityWorkflowSend $entityWorkflowSend, EntityWorkflowViewMetadataDTO $metadata): string
|
||||
{
|
||||
$entityWorkflow = $entityWorkflowSend->getEntityWorkflowStep()->getEntityWorkflow();
|
||||
|
||||
foreach ($this->handlers as $handler) {
|
||||
if ($handler instanceof EntityWorkflowWithPublicViewInterface && $handler->supports($entityWorkflow)) {
|
||||
return $handler->renderPublicView($entityWorkflowSend);
|
||||
return $handler->renderPublicView($entityWorkflowSend, $metadata);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,6 +12,7 @@ declare(strict_types=1);
|
||||
namespace Chill\MainBundle\Workflow;
|
||||
|
||||
use Chill\MainBundle\Entity\Workflow\EntityWorkflowSend;
|
||||
use Chill\MainBundle\Workflow\Templating\EntityWorkflowViewMetadataDTO;
|
||||
|
||||
interface EntityWorkflowWithPublicViewInterface
|
||||
{
|
||||
@@ -20,5 +21,5 @@ interface EntityWorkflowWithPublicViewInterface
|
||||
*
|
||||
* The public view must be a safe html string
|
||||
*/
|
||||
public function renderPublicView(EntityWorkflowSend $entityWorkflowSend): string;
|
||||
public function renderPublicView(EntityWorkflowSend $entityWorkflowSend, EntityWorkflowViewMetadataDTO $metadata): string;
|
||||
}
|
||||
|
@@ -0,0 +1,27 @@
|
||||
<?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\Templating;
|
||||
|
||||
/**
|
||||
* This is a DTO to give some metadata about the vizualisation of the
|
||||
* EntityWorkflowView.
|
||||
*
|
||||
* The aim is to give some information from the controller which show the public view and the
|
||||
* handler which will render the view.
|
||||
*/
|
||||
final readonly class EntityWorkflowViewMetadataDTO
|
||||
{
|
||||
public function __construct(
|
||||
public int $viewsCount,
|
||||
public int $viewsRemaining,
|
||||
) {}
|
||||
}
|
Reference in New Issue
Block a user