관리자 패널을 신속하게 구현하려는 경우 SonataAdminBundle을 살펴볼 필요가 있습니다.
당신은 작곡가 & 가져 오기를 통해 어떤 경로를 설치하고 거기에서, 당신의 Products
, News
및 Article
개체를 참조하는 클래스는 관리 서비스를 정의의 문제, 그리고.
확장 성이 좋기 때문에 &을 설치하는 것이 좋습니다. 또한 필터 양식 외에도 하나의 관리 인터페이스를 다른 상자에 즉시 내장하고 엔티티 단위로 라우트를 활성화/비활성화함으로써 엔티티 간의 관계를 처리 할 수 있습니다. 또한 나뭇 가지 템플릿은 슈퍼 모듈 식이며 쉽게 재정의 할 수 있습니다. 당신이 SonataAdmin를 설치 한 후
(ORM을 가정) 빠른 예를 들어
, 서비스 정의에 추가합니다 (Sonata Admin Docs에서 가져온 예.)
services:
sonata.admin.pprodut:
class: Acme\DemoBundle\Admin\ProductAdmin
tags:
- { name: sonata.admin, manager_type: orm, group: "Content", label: "Product" }
arguments:
- ~
- Acme\DemoBundle\Entity\Product
- ~
...와 일치하는 ProductAdmin
클래스 .
<?php
// src/Acme/DemoBundle/Admin/ProductAdmin.php
namespace Acme\DemoBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Form\FormMapper;
class ProductAdmin extends Admin
{
// Fields to be shown on create/edit forms
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('title', 'text', array('label' => 'Product Title'))
->add('sku', 'text')
->add('description') //if no type is specified, SonataAdminBundle tries to guess it
// Other fields ...
;
}
// Fields to be shown on filter forms
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('title')
->add('sku')
;
}
// Fields to be shown on lists
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('title')
->add('sku')
;
}
}
그리고 경기가 끝났습니다.
그러나 휠체어를 재창조하기보다는 연습용으로 사용하면 SonataAdmin을 멋진 참조 번들로 사용할 수 있습니다. :)