PHP code example of attia-ahmed / extendable-action

1. Go to this page and download the library: Download attia-ahmed/extendable-action library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

attia-ahmed / extendable-action example snippets


App\Providers\ExtendableActionAppServiceProvider::class,

class ExampleExtendableAction extends ExtendableAction
{
    public function run($name)
    {
        return "Hello " . $name;
    }
}

class ExampleFilter extends Filter
{
    public function apply(array $args): array
    {
        $args["name"] = "Mr. " . $args["name"];
        return $args;
    }
}

class ExampleAction extends Action
{
    public function apply($result)
    {
        return "<h1>{$result}</h1>";
    }
}

   protected array $extendable_actions = [

        ExampleExtendableAction::class => [
            "filters" => [
                ExampleFilter::class
            ],
            "actions" => [
                ExampleAction::class
            ]
        ],
    ];

//RECOMMENDED so it automatically be executed it while injecting its dependencies
$result = app(ExampleExtendableAction::class)(...$args);

$result = (new ExampleExtendableAction())(...$args);

class ExampleExtendedQueueableAction extends ExtendableAction
{
    use QueueableAction;
    
    public function run(Example1 $example1, Example2 $example2)
    {
        //custom logic happen in queue
        return $result;
    }
}

app(ExampleExtendedQueueableAction::class)()->onQueue()->execute($example1, $example2);
bash
php artisan vendor:publish --tag="extendable-action-provider"