How to add custom link or button to SonataAdminBundle Dashboard in Symfony2

后端 未结 2 901
名媛妹妹
名媛妹妹 2020-12-02 08:47

I am new with symfony2 and SonataAdminBundle.

I have added 3 entities to the SonataAdminBundle Dashboard and they appear successfully.

The Entities appear w

2条回答
  •  孤城傲影
    2020-12-02 09:20

    I had troubles with method execute (I am using Sonata 2.3.x ). Here is the code that works for me.

    Note BlockContextInterface and $blockContext->getBlock() :

     public function execute(BlockContextInterface $blockContext, Response $response = null)
    {
        // merge settings
        $settings = array_merge($this->getDefaultSettings(), $blockContext->getSettings());
    
        return $this->renderResponse('bundleName:Block:templateName.html.twig', array(
            'block'     => $blockContext->getBlock(),
            'settings'  => $settings
            ), $response);
    }
    

提交回复
热议问题