【问题标题】:Unable to extend ProfileFOSUser1Controller of sonata symfony无法扩展奏鸣曲 symfony 的 ProfileFOSUser1Controller
【发布时间】:2018-06-18 06:59:44
【问题描述】:

我在 symfony sonata 管理员工作。我正在尝试扩展 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(),
    ]);
  }


 }

【问题讨论】:

    标签: symfony sonata-admin symfony-sonata sonata sonata-user-bundle


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

        猜你喜欢
        • 2018-01-09
        • 2019-07-04
        • 2020-12-09
        • 2018-10-15
        • 1970-01-01
        • 2017-08-09
        • 2015-04-20
        • 2018-02-24
        • 2018-03-22
        相关资源
        最近更新 更多