zicht / admin-bundle
Admin utilities for Symfony
Installs: 28 985
Dependents: 4
Suggesters: 0
Security: 0
Stars: 3
Watchers: 2
Forks: 0
Open Issues: 3
Type:symfony-bundle
Requires
- php: ^8
- sonata-project/doctrine-orm-admin-bundle: ^4
- symfony/console: ^6.4
- symfony/yaml: ^6.4
- twig/twig: ^2.13 || ^3
- zicht/framework-extra-bundle: ^11
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3
- phpunit/phpunit: ^9.1
- vimeo/psalm: ^5.16
- zicht/page-bundle: ^9.x-dev
- zicht/url-bundle: ^8.x-dev
- dev-release/9.x
- dev-release/8.x
- 9.0.0
- 8.1.6
- 8.1.5
- 8.1.4
- 8.1.3
- 8.1.2
- 8.1.1
- 8.1.0
- 8.0.4
- 8.0.3
- 8.0.2
- 8.0.1
- 8.0.0
- 7.0.5
- 7.0.4
- 7.0.3
- 7.0.2
- 7.0.1
- 7.0.0
- 6.3.8
- 6.3.7
- 6.3.6
- 6.3.5
- 6.3.4
- 6.3.3
- 6.3.2
- 6.3.1
- 6.3.0
- 6.2.2
- 6.2.1
- 6.2.0
- 6.1.2
- 6.1.1
- 6.1.0
- 6.0.4
- 6.0.3
- 6.0.2
- 6.0.1
- 6.0.0
- 5.2.4
- 5.2.3
- 5.2.2
- 5.2.1
- 5.2.0
- 5.1.2
- 5.1.1
- 5.1.0
- 5.0.10
- 5.0.9
- 5.0.8
- 5.0.7
- 5.0.6
- 5.0.5
- 5.0.4
- 5.0.3
- 5.0.2
- 5.0.1
- 5.0.0
- 4.1.1
- 4.1.0
- 4.0.4
- 4.0.3
- 4.0.2
- 4.0.1
- 4.0.0
- 3.5.8
- 3.5.7
- 3.5.6
- 3.5.5
- 3.5.4
- 3.5.3
- 3.5.2
- 3.5.1
- 3.5.0
- 3.4.9
- 3.4.7
- 3.4.6
- 3.4.5
- 3.4.4
- 3.4.3
- 3.4.2
- 3.4.1
- 3.4.0
- 3.3.7
- 3.3.6
- 3.3.5
- 3.3.4
- 3.3.3
- 3.3.2
- 3.3.1
- 3.3.0
- 3.2.2
- 3.2.1
- 3.2.0
- 3.1.0
- 3.0.0
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.0
- 2.1.1
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.7.0
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.2.2
- 1.2.1
- 1.1.3
- 1.1.2
- 1.1.1
- 1.1.0
- 1.0.2
- 1.0.1
- dev-release/7.x
- dev-release/6.x
- dev-release/5.x
- dev-release/4.x
- dev-release/3.x
- dev-feature-Fabrique-branding
This package is auto-updated.
Last update: 2024-11-02 14:53:29 UTC
README
Provides integration utilities for SonataAdminBundle.
Enable dump-role-hierarchy
To make this command supply you with an actual list of roles, add the following to your sonata_admin.yml
:
parameters: sonata.admin.security.handler.role.class: Zicht\Bundle\AdminBundle\Security\Handler\RoleSecurityHandler sonata_admin: security: handler: sonata.admin.security.handler.role
Override Menu-events to supply other hosts
Add the following configuration to config/zicht_admin.yml
to override the AdminEvents::MENU_EVENT
and alter the url to a match in the list.
zicht_admin: menu: hosts: - site.nl.dev - site.nl.dev3.zicht.intern - a.site.nl
Duplicate entities
To duplicate an entity, add the following code:
-
In the admin of the entity you want to duplicate, add the route:
protected function configureRoutes(RouteCollectionInterface $collection): void { $collection->add('duplicate'); }
-
In
templates/bundles/SonataAdminBundle/CRUD/edit.html.twig
add the duplicate button:{% if admin.hasroute('duplicate') %} <a class="btn btn-info" href="{{ admin.generateObjectUrl('duplicate', object) }}">{{ 'admin.duplicate.text_button'|trans }}</a> {% endif %}
For an example, see https://github.com/zicht/zestor.nl/pull/155/files
Override entities
To also override the entities content (after duplication, see section above), add the following code:
- Add the route in the admin so the configureRoute method becomes:
protected function configureRoutes(RouteCollectionInterface $collection): void { $collection->add('duplicate'); $collection->add('override'); }
- In the entity create the field
copiedFrom
(and its getter and setter).#[ORM\ManyToOne(targetEntity: Page::class)] #[ORM\JoinColumn(referencedColumnName: 'id', onDelete: 'SET NULL')] private ?Page $copiedFrom;
- In the admin of the entity, add the override-button:
if ($this->getSubject()->getCopiedFrom()) { $formMapper ->tab('admin.tab.schedule_publication') ->add( 'copiedFrom', ButtonType::class, [ 'required' => false, 'help' => $this->trans('admin.help.override', ['%copied_from%' => $this->getSubject()->getCopiedFrom()]), 'buttons' => [ 'override' => [ 'label' => 'admin.override.text_button', 'style' => 'info', 'route' => 'override', ], ], ] ) ->end() ->end(); }
For an example, see https://github.com/zicht/zestor.nl/pull/155/files
Quicklist
The quicklist is an autocomplete feature. In the CMS you can place this as an extra block at the dashboard to search for entities. It is also possible to use the AutocompleteType
class in admin entities.
Configuration
In your project, create templates/admin/block_admin.html.twig
and add this:
{% extends sonata_block.templates.block_base %}
{% block block %}
{{ render(controller('Zicht\\Bundle\\AdminBundle\\Controller\\QuicklistController::quicklistAction')) }}
{% endblock %}
In config/packages/zicht/admin.yaml
you have the option to add multiple repositories to be searched through.
Example:
zicht_admin: quicklist: App\Entity\Page\BiographyPage: repository: 'App\Entity\Page\BiographyPage' # choose multiple fields to search in... fields: ['firstName', 'lastName', 'profession'] title: Bio App\Entity\Page\ArticlePage: repository: 'App\Entity\Page\ArticlePage' # ...or just one field fields: ['title'] title: Article App\Entity\Slide: repository: 'App\Entity\Slide' fields: ['title', 'internalTitle', 'image'] title: Slide # by default returns 15 results if not configured explicitly max_results: 100
Implementation example
namespace App\Admin; use App\Entity\Page\BiographyPage; use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Form\FormMapper; use Zicht\Bundle\AdminBundle\Form\AutocompleteType; class FooAdmin extends AbstractAdmin { protected function configureFormFields(FormMapper $form): void { $form ->add('somePropertyNameHere', AutocompleteType::class, [ 'repo' => BiographyPage::class, ]); } }
Maintainers
- Boudewijn Schoon boudewijn@zicht.nl