Name: ElaoHtmlActionBundle
Owner: Elao
Description: Classic HTML actions for ElaoAdminBundle
Created: 2015-02-19 16:35:43.0
Updated: 2016-11-08 10:23:13.0
Pushed: 2017-02-05 13:16:36.0
Homepage: null
Size: 39
Language: PHP
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This bundle provides CRUD + List Actions to be used with ElaoAdminBundle
Require the bundle in Composer:
mposer require elao/html-action-bundle
Install the bundle in your AppKernel:
p
pp/AppKernel.php
ic function registerBundles()
$bundles = array(
//...
// ElaoHtmlActionBundle requires ElaoAdminBundle, you'll need to register it too.
// new Elao\Bundle\ElaoAdminBundle\ElaoAdminBundle(),
new Elao\Bundle\HtmlActionBundle\ElaoHtmlActionBundle(),
);
The HtmlActionBundle provides 5 actions for the AdminBundle:
Here's how you define a simple CRUD administration for a “Post” entity.
_admin:
administrations:
# Administration, named after the model, will impact urls and route names
post:
# The repository service for the Post model (usually DoctrineRepository for model "Post")
repository: blog.repository.post
# The list of actions
actions:
list:
# We're using default values for the list
html_list: ~
create:
html_create:
# Specify the form type to use to create a Post
form: BlogBundle\Form\PostType
update:
html_update:
# Specify the form type to use to edit a Post
form: BlogBundle\Form\PostType
read:
# We're using default values for the read
html_read: ~
delete:
html_delete:
# We're adding a security restriction on the delete action
security: has_role('ROLE_ADMIN')
Don't forget to declare the corresponding repository service:
(extends elao_admin.repository.doctrine
/Elao\Bundle\AdminBundle\Service\DoctrineRepository
or use your own implementation of Elao\Bundle\AdminBundle\Behaviour\RepositoryInterface
)
rvices.yml
.repository.post:
parent: elao_admin.repository.doctrine
arguments: ['BlogBundle\Entity\Post']
List
| Parameter | Description | Required | Default value |
| ——— | ————- | ——– | ————- |
| view
| The template to render the page with. | false | :post:list.html.twig
|
| view_parameter
| The variable name of the model or list of model in the template. | false | posts
|
Create
| Parameter | Description | Required | Default value |
| ——— | ————- | ——– | ————- |
| form
| The form type to use to create the model. | true | |
| view
| The template to render the page with. | false | :post:create.html.twig
|
| view_parameter
| The variable name of the model or list of model in the template. | false | post
|
| redirection
| The action to redirect the user to when the action has been performed. | false | list
|
Read
| Parameter | Description | Required | Default value |
| ——— | ————- | ——– | ————- |
| view
| The template to render the page with. | false | :post:update.html.twig
|
| view_parameter
| The variable name of the model or list of model in the template. | false | post
|
Update
| Parameter | Description | Required | Default value |
| ——— | ————- | ——– | ————- |
| form
| The form type to use to create the model. | true | |
| view
| The template to render the page with. | false | :post:update.html.twig
|
| view_parameter
| The variable name of the model or list of model in the template. | false | post
|
| redirection
| The action to redirect the user to when the action has been performed. | false | list
|
Delete
| Parameter | Description | Required | Default value |
| ——— | ————- | ——– | ————- |
| form
| The form type to use to create the model. | false | Elao\Bundle\HtmlActionBundle\Form\Type\DeleteType
|
| view
| The template to render the page with. | false | :post:delete.html.twig
|
| view_parameter
| The variable name of the model or list of model in the template. | false | post
|
| redirection
| The action to redirect the user to when the action has been performed. | false | list
|
Please note that the views are not provided with the bundle. You have to create them to display the different forms.
Default path for the views is app/Resources/[name]/[alias].html.twig
.
You can override this by setting an explicit view in action's options.
For convenience, you can use AdminBundle's DoctrineRepository as the default doctrine repository.
This way the Doctrine entity manager's getRepository
method will return the repository service declared for each model.
To activate this feature:
nfig.yml
_admin:
doctrine_service_repositories: true
rine:
default_repository_class: Elao\Bundle\AdminBundle\Service\DoctrineRepository
repository_factory: elao_admin.repository_factory.doctrine