elao/rest-action-bundle
Symfony bundle adding ready-to-use REST actions (CRUD plus listing) designed to integrate with ElaoAdminBundle. Install via Composer, register the bundle, and configure the serializer (e.g., JMS) to quickly expose admin-friendly REST endpoints.
Installation
Add the bundle to your composer.json:
composer require elao/rest-action-bundle
Enable it in config/bundles.php:
Elao\RestActionBundle\ElaoRestActionBundle::class => ['all' => true],
First Use Case
Extend a Symfony form type (e.g., AdminBundle's entity form) with REST actions:
use Elao\RestActionBundle\Form\Type\RestActionType;
$builder->add('actions', RestActionType::class, [
'actions' => [
'edit' => ['route' => 'admin_entity_edit', 'icon' => 'pencil'],
'delete' => ['route' => 'admin_entity_delete', 'icon' => 'trash'],
],
]);
Template Integration Render actions in Twig:
{{ form_row(form.actions) }}
AdminBundle Extension
Override AdminBundle's base templates (e.g., ElaoAdminBundle:CRUD:index.html.twig) to include:
{% block actions %}
{{ form_row(form.actions) }}
{% endblock %}
Dynamic Action Configuration Fetch actions from a service or database:
$actions = $this->get('elao_rest_action.action_provider')->getActions($entity);
$builder->add('actions', RestActionType::class, ['actions' => $actions]);
Route-Based Actions
Define routes in routing.yml:
admin_entity_edit:
path: /admin/entity/{id}/edit
methods: [GET, POST]
Event-Driven Customization
Subscribe to elao_rest_action.build_actions event to modify actions dynamically:
$dispatcher->addListener('elao_rest_action.build_actions', function (BuildActionsEvent $event) {
$event->addAction('custom', ['route' => 'custom_route']);
});
Deprecation Risk Last release in 2015—assess compatibility with modern Symfony (5.4+/Laravel 9+). May require patches or forks.
AdminBundle Dependency
Requires elao/admin-bundle (not Laravel-native). Adapt templates/routes to Laravel conventions if needed.
Twig Template Overrides
Ensure template paths align with AdminBundle's structure. Use {% extends %} correctly to avoid missing blocks.
Action Not Rendering? Verify:
{{ form_row(form.actions) }}.CSRF Issues
If using POST actions, ensure _csrf_token is included in forms (Symfony’s default behavior).
Custom Action Types
Extend Elao\RestActionBundle\Form\Type\RestActionType to support new action formats (e.g., buttons with modals).
Permission Handling Integrate with Symfony’s security system:
if (!$this->isGranted('ROLE_ADMIN')) {
unset($actions['delete']);
}
Laravel Adaptation
AdminBundle templates with Laravel Blade.admin_entity_edit routes.elao_rest_action.action_provider with a Laravel service provider.How can I help you explore Laravel packages today?