Minor - flint fixes

pull/3064/head
Julio Montoya 5 years ago
parent 10c0b1f3d8
commit 8858cc49c0
  1. 19
      src/CoreBundle/Controller/AccountController.php
  2. 4
      src/CoreBundle/Controller/UserController.php
  3. 1
      src/CoreBundle/Framework/Container.php
  4. 4
      src/CoreBundle/Repository/IllustrationRepository.php
  5. 1
      src/CoreBundle/Resources/config/routing.yml

@ -3,8 +3,8 @@
namespace Chamilo\CoreBundle\Controller;
use Chamilo\CoreBundle\Repository\IllustrationRepository;
use Chamilo\ThemeBundle\Model\UserInterface;
use Chamilo\UserBundle\Entity\User;
use Chamilo\UserBundle\Form\ProfileType;
use Chamilo\UserBundle\Repository\UserRepository;
use FOS\UserBundle\Model\UserManagerInterface;
@ -35,14 +35,12 @@ class AccountController extends BaseController
*
* @param string $username
*/
public function editAction(Request $request, UserManagerInterface $userManager, TranslatorInterface $translator)
public function editAction(Request $request, UserManagerInterface $userManager, TranslatorInterface $translator, IllustrationRepository $illustrationRepository)
{
$user = $this->getUser();
if (!is_object($user) || !$user instanceof UserInterface) {
throw $this->createAccessDeniedException(
'This user does not have access to this section'
);
throw $this->createAccessDeniedException('This user does not have access to this section');
}
$form = $this->createForm(ProfileType::class, $user);
@ -51,7 +49,14 @@ class AccountController extends BaseController
$form->handleRequest($request);
if ($form->isSubmitted() && $form->isValid()) {
//$event = new FormEvent($form, $request);
$illustration = $form['illustration']->getData();
if ($illustration) {
$file = $illustrationRepository->addIllustration($resource, $this->getUser(), $illustration);
$em = $illustrationRepository->getEntityManager();
$em->persist($file);
$em->flush();
}
$userManager->updateUser($user);
$this->addFlash('success', $translator->trans('Updated'));
@ -61,6 +66,6 @@ class AccountController extends BaseController
return $response;
}
return $this->render('@ChamiloCore/Account/edit.html.twig', ['form' => $form->createView()]);
return $this->render('@ChamiloCore/Account/edit.html.twig', ['form' => $form->createView(), 'user' => $user]);
}
}

@ -26,9 +26,7 @@ class UserController extends BaseController
$user = $userRepository->findByUsername($username);
if (!is_object($user) || !$user instanceof UserInterface) {
throw $this->createAccessDeniedException(
'This user does not have access to this section'
);
throw $this->createAccessDeniedException('This user does not have access to this section');
}
return $this->render('@ChamiloCore/User/profile.html.twig', ['user' => $user]);

@ -134,6 +134,7 @@ class Container
if (isset(self::$container)) {
return self::$container->get('kernel')->getRealRootDir();
}
return str_replace('\\', '/', realpath(__DIR__.'/../../../')).'/';
}

@ -19,6 +19,10 @@ class IllustrationRepository extends ResourceRepository
*/
public function addIllustration(AbstractResource $resource, User $user, $uploadFile): ?ResourceFile
{
if (null === $uploadFile) {
return null;
}
$illustrationNode = $this->getIllustrationNodeFromResource($resource);
$em = $this->getEntityManager();

@ -1,4 +1,3 @@
legacy_main:
path: /main/{name}
defaults: {_controller: 'ChamiloCoreBundle:Legacy:classic'}

Loading…
Cancel
Save