我正在寻找将BaseMediaBundle覆盖为自定义,例如“configureListFields”函数。
我已经覆盖了此捆绑包的控制器,但没有覆盖BaseMediaAdmin。
此代码的问题是我的信息中心实体“Media”消失了!
//在我的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>
//在我的Application \ Sonata \ 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(),
)
))
;
}
}
如果有人有想法?谢谢你的帮助