tv2regionerne / statamic-events
Requires
- php: ^8.2
- pixelfear/composer-dist-plugin: ^0.1.5
- spatie/laravel-activitylog: ^4.7
- statamic/cms: ^4.46 || ^5.0
Requires (Dev)
- laravel/pint: ^1.13
- mockery/mockery: ^1.3.1
- nunomaduro/collision: ^6.0 || ^7.0
- orchestra/testbench: ^7.0 || ^8.0
- pestphp/pest: ^2.24
- phpunit/phpunit: ^9.0 || ^10.0
- dev-main
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- dev-feature/exception-on-error
- dev-feature/trigger-event-button
- dev-fix/api-issues
- dev-feature/add-sample-response-handler
- dev-feature/throw-exception-on-fail
- dev-fix/tidy-email-driver
- dev-fix/bug-fixes-changes
- dev-feature/initial-version
This package is auto-updated.
Last update: 2024-10-25 19:03:24 UTC
README
Statamic Events is a Statamic addon that lets you run actions when events are triggered.
How to Install
Run the following command from your project root:
composer require tv2regionerne/statamic-events
Configuration
A configuration file can be published by running the following command:
php artisan vendor:publish --tag=statamic-events
This will create statamic-events
in your config folder.
Extra events
By default this add-on will list events in the Statamic\Events namespace, but you can change this or configure other events to be listed by modifying the statamic-events.events
config. This should be a list of folders relative to the base folder, keyed by their namespace.
After changing this config, you should run php artisan cache:clear
.
Response handlers
Each driver allows you to specify response_handlers
which can be used to run any additional processing. This should be an array of unique keys to fully qualified class names, eg ['my_key' => '\App\Handlers\MyHandler::class']
A handler is a class containing a handle method:
class MyHandler { public function handle(array $config, string $eventName, mixed $event, mixed $response = null) { // run some logic // you may want to $execution->log(string $message, array $data) something } }
API
This add-on integrates with the Private API addon to provide an end point for managing handlers. The following endpoints are available:
Viewing all handlers:
GET {base}/statamic-events/handlers
View an individual handler:
GET {base}/statamic-events/handlers/{id}
Add a new handler:
POST {base}/statamic-events/handlers
Update an individual handler:
PATCH {base}/statamic-events/handlers/{id}
Delete a handler
DELETE {base}/statamic-events/handlers/{id}