Remove Managers (avoid double classes), use Resource repositories

pull/3016/head
Julio Montoya 5 years ago
parent b75c6edda0
commit 32701bfe8d
  1. 4
      src/CoreBundle/Entity/Tool.php
  2. 8
      src/CoreBundle/Repository/ResourceRepository.php
  3. 11
      src/CoreBundle/Security/Authorization/Voter/GroupVoter.php
  4. 8
      src/CourseBundle/Repository/CAnnouncementRepository.php
  5. 9
      src/CourseBundle/Repository/CGroupInfoRepository.php
  6. 22
      src/CourseBundle/Resources/config/services.yml
  7. 4
      src/GraphQlBundle/Resolver/CourseResolver.php

@ -72,8 +72,8 @@ class Tool
{
$this->toolResourceRight = new ArrayCollection();
foreach ($toolResourceRight as $toolResourceRight) {
$this->addToolResourceRight($toolResourceRight);
foreach ($toolResourceRight as $item) {
$this->addToolResourceRight($item);
}
}

@ -435,4 +435,12 @@ class ResourceRepository extends EntityRepository
->getRepository('ChamiloCoreBundle:Tool')
->findOneBy(['name' => $tool]);
}
/**
* @return mixed
*/
public function create()
{
return new $this->className;
}
}

@ -3,15 +3,12 @@
namespace Chamilo\CoreBundle\Security\Authorization\Voter;
use Chamilo\CoreBundle\Entity\Manager\CourseManager;
use Chamilo\CoreBundle\Repository\CourseRepository;
use Chamilo\CourseBundle\Entity\CGroupInfo;
use Chamilo\CourseBundle\Entity\Manager\GroupManager;
use Chamilo\UserBundle\Entity\User;
use Chamilo\CourseBundle\Repository\CGroupInfoRepository;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
use Symfony\Component\Security\Core\User\UserInterface;
@ -35,15 +32,15 @@ class GroupVoter extends Voter
/**
* @param EntityManager $entityManager
* @param CourseManager $courseManager
* @param GroupManager $groupManager
* @param CourseRepository $courseManager
* @param CGroupInfoRepository $groupManager
* @param AuthorizationCheckerInterface $authorizationChecker
* @param ContainerInterface $container
*/
public function __construct(
EntityManager $entityManager,
CourseRepository $courseManager,
GroupManager $groupManager,
CGroupInfoRepository $groupManager,
AuthorizationCheckerInterface $authorizationChecker,
ContainerInterface $container
) {

@ -1,18 +1,18 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Entity\Manager;
namespace Chamilo\CourseBundle\Repository;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Repository\ResourceRepository;
use Chamilo\CourseBundle\Entity\CGroupInfo;
use Chamilo\UserBundle\Entity\User;
use Sonata\Doctrine\Entity\BaseEntityManager;
/**
* Class AnnouncementManager.
* Class CAnnouncementRepository.
*/
class AnnouncementManager extends BaseEntityManager
final class CAnnouncementRepository extends ResourceRepository
{
/**
* @param User $user

@ -1,16 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Entity\Manager;
namespace Chamilo\CourseBundle\Repository;
use Chamilo\CoreBundle\Repository\ResourceRepository;
use Chamilo\CourseBundle\Entity\CGroupInfo;
use Sonata\Doctrine\Entity\BaseEntityManager;
/**
* Class CourseManager.
*
* Class CGroupInfoRepository.
*/
class GroupManager extends BaseEntityManager
final class CGroupInfoRepository extends ResourceRepository
{
/**
* @return CGroupInfo

@ -16,28 +16,30 @@ services:
tags: ['doctrine.repository_service']
# Entity repository as a service
Chamilo\CourseBundle\Repository\CAnnouncementRepository:
arguments:
$className: 'Chamilo\CourseBundle\Entity\CExerciseCategory'
Chamilo\CourseBundle\Repository\CDocumentRepository:
arguments:
$className: 'Chamilo\CourseBundle\Entity\CDocument'
Chamilo\CourseBundle\Repository\CGroupInfoRepository:
arguments:
$className: 'Chamilo\CourseBundle\Entity\CGroupInfo'
Chamilo\CourseBundle\Repository\CQuizRepository:
arguments:
$className: 'Chamilo\CourseBundle\Entity\CQuiz'
Chamilo\CourseBundle\Repository\CQuizQuestionCategoryRepository:
arguments:
$className: 'Chamilo\CourseBundle\Entity\CQuizQuestionCategory'
Chamilo\CourseBundle\Repository\CExerciseCategoryRepository:
arguments:
$className: 'Chamilo\CourseBundle\Entity\CExerciseCategory'
# Managers
chamilo_course.entity.manager.group_manager:
class: 'Chamilo\CourseBundle\Entity\Manager\GroupManager'
arguments: ['Chamilo\CourseBundle\Entity\CGroupInfo', '@doctrine']
chamilo_course.entity.manager.announcement_manager:
class: 'Chamilo\CourseBundle\Entity\Manager\AnnouncementManager'
arguments: ['Chamilo\CourseBundle\Entity\CAnnouncement', '@doctrine']
# Event Listeners
chamilo_course.listener.course:
class: Chamilo\CourseBundle\EventListener\CourseListener
@ -74,7 +76,7 @@ services:
arguments:
- '@doctrine.orm.entity_manager'
- '@Chamilo\CoreBundle\Repository\CourseRepository'
- '@chamilo_course.entity.manager.group_manager'
- '@Chamilo\CourseBundle\Repository\CGroupInfoRepository'
- '@security.authorization_checker'
- '@service_container'
public: false

@ -24,8 +24,6 @@ use Symfony\Component\DependencyInjection\ContainerAwareInterface;
/**
* Class CourseResolver.
*
* @package Chamilo\GraphQlBundle\Resolver
*/
class CourseResolver implements ContainerAwareInterface
{
@ -167,7 +165,7 @@ class CourseResolver implements ContainerAwareInterface
*/
public function getAnnouncements(CTool $tool, \ArrayObject $context): array
{
$announcementManager = $this->container->get('chamilo_course.entity.manager.announcement_manager');
$announcementManager = $this->container->get('Chamilo\CourseBundle\Repository\CAnnouncementRepository');
$announcementsInfo = $announcementManager->getAnnouncements(
$this->getCurrentUser(),
$tool->getCourse(),

Loading…
Cancel
Save