无法扩展 sonata symfony 的 ProfileFOSUser1Controller

Unable to extend ProfileFOSUser1Controller of sonata symfony

我在 symfony sonata admin 工作。我正在尝试扩展 ProfileFOSUser1Controller 但无法扩展它。我也尝试过清除缓存但没有用?这是我的控制器代码:

<?php

  namespace Application\Sonata\UserBundle\Controller;

  use Sonata\UserBundle\Controller\ProfileFOSUser1Controller as BaseController;
 /**
 * Overwrite methods from the ProfileFOSUser1Controller if you want to change the behavior
 * for the current profile
 *
 */

 class ProfileUserController extends BaseController
 {


  /**
  * @throws AccessDeniedException
  *
  * @return Response|RedirectResponse
  */
  public function editAuthenticationAction()
  {
    echo "here"; die;
    $user = $this->getUser();
    if (!is_object($user) || !$user instanceof UserInterface) {
        throw new AccessDeniedException('This user does not have access to this section.');
    }

    $form = $this->get('sonata.user.authentication.form');
    $formHandler = $this->get('sonata.user.authentication.form_handler');

    $process = $formHandler->process($user);
    if ($process) {
        $this->setFlash('sonata_user_success', 'profile.flash.updated');

        return $this->redirect($this->generateUrl('sonata_user_profile_show'));
    }

    return $this->render('SonataUserBundle:Profile:edit_authentication.html.twig', [
        'form' => $form->createView(),
    ]);
  }


 }

看这里How to Use Bundle Inheritance to Override Parts of a Bundle 我认为您的控制器名称应该是 ProfileFOSUser1Controller

此问题已解决,我已将 class 名称更改为与基 class 相同的名称:已将 "ProfileUserController" 更改为 "ProfileFOSUser1Controller"。现在它工作正常。