Skip to content
Discussion options

You must be logged in to vote

Here is how you would do that. Here is some example middleware.

<?php

declare(strict_types=1);

namespace App\Workflows\Simple;

class SimpleMiddleware
{
    public function handle($job, $next): void
    {
        $next($job);
    }
}

And here is our activity.

<?php

declare(strict_types=1);

namespace App\Workflows\Simple;

use Workflow\Activity;

class SimpleActivity extends Activity
{
    public function middleware()
    {
        $middleware = parent::middleware();
        array_splice($middleware, 1, 0, [SimpleMiddleware::class]);
        return $middleware;
    }

    public function execute()
    {
        return 'activity';
    }
}

The array_splice() will put the middleware in …

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by franck-grenier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants