我正在寻找将 BaseMediaBundle 覆盖为自定义,例如函数“configureListFields”。
我已经覆盖了这个包的控制器,但不是 BaseMediaAdmin。
此代码的问题是我的仪表板中的实体“媒体”消失了!
//在我的 services.xml 中:
<service id="sonata.media.admin.media" class="Application\Sonata\MediaBundle\Admin\MediaAdmin">
<tag name="sonata.media.admin" manager_type="orm" group="Gestion des médias"
label="Média" />
<argument />
<argument>Application\Sonata\MediaBundle\Entity\Media</argument>
<argument>Application\SonataMediaBundle:MediaAdmin</argument>
<call method="setTranslationDomain">
<argument>SonataMediaBundle</argument>
</call>
</service>
//在我的应用程序\奏鸣曲\MediaBundle\Admin\MediaAdmin
namespace Application\Sonata\MediaBundle\Admin;
use Sonata\AdminBundle\Admin\Admin;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Sonata\AdminBundle\Route\RouteCollection;
use Sonata\MediaBundle\Provider\Pool;
use Sonata\MediaBundle\Form\DataTransformer\ProviderDataTransformer;
use Knp\Menu\ItemInterface as MenuItemInterface;
use Sonata\MediaBundle\Admin\BaseMediaAdmin as BaseMediaAdmin;
class MediaAdmin extends BaseMediaAdmin
{
/**
* {@inheritdoc}
*/
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
// ->add('image', 'string', array('template' => 'SonataMediaBundle:MediaAdmin:list_image.html.twig'))
->add('custom', 'string', array('template' => 'SonataMediaBundle:MediaAdmin:list_custom.html.twig'))
->add('enabled', 'boolean', array('editable' => true))
->add('_action', 'actions', array(
'actions' => array(
'view' => array(),
'edit' => array(),
'delete' => array(),
)
))
;
}
}
如果有人有想法?谢谢你的帮助