zicht / admin-bundle
Symfony 的管理工具
9.0.0
2024-05-02 13:36 UTC
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-09-02 14:26:15 UTC
README
提供与 SonataAdminBundle 集成的工具。
启用 dump-role-hierarchy
为了使此命令提供实际的角色列表,请将以下内容添加到您的 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
覆盖 Menu-events 以提供其他主机
将以下配置添加到 config/zicht_admin.yml
以覆盖 AdminEvents::MENU_EVENT
并更改 URL 以匹配列表中的项。
zicht_admin: menu: hosts: - site.nl.dev - site.nl.dev3.zicht.intern - a.site.nl
复制实体
要复制实体,请添加以下代码
-
在您想要复制的实体的管理中添加路由
protected function configureRoutes(RouteCollectionInterface $collection): void { $collection->add('duplicate'); }
-
在
templates/bundles/SonataAdminBundle/CRUD/edit.html.twig
中添加复制按钮{% if admin.hasroute('duplicate') %} <a class="btn btn-info" href="{{ admin.generateObjectUrl('duplicate', object) }}">{{ 'admin.duplicate.text_button'|trans }}</a> {% endif %}
示例请见 https://github.com/zicht/zestor.nl/pull/155/files
覆盖实体
要覆盖实体的内容(复制后,请参阅上面章节),请添加以下代码
- 在管理中添加路由,使 configureRoute 方法变为
protected function configureRoutes(RouteCollectionInterface $collection): void { $collection->add('duplicate'); $collection->add('override'); }
- 在实体中创建字段
copiedFrom
(及其 getter 和 setter)。#[ORM\ManyToOne(targetEntity: Page::class)] #[ORM\JoinColumn(referencedColumnName: 'id', onDelete: 'SET NULL')] private ?Page $copiedFrom;
- 在实体的管理中添加覆盖按钮
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(); }
示例请见 https://github.com/zicht/zestor.nl/pull/155/files
快速列表
快速列表是一个自动完成功能。在 CMS 中,您可以将此作为额外的块放置在仪表板上以搜索实体。还可以在管理实体中使用 AutocompleteType
类。
配置
在您的项目中创建 templates/admin/block_admin.html.twig
并添加以下内容
{% extends sonata_block.templates.block_base %}
{% block block %}
{{ render(controller('Zicht\\Bundle\\AdminBundle\\Controller\\QuicklistController::quicklistAction')) }}
{% endblock %}
在 config/packages/zicht/admin.yaml
中,您可以选择添加多个要搜索的仓库。
示例
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
实现示例
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, ]); } }
维护者
- Boudewijn Schoon boudewijn@zicht.nl