diff --git a/config/packages/chamilo.yaml b/config/packages/chamilo.yaml deleted file mode 100644 index 45c95749f7..0000000000 --- a/config/packages/chamilo.yaml +++ /dev/null @@ -1,93 +0,0 @@ -services: - # default configuration for services in *this* file - _defaults: - # automatically injects dependencies in your services - autowire: true - # automatically registers your services as commands, event subscribers, etc. - autoconfigure: true - # this means you cannot fetch services directly from the container via $container->get() - # if you need to do this, you can override this setting on individual services - public: true - bind: - $passwordEncrypt: '%password_encryption%' - - # makes classes in src/ available to be used as services - # this creates a service per class whose id is the fully-qualified class name - AdminBundle\: - resource: '../../src/AdminBundle/*' - # you can exclude directories or files - # but if a service is unused, it's removed anyway - exclude: '../../src/AdminBundle/{ChamiloAdminBundle.php,Entity,Repository,Tests}' - - ClassificationBundle\: - resource: '../../src/ClassificationBundle/*' - # you can exclude directories or files - # but if a service is unused, it's removed anyway - exclude: '../../src/ClassificationBundle/{ChamiloClassificationBundle.php,Entity,Admin,Document,Repository,Tests}' - - ContactBundle\: - resource: '../../src/ContactBundle/*' - # you can exclude directories or files - # but if a service is unused, it's removed anyway - exclude: '../../src/ContactBundle/{ChamiloContactBundle.php,Entity,Admin,Controller,DependencyInjection,Form,Repository,Tests}' - - Chamilo\CoreBundle\: - resource: '../../src/CoreBundle/*' - # you can exclude directories or files - # but if a service is unused, it's removed anyway - exclude: '../../src/CoreBundle/{Admin,Block,Component,Composer,DependencyInjection,EventListener,Form,Framework,Menu,Migrations,Security,Settings,Twig,Controller,ChamiloCoreBundle.php,Entity,Repository,Tests}' - - Chamilo\CoreBundle\Controller\: - resource: '../../src/CoreBundle/Controller' - public: true - tags: ['controller.service_arguments'] - - Chamilo\UserBundle\: - resource: '../../src/UserBundle/*' - # you can exclude directories or files - # but if a service is unused, it's removed anyway - exclude: '../../src/UserBundle/{Admin,ChamiloUserBundle.php,Security/FOSUBUserProvider.php,DependencyInjection,Form,EventListener,Entity,Repository}' - - chamilo_lti_utils: - class: Chamilo\LtiBundle\Util\Utils - arguments: ['@chamilo.settings.manager'] - -# Doctrine audit -sonata_doctrine_orm_admin: - audit: - force: false # Audits are set in the admin.yml files with audit:true - -# Grid default template -#apy_data_grid: -# theme: ChamiloCoreBundle::grid.html.twig -# - -# Platform settings (new) -sylius_settings: - driver: doctrine/orm - -# Course settings -chamilo_course: - driver: doctrine/orm -# resources: -# parameter: -# classes: -# model: Chamilo\CourseBundle\Entity\CCourseSetting -# repository: Chamilo\CourseBundle\Repository\CCourseSettingRepository - -doctrine_cache: - providers: - sylius_settings: - type: file_system - chamilo_settings: - type: file_system - -gregwar_captcha: - width: 200 - height: 50 - length: 6 - -imports: - - {resource: ../../src/CoreBundle/Resources/config/services.yml} - - {resource: ../../src/PageBundle/Resources/config/services.yml} - - {resource: ../../vendor/knplabs/doctrine-behaviors/config/orm-services.yml} diff --git a/config/services.yaml b/config/services.yaml index d24a6c6a6f..9224bb4397 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -6,25 +6,15 @@ services: public: true # Allows optimizing the container by removing unused services; this also means # fetching services directly from the container via $container->get() won't work. # The best practice is to be explicit about your dependencies anyway. + bind: + $passwordEncrypt: '%password_encryption%' # makes classes in src/ available to be used as services # this creates a service per class whose id is the fully-qualified class name - - Chamilo\CoreBundle\: - resource: '../src/CoreBundle/*' - exclude: '../src/CoreBundle/{Entity,Migrations,Tests,Admin,Block,Component,Repository,Security,EventListener}' - public: true - _instanceof: Sylius\Bundle\ResourceBundle\Controller\ResourceController: autowire: false - Chamilo\CoreBundle\Controller\ResourceUploaderController: - autowire: false - - Chamilo\CoreBundle\Controller\ResourceController: - autowire: false - Chamilo\PageBundle\: resource: '../src/PageBundle/*' exclude: '../src/PageBundle/{Entity,Migrations,Tests}' @@ -46,9 +36,79 @@ services: Doctrine\ORM\EntityManager: "@doctrine.orm.default_entity_manager" + chamilo_core.hook_factory: + class: 'Chamilo\CoreBundle\Hook\HookFactory' + + # makes classes in src/ available to be used as services + # this creates a service per class whose id is the fully-qualified class name + AdminBundle\: + resource: '../src/AdminBundle/*' + # you can exclude directories or files + # but if a service is unused, it's removed anyway + exclude: '../src/AdminBundle/{ChamiloAdminBundle.php,Entity,Repository,Tests}' + + ClassificationBundle\: + resource: '../src/ClassificationBundle/*' + # you can exclude directories or files + # but if a service is unused, it's removed anyway + exclude: '../src/ClassificationBundle/{ChamiloClassificationBundle.php,Entity,Admin,Document,Repository,Tests}' + + ContactBundle\: + resource: '../src/ContactBundle/*' + # you can exclude directories or files + # but if a service is unused, it's removed anyway + exclude: '../src/ContactBundle/{ChamiloContactBundle.php,Entity,Admin,Controller,DependencyInjection,Form,Repository,Tests}' + + Chamilo\UserBundle\: + resource: '../src/UserBundle/*' + # you can exclude directories or files + # but if a service is unused, it's removed anyway + exclude: '../src/UserBundle/{Admin,ChamiloUserBundle.php,Security/FOSUBUserProvider.php,DependencyInjection,Form,EventListener,Entity,Repository}' + + chamilo_lti_utils: + class: Chamilo\LtiBundle\Util\Utils + arguments: ['@chamilo.settings.manager'] + sylius_settings: driver: doctrine/orm +# Doctrine audit +sonata_doctrine_orm_admin: + audit: + force: false # Audits are set in the admin.yml files with audit:true + +# Grid default template +#apy_data_grid: +# theme: ChamiloCoreBundle::grid.html.twig +# + +# Course settings +chamilo_course: + driver: doctrine/orm +# resources: +# parameter: +# classes: +# model: Chamilo\CourseBundle\Entity\CCourseSetting +# repository: Chamilo\CourseBundle\Repository\CCourseSettingRepository + +doctrine_cache: + providers: + sylius_settings: + type: file_system + chamilo_settings: + type: file_system + +gregwar_captcha: + width: 200 + height: 50 + length: 6 + +imports: + - {resource: ../src/CoreBundle/Resources/config/services.yml} + - {resource: ../src/PageBundle/Resources/config/services.yml} + - {resource: ../vendor/knplabs/doctrine-behaviors/config/orm-services.yml} + + #sylius_resource: # resources: # app.document: diff --git a/main/inc/global.inc.php b/main/inc/global.inc.php index 90b89d7c59..b82ff87f4d 100755 --- a/main/inc/global.inc.php +++ b/main/inc/global.inc.php @@ -2,6 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CoreBundle\Framework\Container; +use Patchwork\Utf8\Bootup; use Symfony\Component\Dotenv\Dotenv; /** @@ -17,24 +18,19 @@ use Symfony\Component\Dotenv\Dotenv; * @todo remove the code that displays the button that links to the install page */ -// Showing/hiding error codes in global error messages. -define('SHOW_ERROR_CODES', false); - // Specification for usernames: // 1. ASCII-letters, digits, "." (dot), "_" (underscore) are acceptable, 40 characters maximum length. // 2. Empty username is formally valid, but it is reserved for the anonymous user. // 3. Checking the login_is_email portal setting in order to accept 100 chars maximum define('USERNAME_MAX_LENGTH', 100); -//define('_MPDF_TEMP_PATH', __DIR__.'/../../var/cache/mpdf/'); -//define('_MPDF_TTFONTDATAPATH', __DIR__.'/../../var/cache/mpdf/'); require_once __DIR__.'/../../vendor/autoload.php'; require_once __DIR__.'/../../public/legacy.php'; -// Check the PHP version -api_check_php_version(__DIR__.'/'); - try { + // Check the PHP version + api_check_php_version(); + // Get settings from .env file created when installation Chamilo $envFile = __DIR__.'/../../.env.local'; if (file_exists($envFile)) { @@ -77,22 +73,14 @@ try { $container = $kernel->getContainer(); if ($kernel->isInstalled()) { - //require_once $kernel->getConfigurationFile(); + require_once $kernel->getConfigurationFile(); } else { - $_configuration = []; - // Redirects to the main/install/ page - $global_error_code = 2; - // The system has not been installed yet. - require_once __DIR__.'/../inc/global_error_message.inc.php'; - exit; + throw new Exception('Chamilo is not installed'); } //$kernel->setApi($_configuration); - - // Ensure that _configuration is in the global scope before loading - // main_api.lib.php. This is particularly helpful for unit tests if (!isset($GLOBALS['_configuration'])) { - //$GLOBALS['_configuration'] = $_configuration; + $GLOBALS['_configuration'] = $_configuration; } // Do not over-use this variable. It is only for this script's local use. @@ -190,9 +178,8 @@ try { }*/ $charset = 'UTF-8'; - // Enables the portability layer and configures PHP for UTF-8 - \Patchwork\Utf8\Bootup::initAll(); + Bootup::initAll(); // access_url == 1 is the default chamilo location /*if ($_configuration['access_url'] != 1) { @@ -480,20 +467,6 @@ try { } } }*/ - - // Add language_measure_frequency to your main/inc/conf/configuration.php in - // order to generate language variables frequency measurements (you can then - // see them through main/cron/lang/langstats.php) - // The langstat object will then be used in the get_lang() function. - // This block can be removed to speed things up a bit as it should only ever - // be used in development versions. - if (isset($_configuration['language_measure_frequency']) && - $_configuration['language_measure_frequency'] == 1 - ) { - //require_once api_get_path(SYS_CODE_PATH).'/cron/lang/langstats.class.php'; - //$langstats = new langstats(); - } - //Default quota for the course documents folder /*$default_quota = api_get_setting('default_document_quotum'); //Just in case the setting is not correctly set @@ -504,7 +477,11 @@ try { // Forcing PclZip library to use a custom temporary folder. //define('PCLZIP_TEMPORARY_DIR', api_get_path(SYS_ARCHIVE_PATH)); } catch (Exception $e) { - error_log($e->getMessage()); /* + var_dump($e->getMessage()); + var_dump($e->getCode()); + var_dump($e->getLine()); + /*echo $e->getMessage(); exit; + var_dump($e->getMessage()); var_dump($e->getCode()); var_dump($e->getLine()); diff --git a/main/inc/lib/course.lib.php b/main/inc/lib/course.lib.php index ce50d43407..4fe8cd1b60 100755 --- a/main/inc/lib/course.lib.php +++ b/main/inc/lib/course.lib.php @@ -6,7 +6,7 @@ use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField; use Chamilo\CourseBundle\Component\CourseCopy\CourseBuilder; use Chamilo\CourseBundle\Component\CourseCopy\CourseRestorer; use Chamilo\CourseBundle\Manager\SettingsManager; -use Chamilo\CourseBundle\ToolChain; +use Chamilo\CoreBundle\ToolChain; use ChamiloSession as Session; /** @@ -22,15 +22,14 @@ use ChamiloSession as Session; * * There are probably some places left with the wrong code. * - * @package chamilo.library */ class CourseManager { - const MAX_COURSE_LENGTH_CODE = 40; + public const MAX_COURSE_LENGTH_CODE = 40; /** This constant is used to show separate user names in the course * list (userportal), footer, etc */ - const USER_SEPARATOR = ' |'; - const COURSE_FIELD_TYPE_CHECKBOX = 10; + public const USER_SEPARATOR = ' |'; + public const COURSE_FIELD_TYPE_CHECKBOX = 10; public $columns = []; public static $em; public static $toolList; diff --git a/main/inc/lib/usermanager.lib.php b/main/inc/lib/usermanager.lib.php index 6be8e33c18..1df6303647 100755 --- a/main/inc/lib/usermanager.lib.php +++ b/main/inc/lib/usermanager.lib.php @@ -213,9 +213,7 @@ class UserManager // In some cases, the first access_url ID might be different from 1 // for example when using a DB cluster or hacking the DB manually. // In this case, we want the first row, not necessarily "1". - $dbm = Database::getManager(); - /** @var AccessUrlRepository $accessUrlRepository */ - $accessUrlRepository = $dbm->getRepository('ChamiloCoreBundle:AccessUrl'); + $accessUrlRepository = Container::getAccessUrlRepository(); $accessUrl = $accessUrlRepository->getFirstId(); if (!empty($accessUrl[0]) && !empty($accessUrl[0][1])) { $access_url_id = $accessUrl[0][1]; diff --git a/src/CoreBundle/ChamiloCoreBundle.php b/src/CoreBundle/ChamiloCoreBundle.php index 87c757f2e8..a85e4d4fac 100644 --- a/src/CoreBundle/ChamiloCoreBundle.php +++ b/src/CoreBundle/ChamiloCoreBundle.php @@ -3,6 +3,7 @@ namespace Chamilo\CoreBundle; +use Chamilo\CoreBundle\DependencyInjection\Compiler\ToolCompilerClass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; @@ -17,5 +18,6 @@ class ChamiloCoreBundle extends Bundle public function build(ContainerBuilder $container) { parent::build($container); + $container->addCompilerPass(new ToolCompilerClass()); } } diff --git a/src/CoreBundle/DependencyInjection/ChamiloCoreExtension.php b/src/CoreBundle/DependencyInjection/ChamiloCoreExtension.php index b29926deca..a96e46a556 100644 --- a/src/CoreBundle/DependencyInjection/ChamiloCoreExtension.php +++ b/src/CoreBundle/DependencyInjection/ChamiloCoreExtension.php @@ -10,8 +10,6 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * Class ChamiloCoreExtension. - * - * @package Chamilo\CoreBundle\DependencyInjection */ class ChamiloCoreExtension extends Extension { @@ -25,9 +23,10 @@ class ChamiloCoreExtension extends Extension $container, new FileLocator(__DIR__.'/../Resources/config') ); - $loader->load('services.yml'); $loader->load('admin.yml'); + $loader->load('tools.yml'); + $loader->load('settings.yml'); } /** diff --git a/src/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php b/src/CoreBundle/DependencyInjection/Compiler/ToolCompilerClass.php similarity index 70% rename from src/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php rename to src/CoreBundle/DependencyInjection/Compiler/ToolCompilerClass.php index edb3b46ddb..0d8921aeb8 100644 --- a/src/CourseBundle/DependencyInjection/Compiler/ToolCompilerClass.php +++ b/src/CoreBundle/DependencyInjection/Compiler/ToolCompilerClass.php @@ -1,7 +1,7 @@ hasDefinition('chamilo_course.tool_chain')) { + if (!$container->hasDefinition('chamilo_core.tool_chain')) { return; } - $definition = $container->getDefinition('chamilo_course.tool_chain'); - $taggedServices = $container->findTaggedServiceIds('chamilo_course.tool'); - + $definition = $container->getDefinition('chamilo_core.tool_chain'); + $taggedServices = $container->findTaggedServiceIds('chamilo_core.tool'); foreach ($taggedServices as $id => $attributes) { $definition->addMethodCall('addTool', [new Reference($id)]); } diff --git a/src/CoreBundle/Entity/AccessUrl.php b/src/CoreBundle/Entity/AccessUrl.php index 7e80293ed8..63b1e5c256 100644 --- a/src/CoreBundle/Entity/AccessUrl.php +++ b/src/CoreBundle/Entity/AccessUrl.php @@ -3,6 +3,8 @@ namespace Chamilo\CoreBundle\Entity; +use Chamilo\CoreBundle\Entity\Resource\AbstractResource; +use Chamilo\CoreBundle\Entity\Resource\ResourceInterface; use Chamilo\CoreBundle\Traits\CourseTrait; use Doctrine\ORM\Mapping as ORM; @@ -10,9 +12,9 @@ use Doctrine\ORM\Mapping as ORM; * AccessUrl. * * @ORM\Table(name="access_url") - * @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Repository\AccessUrlRepository") + * @ORM\Entity */ -class AccessUrl +class AccessUrl extends AbstractResource implements ResourceInterface { use CourseTrait; @@ -486,4 +488,30 @@ class AccessUrl return $this; } + + /** + * Resource identifier. + * + * @return int + */ + public function getResourceIdentifier(): int + { + return $this->getId(); + } + + /** + * @return string + */ + public function getResourceName(): string + { + return $this->getUrl(); + } + + /** + * @return string + */ + public function getToolName(): string + { + return 'AccessUrl'; + } } diff --git a/src/CoreBundle/Entity/Course.php b/src/CoreBundle/Entity/Course.php index ea0b0fdcc9..4cfd4e9226 100644 --- a/src/CoreBundle/Entity/Course.php +++ b/src/CoreBundle/Entity/Course.php @@ -3,6 +3,8 @@ namespace Chamilo\CoreBundle\Entity; +use Chamilo\CoreBundle\Entity\Resource\AbstractResource; +use Chamilo\CoreBundle\Entity\Resource\ResourceInterface; use Chamilo\CourseBundle\Entity\CGroupInfo; use Chamilo\CourseBundle\Entity\CTool; use Chamilo\UserBundle\Entity\User; @@ -28,10 +30,10 @@ use Symfony\Component\Validator\Constraints as Assert; * @UniqueEntity("visualCode") * @UniqueEntity("directory") * - * @ORM\Entity(repositoryClass="Chamilo\CoreBundle\Repository\CourseRepository") + * @ORM\Entity * @ORM\EntityListeners({"Chamilo\CoreBundle\Entity\Listener\CourseListener"}) */ -class Course +class Course extends AbstractResource implements ResourceInterface { public const CLOSED = 0; public const REGISTERED = 1; @@ -1366,4 +1368,30 @@ class Course $courseRelUser->setStatus($status); $this->addUsers($courseRelUser); } + + /** + * Resource identifier. + * + * @return int + */ + public function getResourceIdentifier(): int + { + return $this->getId(); + } + + /** + * @return string + */ + public function getResourceName(): string + { + return $this->getTitle(); + } + + /** + * @return string + */ + public function getToolName(): string + { + return 'Course'; + } } diff --git a/src/CoreBundle/Entity/Listener/CourseListener.php b/src/CoreBundle/Entity/Listener/CourseListener.php index 0ae6028b18..169b943952 100644 --- a/src/CoreBundle/Entity/Listener/CourseListener.php +++ b/src/CoreBundle/Entity/Listener/CourseListener.php @@ -7,7 +7,7 @@ use Chamilo\CoreBundle\Entity\AccessUrl; use Chamilo\CoreBundle\Entity\AccessUrlRelCourse; use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Repository\CourseRepository; -use Chamilo\CourseBundle\ToolChain; +use Chamilo\CoreBundle\ToolChain; use Chamilo\SettingsBundle\Manager\SettingsManager; use Doctrine\ORM\Event\LifecycleEventArgs; diff --git a/src/CoreBundle/Entity/Manager/AccessUrlManager.php b/src/CoreBundle/Entity/Manager/AccessUrlManager.php deleted file mode 100644 index 9e48fc558f..0000000000 --- a/src/CoreBundle/Entity/Manager/AccessUrlManager.php +++ /dev/null @@ -1,23 +0,0 @@ -create(); - } -} diff --git a/src/CoreBundle/Framework/Container.php b/src/CoreBundle/Framework/Container.php index a0d1b4bc56..d7819ea3e8 100644 --- a/src/CoreBundle/Framework/Container.php +++ b/src/CoreBundle/Framework/Container.php @@ -4,6 +4,8 @@ namespace Chamilo\CoreBundle\Framework; use Chamilo\CoreBundle\Component\Editor\Editor; +use Chamilo\CoreBundle\Repository\AccessUrlRepository; +use Chamilo\CoreBundle\ToolChain; use Chamilo\CourseBundle\Repository\CDocumentRepository; use Chamilo\CourseBundle\Repository\CExerciseCategoryRepository; use Chamilo\CourseBundle\Repository\CQuizCategoryRepository; @@ -357,6 +359,14 @@ class Container return self::$container->get('Chamilo\CourseBundle\Repository\CQuizQuestionCategoryRepository'); } + /** + * @return AccessUrlRepository + */ + public static function getAccessUrlRepository() + { + return self::$container->get('Chamilo\CoreBundle\Repository\AccessUrlRepository'); + } + /** * @param $manager UserManager */ @@ -424,11 +434,11 @@ class Container } /** - * @return \Chamilo\CourseBundle\ToolChain + * @return ToolChain */ public static function getToolChain() { - return self::$container->get('chamilo_course.tool_chain'); + return self::$container->get('chamilo_core.tool_chain'); } /** @@ -450,7 +460,7 @@ class Container \CourseManager::setCourseManager($container->get('chamilo_core.entity.manager.course_manager')); // Setting course tool chain (in order to create tools to a course) - \CourseManager::setToolList($container->get('chamilo_course.tool_chain')); + \CourseManager::setToolList($container->get('chamilo_core.tool_chain')); if ($setSession) { self::$session = $container->get('session'); diff --git a/src/CoreBundle/Hook/HookFactory.php b/src/CoreBundle/Hook/HookFactory.php index 7c1faa86fd..c298a453c1 100644 --- a/src/CoreBundle/Hook/HookFactory.php +++ b/src/CoreBundle/Hook/HookFactory.php @@ -8,8 +8,6 @@ use Doctrine\ORM\EntityManager; /** * Class HookFactory. - * - * @package Chamilo\CoreBundle\Hook */ class HookFactory { diff --git a/src/CoreBundle/Repository/AccessUrlRepository.php b/src/CoreBundle/Repository/AccessUrlRepository.php index dbd8ca59c9..5fe991eb5e 100644 --- a/src/CoreBundle/Repository/AccessUrlRepository.php +++ b/src/CoreBundle/Repository/AccessUrlRepository.php @@ -3,27 +3,11 @@ namespace Chamilo\CoreBundle\Repository; -use Chamilo\CoreBundle\Entity\AccessUrl; -use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; -use Doctrine\Common\Persistence\ManagerRegistry; - /** * Class AccessUrlRepository. - * - * @package Chamilo\CoreBundle\Repository */ -class AccessUrlRepository extends ServiceEntityRepository +class AccessUrlRepository extends ResourceRepository { - /** - * AccessUrlRepository constructor. - * - * @param ManagerRegistry $registry - */ - public function __construct(ManagerRegistry $registry) - { - parent::__construct($registry, AccessUrl::class); - } - /** * Select the first access_url ID in the list as a default setting for * the creation of new users. @@ -32,7 +16,7 @@ class AccessUrlRepository extends ServiceEntityRepository */ public function getFirstId() { - $qb = $this->createQueryBuilder('a'); + $qb = $this->getRepository()->createQueryBuilder('a'); $qb->select('MIN (a.id)'); $q = $qb->getQuery(); diff --git a/src/CoreBundle/Repository/CourseRepository.php b/src/CoreBundle/Repository/CourseRepository.php index eff423086d..30b5403610 100644 --- a/src/CoreBundle/Repository/CourseRepository.php +++ b/src/CoreBundle/Repository/CourseRepository.php @@ -7,15 +7,13 @@ use Chamilo\CoreBundle\Entity\Course; use Doctrine\Common\Collections\Criteria; use Doctrine\ORM\Query\Expr\Join; use Doctrine\ORM\QueryBuilder; -use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; /** - * Class CourseRepository - * The functions inside this class must return an instance of QueryBuilder. + * Class CourseRepository. * - * @package Chamilo\CoreBundle\Repository + * The functions inside this class must return an instance of QueryBuilder. */ -class CourseRepository extends EntityRepository +class CourseRepository extends ResourceRepository { /** * Get all users that are registered in the course. No matter the status. @@ -27,7 +25,7 @@ class CourseRepository extends EntityRepository public function getSubscribedUsers(Course $course) { // Course builder - $queryBuilder = $this->createQueryBuilder('c'); + $queryBuilder = $this->getRepository()->createQueryBuilder('c'); // Selecting user info. $queryBuilder->select('DISTINCT user'); @@ -71,7 +69,7 @@ class CourseRepository extends EntityRepository */ public function getSubscribedStudents(Course $course) { - return self::getSubscribedUsersByStatus($course, STUDENT); + return $this->getSubscribedUsersByStatus($course, STUDENT); } /** @@ -97,7 +95,7 @@ class CourseRepository extends EntityRepository */ public function getSubscribedTeachers(Course $course) { - return self::getSubscribedUsersByStatus($course, COURSEMANAGER); + return $this->getSubscribedUsersByStatus($course, COURSEMANAGER); } /** @@ -119,7 +117,7 @@ class CourseRepository extends EntityRepository public function getCoursesWithNoSession($urlId) { - $queryBuilder = $this->createQueryBuilder('c'); + $queryBuilder = $this->getRepository()->createQueryBuilder('c'); $criteria = Criteria::create(); $queryBuilder = $queryBuilder ->select('c') diff --git a/src/CoreBundle/Repository/ResourceRepository.php b/src/CoreBundle/Repository/ResourceRepository.php index 71b8991803..08d42b5644 100644 --- a/src/CoreBundle/Repository/ResourceRepository.php +++ b/src/CoreBundle/Repository/ResourceRepository.php @@ -15,15 +15,15 @@ use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter; use Chamilo\CourseBundle\Entity\CGroupInfo; use Chamilo\UserBundle\Entity\User; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\EntityRepository; use Doctrine\ORM\Query\Expr\Join; use League\Flysystem\FilesystemInterface; use League\Flysystem\MountManager; +use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository; /** * Class ResourceRepository. */ -class ResourceRepository +class ResourceRepository extends EntityRepository { /** * @var EntityRepository @@ -41,7 +41,7 @@ class ResourceRepository protected $entityManager; /** - * The entity class FQN + * The entity class FQN. * * @var string */ @@ -62,13 +62,23 @@ class ResourceRepository } /** - * @param int $id + * @return EntityRepository + */ + public function getRepository() + { + return $this->repository; + } + + /** + * @param mixed $id + * @param null $lockMode + * @param null $lockVersion * - * @return AbstractResource + * @return object|null */ - public function find(int $id) + public function find($id, $lockMode = null, $lockVersion = null) { - return $this->repository->find($id); + return $this->getRepository()->find($id); } /** @@ -79,7 +89,7 @@ class ResourceRepository */ public function findOneBy(array $criteria, array $orderBy = null) { - return $this->repository->findOneBy($criteria, $orderBy); + return $this->getRepository()->findOneBy($criteria, $orderBy); } /** diff --git a/src/CoreBundle/Resources/config/admin.yml b/src/CoreBundle/Resources/config/admin.yml index fae9a2057a..164ac69c8f 100644 --- a/src/CoreBundle/Resources/config/admin.yml +++ b/src/CoreBundle/Resources/config/admin.yml @@ -1,4 +1,11 @@ services: + # default configuration for services in *this* file + _defaults: + # automatically injects dependencies in your services + autowire: false + # automatically registers your services as commands, event subscribers, etc. + autoconfigure: false + sonata.admin.session: class: Chamilo\CoreBundle\Admin\SessionAdmin tags: diff --git a/src/CoreBundle/Resources/config/services.yml b/src/CoreBundle/Resources/config/services.yml index 9fb2ab441b..d16f0f9e21 100644 --- a/src/CoreBundle/Resources/config/services.yml +++ b/src/CoreBundle/Resources/config/services.yml @@ -6,25 +6,48 @@ parameters: chamilo_core.entity.manager.session_manager.class: Chamilo\CoreBundle\Entity\Manager\SessionManager chamilo_core.entity.session: Chamilo\CoreBundle\Entity\Session - chamilo_core.entity.manager.access_url_manager.class: Chamilo\CoreBundle\Entity\Manager\AccessUrlManager - chamilo_core.entity.access_url: Chamilo\CoreBundle\Entity\AccessUrl - services: _defaults: autowire: true public: true + autoconfigure: true chamilo_core.translation.loader.po: class: Symfony\Component\Translation\Loader\PoFileLoader tags: - {name: translation.loader, alias: po} + Chamilo\CoreBundle\: + resource: '../../*' + exclude: '../../{Repository,Tool,Admin,Block,Component,Composer,DependencyInjection,EventListener,Form,Framework,Menu,Migrations,Security,Settings,Twig,Controller,ChamiloCoreBundle.php,Entity,Tests}' + public: true + + Chamilo\CoreBundle\Controller\: + resource: '../../Controller' + public: true + tags: ['controller.service_arguments'] + # Classic entity repositories Chamilo\CoreBundle\Repository\: - resource: ../../Repository - exclude: '../../Repository/{BranchSyncRepository.php,CourseRepository.php,ResourceRepository.php}' + resource: '../../Repository' + exclude: '../../Repository/{BranchSyncRepository.php,ResourceRepository.php}' tags: ['doctrine.repository_service'] + Chamilo\CoreBundle\Controller\ResourceUploaderController: + autowire: false + + Chamilo\CoreBundle\Controller\ResourceController: + autowire: false + + # Entity repository as a service + Chamilo\CoreBundle\Repository\AccessUrlRepository: + arguments: + $className: 'Chamilo\CoreBundle\Entity\AccessUrl' + + Chamilo\CoreBundle\Repository\CourseRepository: + arguments: + $className: 'Chamilo\CoreBundle\Entity\Course' + menu.voter.regex: class: Chamilo\CoreBundle\Menu\MenuVoter arguments: ['@request_stack'] @@ -35,17 +58,10 @@ services: chamilo_core.entity.manager.course_manager: class: '%chamilo_core.entity.manager.course_manager.class%' arguments: ['%chamilo_core.entity.course%', '@doctrine'] - public: true chamilo_core.entity.manager.session_manager: class: '%chamilo_core.entity.manager.session_manager.class%' arguments: ['%chamilo_core.entity.session%', '@doctrine'] - public: true - - chamilo_core.manager.access_url: - class: '%chamilo_core.entity.manager.access_url_manager.class%' - arguments: ['%chamilo_core.entity.access_url%', '@doctrine'] - public: true # Chamilo Twig extension (already added with autowiring) # twig.extension.chamilo_extension: @@ -124,7 +140,7 @@ services: chamilo_core.html_editor: class: Chamilo\CoreBundle\Component\Editor\CkEditor\CkEditor arguments: ['@translator', '@router'] - public: true + # Listeners # chamilo.doctrine.entity_listener_resolver: # class: Chamilo\CoreBundle\Doctrine\EntityListenerResolver @@ -140,7 +156,7 @@ services: # When Course entity is loaded chamilo_core.listener.course: class: Chamilo\CoreBundle\Entity\Listener\CourseListener - arguments: ['@chamilo_course.tool_chain', '@chamilo.settings.manager'] + arguments: ['@chamilo_core.tool_chain', '@chamilo.settings.manager'] tags: - {name: doctrine.orm.entity_listener, entity_manager: default, lazy: true} @@ -237,7 +253,6 @@ services: tags: - {name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin} - chamilo_core.listener.logout_success_handler: class: Chamilo\CoreBundle\EventListener\LogoutSuccessHandler arguments: ['@router', '@security.authorization_checker', '@security.token_storage'] @@ -263,185 +278,6 @@ services: - {name: sonata.block} - {name: sonata.breadcrumb} - # Platform settings - chamilo_core.settings.admin: - class: Chamilo\CoreBundle\Settings\AdminSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.admin, namespace: admin} - - chamilo_core.settings.announcement: - class: Chamilo\CoreBundle\Settings\AnnouncementSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.announcement, namespace: announcement} - - chamilo_core.settings.agenda: - class: Chamilo\CoreBundle\Settings\AgendaSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.agenda, namespace: agenda} - - chamilo_core.settings.attendance: - class: Chamilo\CoreBundle\Settings\AttendanceSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.attendance, namespace: attendance} - - chamilo_core.settings.cas: - class: Chamilo\CoreBundle\Settings\CasSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.cas, namespace: cas} - - chamilo_core.settings.certificate: - class: Chamilo\CoreBundle\Settings\CertificateSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.certificate, namespace: certificate} - - chamilo_core.settings.chat: - class: Chamilo\CoreBundle\Settings\ChatSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.chat, namespace: chat} - - chamilo_core.settings.course: - class: Chamilo\CoreBundle\Settings\CourseSettingsSchema - calls: - - [setToolChain, ['@chamilo_course.tool_chain']] - - [setCourseManager, ['@chamilo_core.entity.manager.course_manager']] - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.course, namespace: course} - - chamilo_core.settings.crons: - class: Chamilo\CoreBundle\Settings\CronSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.crons, namespace: crons} - - chamilo_core.settings.display: - class: Chamilo\CoreBundle\Settings\DisplaySettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.display, namespace: display} - - chamilo_core.settings.document: - class: Chamilo\CoreBundle\Settings\DocumentSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.document, namespace: document} - - chamilo_core.settings.dropbox: - class: Chamilo\CoreBundle\Settings\DropboxSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.dropbox, namespace: dropbox} - - chamilo_core.settings.editor: - class: Chamilo\CoreBundle\Settings\EditorSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.editor, namespace: editor} - - chamilo_core.settings.exercise: - class: Chamilo\CoreBundle\Settings\ExerciseSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.exercise, namespace: exercise} - - chamilo_core.settings.forum: - class: Chamilo\CoreBundle\Settings\ForumSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.forum, namespace: forum} - - chamilo_core.settings.glossary: - class: Chamilo\CoreBundle\Settings\GlossarySettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.glossary, namespace: glossary} - - chamilo_core.settings.gradebook: - class: Chamilo\CoreBundle\Settings\GradebookSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.gradebook, namespace: gradebook} - - chamilo_core.settings.group: - class: Chamilo\CoreBundle\Settings\GroupSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.group, namespace: group} - - chamilo_core.settings.language: - class: Chamilo\CoreBundle\Settings\LanguageSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.language, namespace: language} - - chamilo_core.settings.lp: - class: Chamilo\CoreBundle\Settings\LearningPathSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.lp, namespace: lp} - - chamilo_core.settings.mail: - class: Chamilo\CoreBundle\Settings\MailSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.mail, namespace: mail} - - chamilo_core.settings.message: - class: Chamilo\CoreBundle\Settings\MessageSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.message, namespace: message} - - chamilo_core.settings.platform: - class: Chamilo\CoreBundle\Settings\PlatformSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.platform, namespace: platform} - - chamilo_core.settings.profile: - class: Chamilo\CoreBundle\Settings\ProfileSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.profile, namespace: profile} - - chamilo_core.settings.ppt_to_lp: - class: Chamilo\CoreBundle\Settings\PptToLpSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.ppt_to_lp, namespace: ppt_to_lp} - - chamilo_core.settings.registration: - class: Chamilo\CoreBundle\Settings\RegistrationSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.registration, namespace: registration} - - chamilo_core.settings.search: - class: Chamilo\CoreBundle\Settings\SearchSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.search, namespace: search} - - chamilo_core.settings.security: - class: Chamilo\CoreBundle\Settings\SecuritySettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.security, namespace: security} - - chamilo_core.settings.session: - class: Chamilo\CoreBundle\Settings\SessionSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.session, namespace: session} - - chamilo_core.settings.skill: - class: Chamilo\CoreBundle\Settings\SkillSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.skill, namespace: skill} - - chamilo_core.settings.social: - class: Chamilo\CoreBundle\Settings\SocialSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.social, namespace: social} - - chamilo_core.settings.survey: - class: Chamilo\CoreBundle\Settings\SurveySettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.survey, namespace: survey} - - chamilo_core.settings.ticket: - class: Chamilo\CoreBundle\Settings\TicketSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.ticket, namespace: ticket} - - chamilo_core.settings.tracking: - class: Chamilo\CoreBundle\Settings\TrackingSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.tracking, namespace: tracking} - - chamilo_core.settings.webservice: - class: Chamilo\CoreBundle\Settings\WebServiceSettingsSchema - tags: - - {name: sylius.settings_schema, alias: chamilo_core.settings.webservice, namespace: webservice} - # Form types chamilo_user.registration.form.type: class: Chamilo\UserBundle\Form\Type\RegistrationFormType @@ -458,6 +294,3 @@ services: Liip\ImagineBundle\Service\FilterService: alias: 'liip_imagine.service.filter' - chamilo_core.hook_factory: - class: Chamilo\CoreBundle\Hook\HookFactory - public: true diff --git a/src/CoreBundle/Resources/config/settings.yml b/src/CoreBundle/Resources/config/settings.yml new file mode 100644 index 0000000000..e714ae3db5 --- /dev/null +++ b/src/CoreBundle/Resources/config/settings.yml @@ -0,0 +1,183 @@ +services: + _defaults: + autowire: true + public: true + + # Platform settings + chamilo_core.settings.admin: + class: Chamilo\CoreBundle\Settings\AdminSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.admin, namespace: admin} + + chamilo_core.settings.announcement: + class: Chamilo\CoreBundle\Settings\AnnouncementSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.announcement, namespace: announcement} + + chamilo_core.settings.agenda: + class: Chamilo\CoreBundle\Settings\AgendaSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.agenda, namespace: agenda} + + chamilo_core.settings.attendance: + class: Chamilo\CoreBundle\Settings\AttendanceSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.attendance, namespace: attendance} + + chamilo_core.settings.cas: + class: Chamilo\CoreBundle\Settings\CasSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.cas, namespace: cas} + + chamilo_core.settings.certificate: + class: Chamilo\CoreBundle\Settings\CertificateSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.certificate, namespace: certificate} + + chamilo_core.settings.chat: + class: Chamilo\CoreBundle\Settings\ChatSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.chat, namespace: chat} + + chamilo_core.settings.course: + class: Chamilo\CoreBundle\Settings\CourseSettingsSchema + calls: + - [setToolChain, ['@chamilo_core.tool_chain']] + - [setRepository, ['@Chamilo\CoreBundle\Repository\CourseRepository']] + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.course, namespace: course} + + chamilo_core.settings.crons: + class: Chamilo\CoreBundle\Settings\CronSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.crons, namespace: crons} + + chamilo_core.settings.display: + class: Chamilo\CoreBundle\Settings\DisplaySettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.display, namespace: display} + + chamilo_core.settings.document: + class: Chamilo\CoreBundle\Settings\DocumentSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.document, namespace: document} + + chamilo_core.settings.dropbox: + class: Chamilo\CoreBundle\Settings\DropboxSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.dropbox, namespace: dropbox} + + chamilo_core.settings.editor: + class: Chamilo\CoreBundle\Settings\EditorSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.editor, namespace: editor} + + chamilo_core.settings.exercise: + class: Chamilo\CoreBundle\Settings\ExerciseSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.exercise, namespace: exercise} + + chamilo_core.settings.forum: + class: Chamilo\CoreBundle\Settings\ForumSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.forum, namespace: forum} + + chamilo_core.settings.glossary: + class: Chamilo\CoreBundle\Settings\GlossarySettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.glossary, namespace: glossary} + + chamilo_core.settings.gradebook: + class: Chamilo\CoreBundle\Settings\GradebookSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.gradebook, namespace: gradebook} + + chamilo_core.settings.group: + class: Chamilo\CoreBundle\Settings\GroupSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.group, namespace: group} + + chamilo_core.settings.language: + class: Chamilo\CoreBundle\Settings\LanguageSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.language, namespace: language} + + chamilo_core.settings.lp: + class: Chamilo\CoreBundle\Settings\LearningPathSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.lp, namespace: lp} + + chamilo_core.settings.mail: + class: Chamilo\CoreBundle\Settings\MailSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.mail, namespace: mail} + + chamilo_core.settings.message: + class: Chamilo\CoreBundle\Settings\MessageSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.message, namespace: message} + + chamilo_core.settings.platform: + class: Chamilo\CoreBundle\Settings\PlatformSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.platform, namespace: platform} + + chamilo_core.settings.profile: + class: Chamilo\CoreBundle\Settings\ProfileSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.profile, namespace: profile} + + chamilo_core.settings.ppt_to_lp: + class: Chamilo\CoreBundle\Settings\PptToLpSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.ppt_to_lp, namespace: ppt_to_lp} + + chamilo_core.settings.registration: + class: Chamilo\CoreBundle\Settings\RegistrationSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.registration, namespace: registration} + + chamilo_core.settings.search: + class: Chamilo\CoreBundle\Settings\SearchSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.search, namespace: search} + + chamilo_core.settings.security: + class: Chamilo\CoreBundle\Settings\SecuritySettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.security, namespace: security} + + chamilo_core.settings.session: + class: Chamilo\CoreBundle\Settings\SessionSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.session, namespace: session} + + chamilo_core.settings.skill: + class: Chamilo\CoreBundle\Settings\SkillSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.skill, namespace: skill} + + chamilo_core.settings.social: + class: Chamilo\CoreBundle\Settings\SocialSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.social, namespace: social} + + chamilo_core.settings.survey: + class: Chamilo\CoreBundle\Settings\SurveySettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.survey, namespace: survey} + + chamilo_core.settings.ticket: + class: Chamilo\CoreBundle\Settings\TicketSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.ticket, namespace: ticket} + + chamilo_core.settings.tracking: + class: Chamilo\CoreBundle\Settings\TrackingSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.tracking, namespace: tracking} + + chamilo_core.settings.webservice: + class: Chamilo\CoreBundle\Settings\WebServiceSettingsSchema + tags: + - {name: sylius.settings_schema, alias: chamilo_core.settings.webservice, namespace: webservice} \ No newline at end of file diff --git a/src/CoreBundle/Resources/config/tools.yml b/src/CoreBundle/Resources/config/tools.yml new file mode 100644 index 0000000000..717b6f7b98 --- /dev/null +++ b/src/CoreBundle/Resources/config/tools.yml @@ -0,0 +1,479 @@ +services: + _defaults: + autowire: false + public: true + autoconfigure: false + + # Tool chain loads the list of tool services with the tag "chamilo_core.tool" + # Tool chain is filled in file DependencyInjection/Compiler/ToolCompilerClass.php + chamilo_core.tool_chain: + class: 'Chamilo\CoreBundle\ToolChain' + + # Admin + chamilo_core.tool.admin: + class: Chamilo\CoreBundle\Tool\Admin + arguments: + - 'admin' + - 'admin' + - 'admin' + - 'admin.png' + - '' + - [AccessUrl, Course] + - 1 + tags: + - {name: chamilo_core.tool} + + # Agenda tool + chamilo_core.tool.agenda: + class: Chamilo\CoreBundle\Tool\Agenda + arguments: + - 'calendar_event' + - 'authoring' + - 'calendar/agenda.php' + - 'agenda.gif' + - chamilo_course.settings.agenda + - [calendar_event, calendar_event_attachment] + - 0 + tags: + - {name: chamilo_core.tool} + + # Agenda tool settings + chamilo_course.settings.agenda: + class: Chamilo\CourseBundle\Settings\AgendaCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.agenda, namespace: agenda} + + # Announcement tool + chamilo_core.tool.announcement: + class: Chamilo\CoreBundle\Tool\Announcement + arguments: + - 'announcement' + - 'authoring' + - 'announcements/announcements.php' + - 'valves.gif' + - chamilo_course.settings.announcement + - [announcement] + - 0 + tags: + - {name: chamilo_core.tool} + + # Announcement tool settings + chamilo_course.settings.announcement: + class: Chamilo\CourseBundle\Settings\AnnouncementCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.announcement, namespace: announcement} + + chamilo_core.tool.assignment: + class: Chamilo\CoreBundle\Tool\Assignment + arguments: + - 'student_publication' + - 'interaction' + - 'work/work.php' + - 'works.gif' + - chamilo_course.settings.assignment + - [work] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.assignment: + class: Chamilo\CourseBundle\Settings\AssignmentCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.assignment, namespace: assignment} + + chamilo_core.tool.attendance: + class: Chamilo\CoreBundle\Tool\Attendance + arguments: + - 'attendance' + - 'authoring' + - 'attendance/index.php' + - 'attendance.gif' + - '@chamilo_course.settings.attendance' + - [attendance] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.attendance: + class: Chamilo\CourseBundle\Settings\AttendanceCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.attendance, namespace: attendance} + + chamilo_core.tool.blog: + class: Chamilo\CoreBundle\Tool\Blog + arguments: + - 'blog' + - 'admin' + - 'blog/blog_admin.php' + - 'blog_admin.gif' + - '@chamilo_course.settings.blog' + - [blog_management] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.blog: + class: Chamilo\CourseBundle\Settings\BlogCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.blog, namespace: blog} + + chamilo_core.tool.course_description: + class: Chamilo\CoreBundle\Tool\CourseDescription + arguments: + - course_description + - authoring + - course_description/index.php + - info.gif + - '@chamilo_course.settings.course_description' + - [course_description] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.course_description: + class: Chamilo\CourseBundle\Settings\CourseDescriptionCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.course_description, namespace: course_description} + + chamilo_core.tool.chat: + class: Chamilo\CoreBundle\Tool\Chat + arguments: + - chat + - interaction + - chat/chat.php + - chat.gif + - '@chamilo_course.settings.chat' + - ~ + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.chat: + class: Chamilo\CourseBundle\Settings\ChatCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.chat, namespace: chat} + + chamilo_core.tool.course_progress: + class: Chamilo\CoreBundle\Tool\CourseProgress + arguments: + - course_progress + - authoring + - course_progress/index.php + - course_progress.gif + - '@chamilo_course.settings.course_progress' + - [thematic, thematic_advance, thematic_plan] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.course_progress: + class: Chamilo\CourseBundle\Settings\CourseProgressCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.course_progress, namespace: course_progress} + + chamilo_core.tool.document: + class: Chamilo\CoreBundle\Tool\Document + arguments: + - document + - authoring + - document/document.php + - folder_document.gif + - '@chamilo_course.settings.document' + - [document] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.document: + class: Chamilo\CourseBundle\Settings\DocumentCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.document, namespace: document} + + chamilo_core.tool.dropbox: + class: Chamilo\CoreBundle\Tool\Dropbox + arguments: + - dropbox + - interaction + - dropbox/index.php + - dropbox.gif + - '@chamilo_course.settings.dropbox' + - [dropbox] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.dropbox: + class: Chamilo\CourseBundle\Settings\DropboxCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.dropbox, namespace: dropbox} + + chamilo_core.tool.exercise: + class: Chamilo\CoreBundle\Tool\Exercise + arguments: + - quiz + - authoring + - exercise/exercise.php + - quiz.gif + - '@chamilo_course.settings.exercise' + - [CQuiz, CQuizQuestionCategory, CQuizQuestionCategory, CExerciseCategory] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.exercise: + class: Chamilo\CourseBundle\Settings\ExerciseCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.quiz, namespace: quiz} + + chamilo_core.tool.forum: + class: Chamilo\CoreBundle\Tool\Forum + arguments: + - forum + - interaction + - forum/index.php + - forum.gif + - '@chamilo_course.settings.forum' + - [forum, forum_attachment, forum_category, forum_post, forum_thread] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.forum: + class: Chamilo\CourseBundle\Settings\ForumCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.forum, namespace: forum} + + chamilo_core.tool.glossary: + class: Chamilo\CoreBundle\Tool\Glossary + arguments: + - glossary + - authoring + - glossary/index.php + - glossary.gif + - '@chamilo_course.settings.glossary' + - [glossary] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.glossary: + class: Chamilo\CourseBundle\Settings\GlossaryCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.glossary, namespace: glossary} + + chamilo_core.tool.gradebook: + class: Chamilo\CoreBundle\Tool\Gradebook + arguments: + - gradebook + - authoring + - gradebook/index.php + - gradebook.gif + - '@chamilo_course.settings.gradebook' + - ~ + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.gradebook: + class: Chamilo\CourseBundle\Settings\GradebookCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.gradebook, namespace: gradebook} + + chamilo_core.tool.group: + class: Chamilo\CoreBundle\Tool\Group + arguments: + - group + - interaction + - group/group.php + - group.gif + - '@chamilo_course.settings.group' + - ~ + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.group: + class: Chamilo\CourseBundle\Settings\GroupCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.group, namespace: group} + + chamilo_core.tool.learning_path: + class: Chamilo\CoreBundle\Tool\LearningPath + arguments: + - learnpath + - authoring + - lp/lp_controller.php + - scorms.gif + - '@chamilo_course.settings.learning_path' + - [learnpath, learnpath_category] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.learning_path: + class: Chamilo\CourseBundle\Settings\LearningPathCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.learnpath, namespace: learnpath} + + chamilo_core.tool.link: + class: Chamilo\CoreBundle\Tool\Link + arguments: + - link + - authoring + - link/link.php + - links.gif + - '@chamilo_course.settings.link' + - [link, link_category] + - 0 + tags: + - {name: chamilo_core.tool} + + chamilo_course.settings.link: + class: Chamilo\CourseBundle\Settings\LinkCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.link, namespace: link} + + # Maintenance + chamilo_course.settings.maintenance: + class: Chamilo\CourseBundle\Settings\MaintenanceCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.maintenance, namespace: maintenance} + + chamilo_core.tool.maintenance: + class: Chamilo\CoreBundle\Tool\Maintenance + arguments: + - course_maintenance + - admin + - course_info/maintenance.php + - backup.gif + - '@chamilo_course.settings.maintenance' + - ~ + - 0 + tags: + - {name: chamilo_core.tool} + + # Notebook + chamilo_course.settings.notebook: + class: Chamilo\CourseBundle\Settings\NotebookCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.notebook, namespace: notebook} + + chamilo_core.tool.notebook: + class: Chamilo\CoreBundle\Tool\Notebook + arguments: + - notebook + - interaction + - notebook/index.php + - notebook.gif + - '@chamilo_course.settings.notebook' + - [notebook] + - 0 + tags: + - {name: chamilo_core.tool} + + chamilo_core.tool.settings: + class: Chamilo\CoreBundle\Tool\Settings + arguments: + - course_setting + - admin + - course_info/infocours.php + - reference.gif + - '@chamilo_course.settings.settings' + - ~ + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.settings: + class: Chamilo\CourseBundle\Settings\SettingsCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.settings, namespace: settings} + # Survey + chamilo_core.tool.survey: + class: Chamilo\CoreBundle\Tool\Survey + arguments: + - survey + - interaction + - survey/survey_list.php + - survey.gif + - '@chamilo_course.settings.survey' + - [survey] + - 0 + tags: + - {name: chamilo_core.tool} + + chamilo_course.settings.survey: + class: Chamilo\CourseBundle\Settings\SurveyCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.survey, namespace: survey} + + chamilo_core.tool.tracking: + class: Chamilo\CoreBundle\Tool\Tracking + arguments: + - tracking + - admin + - tracking/courseLog.php + - statistics.gif + - '@chamilo_course.settings.tracking' + - ~ + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.tracking: + class: Chamilo\CourseBundle\Settings\TrackingCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.tracking, namespace: tracking} + + chamilo_core.tool.user: + class: Chamilo\CoreBundle\Tool\User + arguments: + - user + - interaction + - user/user.php + - members.gif + - '@chamilo_course.settings.user' + - ~ + - 0 + tags: + - {name: chamilo_core.tool} + # Course settings + chamilo_course.settings.user: + class: Chamilo\CourseBundle\Settings\UserCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.user, namespace: user} + + chamilo_core.tool.wiki: + class: Chamilo\CoreBundle\Tool\Wiki + arguments: + - wiki + - interaction + - wiki/index.php + - wiki.gif + - '@chamilo_course.settings.wiki' + - [wiki] + - 0 + tags: + - {name: chamilo_core.tool} + + # Course settings + chamilo_course.settings.wiki: + class: Chamilo\CourseBundle\Settings\WikiCourseSettingsSchema + tags: + - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.wiki, namespace: wiki} diff --git a/src/CoreBundle/Settings/AbstractSettingsSchema.php b/src/CoreBundle/Settings/AbstractSettingsSchema.php index 73102b4a1b..1c0eafb821 100644 --- a/src/CoreBundle/Settings/AbstractSettingsSchema.php +++ b/src/CoreBundle/Settings/AbstractSettingsSchema.php @@ -3,13 +3,12 @@ namespace Chamilo\CoreBundle\Settings; +use Chamilo\CoreBundle\Entity\Manager\CourseManager; use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder; use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; /** * Class AbstractSettingsSchema. - * - * @package Chamilo\CoreBundle\Settings */ abstract class AbstractSettingsSchema implements SchemaInterface { @@ -23,4 +22,20 @@ abstract class AbstractSettingsSchema implements SchemaInterface $builder->setAllowedTypes($name, $type); } } + + /** + * @return mixed + */ + public function getRepository() + { + return $this->repository; + } + + /** + * @param $repo + */ + public function setRepository($repo) + { + $this->repository = $repo; + } } diff --git a/src/CoreBundle/Settings/CourseSettingsSchema.php b/src/CoreBundle/Settings/CourseSettingsSchema.php index cd6245f984..98c29a3c09 100644 --- a/src/CoreBundle/Settings/CourseSettingsSchema.php +++ b/src/CoreBundle/Settings/CourseSettingsSchema.php @@ -6,8 +6,8 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Manager\CourseManager; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Chamilo\CourseBundle\Tool\BaseTool; -use Chamilo\CourseBundle\ToolChain; +use Chamilo\CoreBundle\Tool\AbstractTool; +use Chamilo\CoreBundle\ToolChain; use Chamilo\SettingsBundle\Transformer\ArrayToIdentifierTransformer; use Sylius\Bundle\ResourceBundle\Form\DataTransformer\ResourceToIdentifierTransformer; use Sylius\Bundle\SettingsBundle\Schema\AbstractSettingsBuilder; @@ -31,10 +31,12 @@ class CourseSettingsSchema extends AbstractSettingsSchema */ protected $courseManager; + protected $repository; + /** * @param ToolChain $tools */ - public function setToolChain(ToolChain $tools) + public function setToolChain(ToolChain $tools): void { $this->toolChain = $tools; } @@ -42,7 +44,7 @@ class CourseSettingsSchema extends AbstractSettingsSchema /** * @param CourseManager $manager */ - public function setCourseManager($manager) + public function setCourseManager($manager): void { $this->courseManager = $manager; } @@ -50,10 +52,10 @@ class CourseSettingsSchema extends AbstractSettingsSchema /** * @return array */ - public function getProcessedToolChain() + public function getProcessedToolChain(): array { $tools = []; - /** @var BaseTool $tool */ + /** @var AbstractTool $tool */ foreach ($this->toolChain->getTools() as $tool) { $name = $tool->getName(); $tools[$name] = $name; @@ -68,7 +70,6 @@ class CourseSettingsSchema extends AbstractSettingsSchema public function buildSettings(AbstractSettingsBuilder $builder) { $tools = $this->getProcessedToolChain(); - $em = $this->courseManager->getEntityManager(); $builder ->setDefaults( @@ -121,7 +122,7 @@ class CourseSettingsSchema extends AbstractSettingsSchema ) ->setTransformer( 'course_creation_use_template', - new ResourceToIdentifierTransformer($em->getRepository('ChamiloCoreBundle:Course')) + new ResourceToIdentifierTransformer($this->getRepository()) ) ; diff --git a/src/CourseBundle/Tool/BaseTool.php b/src/CoreBundle/Tool/AbstractTool.php similarity index 88% rename from src/CourseBundle/Tool/BaseTool.php rename to src/CoreBundle/Tool/AbstractTool.php index 44bf5828da..25c8dea091 100644 --- a/src/CourseBundle/Tool/BaseTool.php +++ b/src/CoreBundle/Tool/AbstractTool.php @@ -1,15 +1,15 @@ name = $name; $this->category = $category; $this->link = $link; $this->image = $image; - $this->admin = 0; + $this->admin = (int) $admin; $this->courseSettings = $courseSettings; $this->types = $types; } @@ -90,9 +91,9 @@ abstract class BaseTool implements ToolInterface /** * @return int */ - public function getAdmin() + public function getAdmin(): int { - return $this->admin; + return (int) $this->admin; } /** diff --git a/src/CoreBundle/Tool/Admin.php b/src/CoreBundle/Tool/Admin.php new file mode 100644 index 0000000000..55038d6924 --- /dev/null +++ b/src/CoreBundle/Tool/Admin.php @@ -0,0 +1,11 @@ +tools[$tool->getName()] = $tool; } @@ -76,19 +75,25 @@ class ToolChain /** * @param ObjectManager $manager */ - public function createTools(ObjectManager $manager) + public function createTools(ObjectManager $manager): void { $tools = $this->getTools(); - /** @var BaseTool $tool */ + /** @var AbstractTool $tool */ foreach ($tools as $tool) { $toolEntity = new Tool(); $toolEntity ->setName($tool->getName()) ->setImage($tool->getImage()) - ->setDescription($tool->getName().' - description') + ->setDescription('') ; - $this->setToolPermissions($toolEntity); + + if ($tool->getAdmin() === 1) { + // Only check ROLE_ADMIN + } else { + $this->setToolPermissions($toolEntity); + } + $manager->persist($toolEntity); $types = $tool->getTypes(); @@ -108,7 +113,7 @@ class ToolChain /** * @param Tool $tool */ - public function setToolPermissions(Tool $tool) + public function setToolPermissions(Tool $tool): void { $toolResourceRight = new ToolResourceRight(); $toolResourceRight @@ -132,12 +137,12 @@ class ToolChain * * @return Course */ - public function addToolsInCourse(Course $course, SettingsManager $settingsManager) + public function addToolsInCourse(Course $course, SettingsManager $settingsManager): Course { $tools = $this->getTools(); $toolVisibility = $settingsManager->getSetting('course.active_tools_on_create'); - /** @var BaseTool $tool */ + /** @var AbstractTool $tool */ foreach ($tools as $tool) { $toolEntity = new CTool(); $visibility = in_array($tool->getName(), $toolVisibility); @@ -160,7 +165,7 @@ class ToolChain /** * @param string $name * - * @return BaseTool + * @return AbstractTool|false */ public function getToolFromName($name) { diff --git a/src/CourseBundle/Admin/CourseAdmin.php b/src/CourseBundle/Admin/CourseAdmin.php index 03275fa609..2d56f0e648 100644 --- a/src/CourseBundle/Admin/CourseAdmin.php +++ b/src/CourseBundle/Admin/CourseAdmin.php @@ -4,8 +4,8 @@ namespace Chamilo\CourseBundle\Admin; use Chamilo\CoreBundle\Entity\Course; +use Chamilo\CoreBundle\ToolChain; use Chamilo\CourseBundle\Entity\CTool; -use Chamilo\CourseBundle\ToolChain; use FOS\CKEditorBundle\Form\Type\CKEditorType; use Sonata\AdminBundle\Admin\AbstractAdmin; use Sonata\AdminBundle\Datagrid\DatagridMapper; @@ -19,8 +19,6 @@ use Symfony\Component\Form\Extension\Core\Type\UrlType; /** * Class CourseAdmin. - * - * @package Chamilo\CoreBundle\Admin */ class CourseAdmin extends AbstractAdmin { @@ -42,7 +40,7 @@ class CourseAdmin extends AbstractAdmin /** * Very important in order to save the related entities while updating. * - * @param \Chamilo\CoreBundle\Entity\Course $course + * @param Course $course * * @return mixed|void */ diff --git a/src/CourseBundle/ChamiloCourseBundle.php b/src/CourseBundle/ChamiloCourseBundle.php index 414b1210a1..218a89ca77 100644 --- a/src/CourseBundle/ChamiloCourseBundle.php +++ b/src/CourseBundle/ChamiloCourseBundle.php @@ -4,27 +4,14 @@ namespace Chamilo\CourseBundle; use Chamilo\CourseBundle\DependencyInjection\Compiler\RegisterSchemasPass; -use Chamilo\CourseBundle\DependencyInjection\Compiler\ToolCompilerClass; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\HttpKernel\Bundle\Bundle; /** * Class ChamiloCourseBundle. - * - * @package Chamilo\CourseBundle */ class ChamiloCourseBundle extends Bundle { - /** - * {@inheritdoc} - */ - public static function getSupportedDrivers() - { - return [ - SyliusResourceBundle::DRIVER_DOCTRINE_ORM, - ]; - } - /** * {@inheritdoc} */ @@ -32,15 +19,6 @@ class ChamiloCourseBundle extends Bundle { parent::build($container); - $container->addCompilerPass(new ToolCompilerClass()); $container->addCompilerPass(new RegisterSchemasPass()); } - - /** - * {@inheritdoc} - */ - protected function getBundlePrefix() - { - return 'chamilo_course'; - } } diff --git a/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php b/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php index c9432b693c..8707fb12aa 100644 --- a/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php +++ b/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php @@ -3,7 +3,6 @@ namespace Chamilo\CourseBundle\DependencyInjection; -//use Sylius\Bundle\ResourceBundle\DependencyInjection\AbstractResourceExtension; old use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader; @@ -16,34 +15,13 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; */ class ChamiloCourseExtension extends Extension { - // You can choose your application name, it will use to prefix the configuration keys in the container (the default value is sylius). - protected $applicationName = 'chamilo_course'; - - // You can define where yours service definitions are - protected $configDirectory = '/../Resources/config'; - - // You can define what service definitions you want to load - protected $configFiles = [ - 'services.yml', - 'forms.yml', - ]; - /** * {@inheritdoc} */ - public function load(array $config, ContainerBuilder $container) + public function load(array $config, ContainerBuilder $container): void { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); $loader->load('admin.yml'); - - //self::CONFIGURE_VALIDATORS - - /*$this->configure( - $config, - new Configuration(), - $container, - self::CONFIGURE_LOADER | self::CONFIGURE_DATABASE | self::CONFIGURE_PARAMETERS | self::CONFIGURE_FORMS - );*/ } } diff --git a/src/CourseBundle/Entity/CExerciseCategory.php b/src/CourseBundle/Entity/CExerciseCategory.php index 07b9dc49db..4b681f75a9 100644 --- a/src/CourseBundle/Entity/CExerciseCategory.php +++ b/src/CourseBundle/Entity/CExerciseCategory.php @@ -231,6 +231,6 @@ class CExerciseCategory extends AbstractResource implements ResourceInterface */ public function getToolName(): string { - return 'test_category'; + return 'CExerciseCategory'; } } diff --git a/src/CourseBundle/Entity/CQuiz.php b/src/CourseBundle/Entity/CQuiz.php index 3bd32a1b27..0f0fb56175 100644 --- a/src/CourseBundle/Entity/CQuiz.php +++ b/src/CourseBundle/Entity/CQuiz.php @@ -968,6 +968,6 @@ class CQuiz extends AbstractResource implements ResourceInterface */ public function getToolName(): string { - return 'quiz'; + return 'CQuiz'; } } diff --git a/src/CourseBundle/Entity/CQuizQuestionCategory.php b/src/CourseBundle/Entity/CQuizQuestionCategory.php index 3e8e4e09a2..fa58ba6f3e 100644 --- a/src/CourseBundle/Entity/CQuizQuestionCategory.php +++ b/src/CourseBundle/Entity/CQuizQuestionCategory.php @@ -205,6 +205,6 @@ class CQuizQuestionCategory extends AbstractResource implements ResourceInterfac */ public function getToolName(): string { - return 'exercise_category'; + return 'CQuizQuestionCategory'; } } diff --git a/src/CourseBundle/Resources/config/admin.yml b/src/CourseBundle/Resources/config/admin.yml index 34a66972e6..19bfcee41f 100644 --- a/src/CourseBundle/Resources/config/admin.yml +++ b/src/CourseBundle/Resources/config/admin.yml @@ -9,7 +9,7 @@ services: - ~ calls: - [setTranslationDomain, [ChamiloCoreBundle]] - - [setToolChain, ['@chamilo_course.tool_chain']] + - [setToolChain, ['@chamilo_core.tool_chain']] sonata.admin.course_rel_user: class: Chamilo\CourseBundle\Admin\CourseRelUserAdmin diff --git a/src/CourseBundle/Resources/config/services.yml b/src/CourseBundle/Resources/config/services.yml index 0158947cfc..d756cc7917 100644 --- a/src/CourseBundle/Resources/config/services.yml +++ b/src/CourseBundle/Resources/config/services.yml @@ -1,7 +1,5 @@ parameters: - chamilo_course.tool_chain.class: Chamilo\CourseBundle\ToolChain chamilo_course.controller.settings.class: Chamilo\CourseBundle\Controller\SettingsController - chamilo_course.settings.form_factory.class: Chamilo\CourseBundle\Form\Factory\SettingsFormFactory chamilo_course.settings.manager.class: Chamilo\CourseBundle\Manager\SettingsManager chamilo_course.settings.schema_registry.class: Sylius\Component\Registry\ServiceRegistry @@ -85,7 +83,7 @@ services: # Course settings chamilo_course.controller.settings: - class: "%chamilo_course.controller.settings.class%" + class: 'Chamilo\CourseBundle\Controller\SettingsController' calls: - [setContainer, ['@service_container']] @@ -130,463 +128,3 @@ services: - '@event_dispatcher' - # Tool chain loads the list of tool services with the tag "chamilo_course.tool" - # Tool chain is filled in file DependencyInjection/Compiler/ToolCompilerClass.php - chamilo_course.tool_chain: - class: '%chamilo_course.tool_chain.class%' - public: true - - # Agenda tool - chamilo_course.tool.agenda: - class: Chamilo\CourseBundle\Tool\Agenda - arguments: - - calendar_event - - authoring - - calendar/agenda.php - - agenda.gif - - chamilo_course.settings.agenda - - [calendar_event, calendar_event_attachment] - - - tags: - - {name: chamilo_course.tool} - - # Agenda tool settings - chamilo_course.settings.agenda: - class: Chamilo\CourseBundle\Settings\AgendaCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.agenda, namespace: agenda} - - # Announcement tool - chamilo_course.tool.announcement: - class: Chamilo\CourseBundle\Tool\Announcement - arguments: - - announcement - - authoring - - announcements/announcements.php - - valves.gif - - chamilo_course.settings.announcement - - [announcement] - - - tags: - - {name: chamilo_course.tool} - - # Announcement tool settings - chamilo_course.settings.announcement: - class: Chamilo\CourseBundle\Settings\AnnouncementCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.announcement, namespace: announcement} - - chamilo_course.tool.assignment: - class: Chamilo\CourseBundle\Tool\Assignment - arguments: - - student_publication - - interaction - - work/work.php - - works.gif - - chamilo_course.settings.assignment - - [work] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.assignment: - class: Chamilo\CourseBundle\Settings\AssignmentCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.assignment, namespace: assignment} - - chamilo_course.tool.attendance: - class: Chamilo\CourseBundle\Tool\Attendance - arguments: - - attendance - - authoring - - attendance/index.php - - attendance.gif - - '@chamilo_course.settings.attendance' - - [attendance] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.attendance: - class: Chamilo\CourseBundle\Settings\AttendanceCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.attendance, namespace: attendance} - - chamilo_course.tool.blog: - class: Chamilo\CourseBundle\Tool\Blog - arguments: - - blog_management - - admin - - blog/blog_admin.php - - blog_admin.gif - - '@chamilo_course.settings.blog' - - [blog_management] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.blog: - class: Chamilo\CourseBundle\Settings\BlogCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.blog, namespace: blog} - - chamilo_course.tool.course_description: - class: Chamilo\CourseBundle\Tool\CourseDescription - arguments: - - course_description - - authoring - - course_description/index.php - - info.gif - - '@chamilo_course.settings.course_description' - - [course_description] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.course_description: - class: Chamilo\CourseBundle\Settings\CourseDescriptionCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.course_description, namespace: course_description} - - chamilo_course.tool.chat: - class: Chamilo\CourseBundle\Tool\Chat - arguments: - - chat - - interaction - - chat/chat.php - - chat.gif - - '@chamilo_course.settings.chat' - - - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.chat: - class: Chamilo\CourseBundle\Settings\ChatCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.chat, namespace: chat} - - chamilo_course.tool.course_progress: - class: Chamilo\CourseBundle\Tool\CourseProgress - arguments: - - course_progress - - authoring - - course_progress/index.php - - course_progress.gif - - '@chamilo_course.settings.course_progress' - - [thematic, thematic_advance, thematic_plan] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.course_progress: - class: Chamilo\CourseBundle\Settings\CourseProgressCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.course_progress, namespace: course_progress} - - chamilo_course.tool.document: - class: Chamilo\CourseBundle\Tool\Document - arguments: - - document - - authoring - - document/document.php - - folder_document.gif - - '@chamilo_course.settings.document' - - [document] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.document: - class: Chamilo\CourseBundle\Settings\DocumentCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.document, namespace: document} - - chamilo_course.tool.dropbox: - class: Chamilo\CourseBundle\Tool\Dropbox - arguments: - - dropbox - - interaction - - dropbox/index.php - - dropbox.gif - - '@chamilo_course.settings.dropbox' - - [dropbox] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.dropbox: - class: Chamilo\CourseBundle\Settings\DropboxCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.dropbox, namespace: dropbox} - - chamilo_course.tool.exercise: - class: Chamilo\CourseBundle\Tool\Exercise - arguments: - - quiz - - authoring - - exercise/exercise.php - - quiz.gif - - '@chamilo_course.settings.exercise' - - [quiz, test_category] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.exercise: - class: Chamilo\CourseBundle\Settings\ExerciseCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.quiz, namespace: quiz} - - chamilo_course.tool.forum: - class: Chamilo\CourseBundle\Tool\Forum - arguments: - - forum - - interaction - - forum/index.php - - forum.gif - - '@chamilo_course.settings.forum' - - [forum, forum_attachment, forum_category, forum_post, forum_thread] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.forum: - class: Chamilo\CourseBundle\Settings\ForumCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.forum, namespace: forum} - - chamilo_course.tool.glossary: - class: Chamilo\CourseBundle\Tool\Glossary - arguments: - - glossary - - authoring - - glossary/index.php - - glossary.gif - - '@chamilo_course.settings.glossary' - - [glossary] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.glossary: - class: Chamilo\CourseBundle\Settings\GlossaryCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.glossary, namespace: glossary} - - chamilo_course.tool.gradebook: - class: Chamilo\CourseBundle\Tool\Gradebook - arguments: - - gradebook - - authoring - - gradebook/index.php - - gradebook.gif - - '@chamilo_course.settings.gradebook' - - - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.gradebook: - class: Chamilo\CourseBundle\Settings\GradebookCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.gradebook, namespace: gradebook} - - chamilo_course.tool.group: - class: Chamilo\CourseBundle\Tool\Group - arguments: - - group - - interaction - - group/group.php - - group.gif - - '@chamilo_course.settings.group' - - - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.group: - class: Chamilo\CourseBundle\Settings\GroupCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.group, namespace: group} - - chamilo_course.tool.learning_path: - class: Chamilo\CourseBundle\Tool\LearningPath - arguments: - - learnpath - - authoring - - lp/lp_controller.php - - scorms.gif - - '@chamilo_course.settings.learning_path' - - [learnpath, learnpath_category] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.learning_path: - class: Chamilo\CourseBundle\Settings\LearningPathCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.learnpath, namespace: learnpath} - - chamilo_course.tool.link: - class: Chamilo\CourseBundle\Tool\Link - arguments: - - link - - authoring - - link/link.php - - links.gif - - '@chamilo_course.settings.link' - - [link, link_category] - - - tags: - - {name: chamilo_course.tool} - - chamilo_course.settings.link: - class: Chamilo\CourseBundle\Settings\LinkCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.link, namespace: link} - - # Maintenance - chamilo_course.settings.maintenance: - class: Chamilo\CourseBundle\Settings\MaintenanceCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.maintenance, namespace: maintenance} - - chamilo_course.tool.maintenance: - class: Chamilo\CourseBundle\Tool\Maintenance - arguments: - - course_maintenance - - admin - - course_info/maintenance.php - - backup.gif - - '@chamilo_course.settings.maintenance' - - - - - tags: - - {name: chamilo_course.tool} - - # Notebook - chamilo_course.settings.notebook: - class: Chamilo\CourseBundle\Settings\NotebookCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.notebook, namespace: notebook} - - chamilo_course.tool.notebook: - class: Chamilo\CourseBundle\Tool\Notebook - arguments: - - notebook - - interaction - - notebook/index.php - - notebook.gif - - '@chamilo_course.settings.notebook' - - [notebook] - - - tags: - - {name: chamilo_course.tool} - - chamilo_course.tool.settings: - class: Chamilo\CourseBundle\Tool\Settings - arguments: - - course_setting - - admin - - course_info/infocours.php - - reference.gif - - '@chamilo_course.settings.settings' - - - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.settings: - class: Chamilo\CourseBundle\Settings\SettingsCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.settings, namespace: settings} - # Survey - chamilo_course.tool.survey: - class: Chamilo\CourseBundle\Tool\Survey - arguments: - - survey - - interaction - - survey/survey_list.php - - survey.gif - - '@chamilo_course.settings.survey' - - [survey] - - - tags: - - {name: chamilo_course.tool} - - chamilo_course.settings.survey: - class: Chamilo\CourseBundle\Settings\SurveyCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.survey, namespace: survey} - - chamilo_course.tool.tracking: - class: Chamilo\CourseBundle\Tool\Tracking - arguments: - - tracking - - admin - - tracking/courseLog.php - - statistics.gif - - '@chamilo_course.settings.tracking' - - - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.tracking: - class: Chamilo\CourseBundle\Settings\TrackingCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.tracking, namespace: tracking} - - chamilo_course.tool.user: - class: Chamilo\CourseBundle\Tool\User - arguments: - - user - - interaction - - user/user.php - - members.gif - - '@chamilo_course.settings.user' - - - - - tags: - - {name: chamilo_course.tool} - # Course settings - chamilo_course.settings.user: - class: Chamilo\CourseBundle\Settings\UserCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.user, namespace: user} - - chamilo_course.tool.wiki: - class: Chamilo\CourseBundle\Tool\Wiki - arguments: - - wiki - - interaction - - wiki/index.php - - wiki.gif - - '@chamilo_course.settings.wiki' - - [wiki] - - - tags: - - {name: chamilo_course.tool} - - # Course settings - chamilo_course.settings.wiki: - class: Chamilo\CourseBundle\Settings\WikiCourseSettingsSchema - tags: - - {name: chamilo_course.settings_schema, alias: chamilo_course.settings.wiki, namespace: wiki} diff --git a/src/CourseBundle/Tool/Document.php b/src/CourseBundle/Tool/Document.php deleted file mode 100644 index 7b3f3b2183..0000000000 --- a/src/CourseBundle/Tool/Document.php +++ /dev/null @@ -1,10 +0,0 @@ -getRealRootDir().'data/'; } - /** - * @return string - */ - public function getAppDir() - { - return $this->getRealRootDir().'app/'; - } - - /** - * @return string - */ - public function getConfigDir() - { - return $this->getRealRootDir().'app/config/'; - } - /** * @return string */ @@ -143,36 +128,28 @@ class Kernel extends BaseKernel /** * @param ContainerBuilder $container * @param LoaderInterface $loader - * - * @throws \Exception */ - protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader) + protected function configureContainer(ContainerBuilder $container, LoaderInterface $loader): void { - $container->setParameter('container.autowiring.strict_mode', true); + $container->addResource(new FileResource($this->getProjectDir().'/config/bundles.php')); $container->setParameter('container.dumper.inline_class_loader', true); $confDir = $this->getProjectDir().'/config'; - $loader->load($confDir.'/packages/*'.self::CONFIG_EXTS, 'glob'); - if (is_dir($confDir.'/packages/'.$this->environment)) { - $loader->load($confDir.'/packages/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); - } - $loader->load($confDir.'/services'.self::CONFIG_EXTS, 'glob'); - $loader->load($confDir.'/services_'.$this->environment.self::CONFIG_EXTS, 'glob'); + + $loader->load($confDir.'/{packages}/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{packages}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}'.self::CONFIG_EXTS, 'glob'); + $loader->load($confDir.'/{services}_'.$this->environment.self::CONFIG_EXTS, 'glob'); } /** * @param RouteCollectionBuilder $routes - * - * @throws \Symfony\Component\Config\Exception\FileLoaderLoadException */ - protected function configureRoutes(RouteCollectionBuilder $routes) + protected function configureRoutes(RouteCollectionBuilder $routes): void { $confDir = $this->getProjectDir().'/config'; - if (is_dir($confDir.'/routes/')) { - $routes->import($confDir.'/routes/*'.self::CONFIG_EXTS, '/', 'glob'); - } - if (is_dir($confDir.'/routes/'.$this->environment)) { - $routes->import($confDir.'/routes/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); - } - $routes->import($confDir.'/routes'.self::CONFIG_EXTS, '/', 'glob'); + + $routes->import($confDir.'/{routes}/'.$this->environment.'/**/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}/*'.self::CONFIG_EXTS, '/', 'glob'); + $routes->import($confDir.'/{routes}'.self::CONFIG_EXTS, '/', 'glob'); } } diff --git a/src/UserBundle/Resources/config/services.yml b/src/UserBundle/Resources/config/services.yml index 58e86b9f90..b9ace0c65b 100644 --- a/src/UserBundle/Resources/config/services.yml +++ b/src/UserBundle/Resources/config/services.yml @@ -1,10 +1,10 @@ services: - chamilo_user.security.user_provider: - class: Chamilo\UserBundle\Security\FOSUBUserProvider - arguments: - - '@sonata.user.orm.user_manager' - - {facebook: facebookId, google: googleId, github: githubId} + chamilo_user.security.user_provider: + class: Chamilo\UserBundle\Security\FOSUBUserProvider + arguments: + - '@sonata.user.orm.user_manager' + - {facebook: facebookId, google: googleId, github: githubId} - chamilo_user.security.login_form_authenticator: - class: Chamilo\UserBundle\Security\LoginFormAuthenticator - autowire: true + chamilo_user.security.login_form_authenticator: + class: Chamilo\UserBundle\Security\LoginFormAuthenticator + autowire: true diff --git a/src/UserBundle/Security/FOSUBUserProvider.php b/src/UserBundle/Security/FOSUBUserProvider.php index fe1bd04648..7f0aa88791 100644 --- a/src/UserBundle/Security/FOSUBUserProvider.php +++ b/src/UserBundle/Security/FOSUBUserProvider.php @@ -9,8 +9,6 @@ use Symfony\Component\Security\Core\User\UserInterface; /** * Class FOSUBUserProvider. - * - * @package Chamilo\UserBundle\Security */ class FOSUBUserProvider extends BaseFOSUBProvider { diff --git a/src/UserBundle/Security/LoginFormAuthenticator.php b/src/UserBundle/Security/LoginFormAuthenticator.php index c2325f0943..79d43970b5 100644 --- a/src/UserBundle/Security/LoginFormAuthenticator.php +++ b/src/UserBundle/Security/LoginFormAuthenticator.php @@ -1,4 +1,5 @@