Show Action Show View

<?php

    namespace Showcase\Action\Demo\Events;
    
    
    use ObjectivePHP\Application\Action\RenderableAction;
    use ObjectivePHP\Application\ApplicationInterface;
    use ObjectivePHP\Application\Workflow\Hook;
    use ObjectivePHP\Application\Workflow\Step;
    use Showcase\Application;

    /**
     * Class Workflow
     *
     * @package Showcase\Action\Demo\Events
     */
    class Workflow extends RenderableAction
    {

        /**
         * Run the action
         *
         * @var $app Application
         *
         */
        public function run(ApplicationInterface $app)
        {


            $hooks = $app->getSteps();
            $workflow = [];
            $hooks->each(function (Step $hook) use (&$workflow, $app)
            {
                $workflow[$hook->getName()] = [];
                $currentStep                = &$workflow[$hook->getName()];

                    $hook->each(function (Hook $hook, $alias) use(&$currentStep, $app)
                {
                    if(is_int($alias)) $alias = 'unaliased';
                    $currentStep[] = $alias . ': ' . $hook->getMiddleware()->getDescription();
                });


            });

            return
                [
                    'page.title'    => 'Workflow steps',
                    'workflow'  => $workflow
                ];
        }

    }
<?php
    use ObjectivePHP\Application\View\Helper\Vars;
    use ObjectivePHP\Html\Tag\Tag;
    use ObjectivePHP\Primitives\Collection\Collection;

?>

Below is the tree of default ObjectivePHP/Application workflow events.
<br/><br/>
<?php
    $workflow = Vars::collection('workflow');

?>

<div class="panel panel-default">
    <!-- Default panel contents -->
    <div class="panel-heading"><?= Vars::get('page.title') ?></div>
    <div class="panel-body">
        <p>
            The steps below are the actual steps of the current workflow. This is a fully dynamic table, generated
            from the actual workflow running the page.
        </p>
    </div>

    <!-- Table -->
    <table class="table table-striped">
        <thead>
        <tr>
            <th>Hook</th>
            <th>MiddleWare</th>
        </tr>
        </thead>
        <tbody>
        <?php

            $workflow->each(function ($middleWares, $hook)
            {
                Tag::tr(Tag::td(Tag::strong($hook))->addAttribute('colspan', 2));


                if (!$middleWares)
                {
                    $middleWares[] = 'No Hook has been plugged here';
                }

                Collection::cast($middleWares)->each(function ($middleWare)
                {
                    Tag::tr([Tag::td(), Tag::td($middleWare)]);

                })
                ;

            });


        ?>
        </tbody>
    </table>
</div>
Below is the tree of default ObjectivePHP/Application workflow events.

Workflow steps

The steps below are the actual steps of the current workflow. This is a fully dynamic table, generated from the actual workflow running the page.

Hook MiddleWare
init
request-wrapper: Middleware ObjectivePHP\Application\Operation\RequestWrapper
response-initializer: Middleware embedding Instance of callable class ObjectivePHP\Application\Operation\ResponseInitializer
bootstrap
service-loader: Middleware embedding Invokable class ObjectivePHP\Application\Operation\ServiceLoader
unaliased: Middleware embedding Closure defined in file "/var/www/html/showcase/app/src/Application.php" on line 62
route
router: Middleware ObjectivePHP\Router\MetaRouter
action
unaliased: Middleware ObjectivePHP\Router\Dispatcher
rendering
unaliased: Middleware embedding Invokable class Showcase\Middleware\LayoutSwitcher
unaliased: Middleware embedding Closure defined in file "/var/www/html/showcase/app/src/Application.php" on line 75
unaliased: Middleware embedding Invokable class Showcase\Package\ShowSource\ShowSourcePackage
view-resolver: Middleware ObjectivePHP\Application\Operation\ViewResolver
view-renderer: Middleware ObjectivePHP\Application\Operation\ViewRenderer
end
unaliased: Middleware embedding Instance of callable class ObjectivePHP\Application\Operation\ResponseSender