diff --git a/public/main/lp/learnpath.class.php b/public/main/lp/learnpath.class.php index 5f64b92d75..f090b0c12c 100644 --- a/public/main/lp/learnpath.class.php +++ b/public/main/lp/learnpath.class.php @@ -4347,7 +4347,6 @@ class learnpath /** * Publishes a learnpath. This basically means show or hide the learnpath * on the course homepage - * Can be used as abstract. * * @param int $id Learnpath id * @param string $setVisibility New visibility (v/i - visible/invisible) @@ -4367,7 +4366,6 @@ class learnpath return false; } $repoShortcut = Container::getShortcutRepository(); - $em = $repoShortcut->getEntityManager(); $courseEntity = api_get_course_entity(); if ($addShortcut) { diff --git a/src/CoreBundle/Controller/EditorController.php b/src/CoreBundle/Controller/EditorController.php index a170fabe08..3ace28bb0a 100644 --- a/src/CoreBundle/Controller/EditorController.php +++ b/src/CoreBundle/Controller/EditorController.php @@ -70,7 +70,7 @@ class EditorController extends BaseController * * @param int $parentId */ - public function customEditorFileManager(ResourceFactory $resourceFactory, Request $request, $tool, $type, Grid $grid, $parentId = 0): Response + public function customEditorFileManager(ResourceFactory $resourceFactory, Request $request, $tool, $type, $parentId = 0): Response { $id = $request->get('id'); diff --git a/src/CoreBundle/Controller/ResourceController.php b/src/CoreBundle/Controller/ResourceController.php index c2ff8a39f2..79eef6fea2 100644 --- a/src/CoreBundle/Controller/ResourceController.php +++ b/src/CoreBundle/Controller/ResourceController.php @@ -91,7 +91,7 @@ class ResourceController extends AbstractResourceController implements CourseCon ); } - public function getGrid(Request $request, ResourceRepository $repository, Grid $grid, int $resourceNodeId, string $routeName): Grid + public function getGrid(Request $request, ResourceRepository $repository, int $resourceNodeId, string $routeName): Grid { $class = $repository->getRepository()->getClassName(); diff --git a/src/CoreBundle/Hook/HookEvent.php b/src/CoreBundle/Hook/HookEvent.php index 7af663fb39..a8bc8f6a96 100644 --- a/src/CoreBundle/Hook/HookEvent.php +++ b/src/CoreBundle/Hook/HookEvent.php @@ -82,7 +82,7 @@ abstract class HookEvent implements HookEventInterface */ public static function create(EntityManager $entityManager) { - static $result = null; + /*static $result = null; if ($result) { return $result; @@ -94,7 +94,7 @@ abstract class HookEvent implements HookEventInterface return new $class($entityManager); } catch (\Exception $e) { return null; - } + }*/ } /** diff --git a/src/CoreBundle/Hook/HookManagement.php b/src/CoreBundle/Hook/HookManagement.php index 401fac792d..fdae38806a 100644 --- a/src/CoreBundle/Hook/HookManagement.php +++ b/src/CoreBundle/Hook/HookManagement.php @@ -134,7 +134,7 @@ class HookManagement implements HookManagementInterface */ public function orderHook($eventName, $type, $hookOrders) { - foreach ($this->hookCalls[$eventName] as $observerClassName => $types) { + /*foreach ($this->hookCalls[$eventName] as $observerClassName => $types) { foreach ($hookOrders as $oldOrder => $newOrder) { $res = Database::update( $this->tables[TABLE_HOOK_CALL], @@ -151,7 +151,7 @@ class HookManagement implements HookManagementInterface break; } } - } + }*/ } /** diff --git a/src/CoreBundle/Hook/HookNotificationContent.php b/src/CoreBundle/Hook/HookNotificationContent.php index d917eebfbe..0bf371dffc 100644 --- a/src/CoreBundle/Hook/HookNotificationContent.php +++ b/src/CoreBundle/Hook/HookNotificationContent.php @@ -26,9 +26,8 @@ class HookNotificationContent extends HookEvent implements HookNotificationConte */ public function notifyNotificationContent($type): array { - /** @var \HookNotificationContentObserverInterface $observer */ // Check if exists data content - if (isset($this->eventData['content'])) { + /*if (isset($this->eventData['content'])) { // Save data type $this->eventData['type'] = $type; // Check for hook all registered observers @@ -44,6 +43,6 @@ class HookNotificationContent extends HookEvent implements HookNotificationConte return $this->eventData; } - return []; + return [];*/ } } diff --git a/src/CoreBundle/Hook/HookNotificationTitle.php b/src/CoreBundle/Hook/HookNotificationTitle.php index f8328bf506..8d05d2c939 100644 --- a/src/CoreBundle/Hook/HookNotificationTitle.php +++ b/src/CoreBundle/Hook/HookNotificationTitle.php @@ -28,9 +28,8 @@ class HookNotificationTitle extends HookEvent implements HookNotificationTitleEv */ public function notifyNotificationTitle($type): array { - /** @var \HookNotificationTitleObserverInterface $observer */ // Check if exists data title - if (isset($this->eventData['title'])) { + /*if (isset($this->eventData['title'])) { // Save data type $this->eventData['type'] = $type; // Check for hook all registered observers @@ -45,7 +44,7 @@ class HookNotificationTitle extends HookEvent implements HookNotificationTitleEv } return $this->eventData; - } + }*/ return []; } diff --git a/src/CoreBundle/Hook/HookObserver.php b/src/CoreBundle/Hook/HookObserver.php index 196b60e862..25944c05b0 100644 --- a/src/CoreBundle/Hook/HookObserver.php +++ b/src/CoreBundle/Hook/HookObserver.php @@ -54,7 +54,7 @@ abstract class HookObserver implements HookObserverInterface */ public static function create() { - static $result = null; + /*static $result = null; if ($result) { return $result; @@ -66,7 +66,7 @@ abstract class HookObserver implements HookObserverInterface } catch (\Exception $e) { return null; } - } + }*/ } /** diff --git a/src/CoreBundle/Repository/IllustrationRepository.php b/src/CoreBundle/Repository/IllustrationRepository.php index c820757f2f..55232cc03f 100644 --- a/src/CoreBundle/Repository/IllustrationRepository.php +++ b/src/CoreBundle/Repository/IllustrationRepository.php @@ -168,11 +168,6 @@ final class IllustrationRepository extends ResourceRepository implements GridInt return ''; } - public function getTitleColumn(Grid $grid): Column - { - return $grid->getColumn('name'); - } - public function getResourceFormType(): string { return IllustrationType::class; diff --git a/src/CoreBundle/Repository/PersonalFileRepository.php b/src/CoreBundle/Repository/PersonalFileRepository.php index 8eb6cf64c0..7db4ab9e8a 100644 --- a/src/CoreBundle/Repository/PersonalFileRepository.php +++ b/src/CoreBundle/Repository/PersonalFileRepository.php @@ -48,11 +48,6 @@ final class PersonalFileRepository extends ResourceRepository implements GridInt return $newResource; } - public function getTitleColumn(Grid $grid): Column - { - return $grid->getColumn('name'); - } - public function getResourceFormType(): string { return PersonalFileType::class; diff --git a/src/CoreBundle/Repository/ResourceRepository.php b/src/CoreBundle/Repository/ResourceRepository.php index d9855c34b5..11f3f78535 100644 --- a/src/CoreBundle/Repository/ResourceRepository.php +++ b/src/CoreBundle/Repository/ResourceRepository.php @@ -579,22 +579,6 @@ class ResourceRepository extends EntityRepository return $qb->getQuery()->getOneOrNullResult(); } - public function rowCanBeEdited(RowAction $action, Row $row, Session $session = null): ?RowAction - { - if (null !== $session) { - /** @var AbstractResource $entity */ - $entity = $row->getEntity(); - $hasSession = $entity->getResourceNode()->hasSession($session); - if ($hasSession->count() > 0) { - return $action; - } - - return null; - } - - return $action; - } - public function delete(AbstractResource $resource) { $children = $resource->getResourceNode()->getChildren(); diff --git a/src/CoreBundle/Security/Authorization/Voter/CourseVoter.php b/src/CoreBundle/Security/Authorization/Voter/CourseVoter.php index 6f01b6ee04..7f891458f6 100644 --- a/src/CoreBundle/Security/Authorization/Voter/CourseVoter.php +++ b/src/CoreBundle/Security/Authorization/Voter/CourseVoter.php @@ -57,7 +57,7 @@ class CourseVoter extends Voter return true; } - protected function voteOnAttribute(string $attribute, $course, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool { /** @var User $user */ $user = $token->getUser(); @@ -73,6 +73,8 @@ class CourseVoter extends Voter // Course is active? /** @var Course $course */ + $course = $subject; + switch ($attribute) { case self::VIEW: // Course is hidden then is not visible for nobody expect admins. diff --git a/src/CoreBundle/Security/Authorization/Voter/GroupVoter.php b/src/CoreBundle/Security/Authorization/Voter/GroupVoter.php index 786c7b8dc3..df8e9bf286 100644 --- a/src/CoreBundle/Security/Authorization/Voter/GroupVoter.php +++ b/src/CoreBundle/Security/Authorization/Voter/GroupVoter.php @@ -60,7 +60,7 @@ class GroupVoter extends Voter return true; } - protected function voteOnAttribute(string $attribute, $group, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool { $user = $token->getUser(); @@ -69,7 +69,7 @@ class GroupVoter extends Voter return false; } - if (false == $group) { + if (false == $subject) { return false; } @@ -77,7 +77,8 @@ class GroupVoter extends Voter if ($this->security->isGranted('ROLE_ADMIN')) { return true; } - + /** @var CGroup $group */ + $group = $subject; $groupInfo = [ 'id' => $group->getId(), 'session_id' => 0, diff --git a/src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php b/src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php index cb7aed955c..22f5248198 100644 --- a/src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php +++ b/src/CoreBundle/Security/Authorization/Voter/ResourceNodeVoter.php @@ -94,10 +94,7 @@ class ResourceNodeVoter extends Voter return true; } - /** - * @param ResourceNode $resourceNode - */ - protected function voteOnAttribute(string $attribute, $resourceNode, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool { $user = $token->getUser(); @@ -106,6 +103,9 @@ class ResourceNodeVoter extends Voter return false; } + /** @var ResourceNode $group */ + $resourceNode = $subject; + if (!$resourceNode instanceof ResourceNode) { return false; } diff --git a/src/CoreBundle/Security/Authorization/Voter/SessionVoter.php b/src/CoreBundle/Security/Authorization/Voter/SessionVoter.php index b0f66b1736..368157e97f 100644 --- a/src/CoreBundle/Security/Authorization/Voter/SessionVoter.php +++ b/src/CoreBundle/Security/Authorization/Voter/SessionVoter.php @@ -56,7 +56,7 @@ class SessionVoter extends Voter * * {@inheritdoc} */ - protected function voteOnAttribute(string $attribute, $session, TokenInterface $token): bool + protected function voteOnAttribute(string $attribute, $subject, TokenInterface $token): bool { /** @var User $user */ $user = $token->getUser(); @@ -74,6 +74,8 @@ class SessionVoter extends Voter // Checks if the current course was set up // $session->getCurrentCourse() is set in the class CourseListener /** @var Session $session */ + $session = $subject; + $currentCourse = $session->getCurrentCourse(); switch ($attribute) { diff --git a/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php b/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php index 8f7aa0afdf..143ca62b3a 100644 --- a/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php +++ b/src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension; */ class ChamiloCourseExtension extends Extension { - public function load(array $config, ContainerBuilder $container): void + public function load(array $configs, ContainerBuilder $container): void { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); $loader->load('services.yml'); diff --git a/src/CourseBundle/Entity/CShortcut.php b/src/CourseBundle/Entity/CShortcut.php index 68e11bf2b3..dcd3e1dc99 100644 --- a/src/CourseBundle/Entity/CShortcut.php +++ b/src/CourseBundle/Entity/CShortcut.php @@ -6,6 +6,7 @@ namespace Chamilo\CourseBundle\Entity; use Chamilo\CoreBundle\Entity\AbstractResource; use Chamilo\CoreBundle\Entity\ResourceInterface; +use Chamilo\CoreBundle\Entity\ResourceNode; use Doctrine\ORM\Mapping as ORM; use Symfony\Component\Validator\Constraints as Assert; @@ -56,9 +57,6 @@ class CShortcut extends AbstractResource implements ResourceInterface return $this; } - /** - * Resource identifier. - */ public function getResourceIdentifier(): int { return $this->id; @@ -74,10 +72,7 @@ class CShortcut extends AbstractResource implements ResourceInterface return $this->shortCutNode; } - /** - * @return CShortcut - */ - public function setShortCutNode($shortCutNode) + public function setShortCutNode(ResourceNode $shortCutNode): self { $this->shortCutNode = $shortCutNode; diff --git a/src/CourseBundle/Repository/CCourseDescriptionRepository.php b/src/CourseBundle/Repository/CCourseDescriptionRepository.php index 4bad317de6..f1ef42adf9 100644 --- a/src/CourseBundle/Repository/CCourseDescriptionRepository.php +++ b/src/CourseBundle/Repository/CCourseDescriptionRepository.php @@ -45,11 +45,6 @@ final class CCourseDescriptionRepository extends ResourceRepository implements G return $this->getResourcesByCourse($course, $session, $group, $parentNode); } - public function getTitleColumn(Grid $grid): Column - { - return $grid->getColumn('title'); - } - public function setResourceProperties(FormInterface $form, $course, $session, $fileType) { /** @var CCourseDescription $newResource */ diff --git a/src/CourseBundle/Repository/CDocumentRepository.php b/src/CourseBundle/Repository/CDocumentRepository.php index 3e79e48c6f..077f7c744b 100644 --- a/src/CourseBundle/Repository/CDocumentRepository.php +++ b/src/CourseBundle/Repository/CDocumentRepository.php @@ -210,11 +210,6 @@ final class CDocumentRepository extends ResourceRepository implements GridInterf return $query->getResult(); } - public function getTitleColumn(Grid $grid): Column - { - return $grid->getColumn('title'); - } - public function getResourceFormType(): string { return CDocumentType::class; diff --git a/src/CourseBundle/Repository/CGlossaryRepository.php b/src/CourseBundle/Repository/CGlossaryRepository.php index b75da25e14..4baa16bbf7 100644 --- a/src/CourseBundle/Repository/CGlossaryRepository.php +++ b/src/CourseBundle/Repository/CGlossaryRepository.php @@ -45,11 +45,6 @@ final class CGlossaryRepository extends ResourceRepository implements GridInterf return $this->getResourcesByCourse($course, $session, $group, $parentNode); } - public function getTitleColumn(Grid $grid): Column - { - return $grid->getColumn('name'); - } - public function setResourceProperties(FormInterface $form, $course, $session, $fileType) { /** @var CGlossary $newResource */ diff --git a/src/CourseBundle/Repository/CLinkCategoryRepository.php b/src/CourseBundle/Repository/CLinkCategoryRepository.php index c78311f6f9..8d79818068 100644 --- a/src/CourseBundle/Repository/CLinkCategoryRepository.php +++ b/src/CourseBundle/Repository/CLinkCategoryRepository.php @@ -49,11 +49,6 @@ final class CLinkCategoryRepository extends ResourceRepository implements GridIn return $newResource; } - public function getTitleColumn(Grid $grid): Column - { - return $grid->getColumn('title'); - } - public function getResourceFormType(): string { return CLinkType::class; diff --git a/src/CourseBundle/Repository/CLinkRepository.php b/src/CourseBundle/Repository/CLinkRepository.php index e6f1c50911..e3d1b7bbb3 100644 --- a/src/CourseBundle/Repository/CLinkRepository.php +++ b/src/CourseBundle/Repository/CLinkRepository.php @@ -39,11 +39,6 @@ final class CLinkRepository extends ResourceRepository implements GridInterface return $newResource; } - public function getTitleColumn(Grid $grid): Column - { - return $grid->getColumn('title'); - } - public function getResourceFormType(): string { return CLinkType::class; diff --git a/src/CourseBundle/Repository/CQuizRepository.php b/src/CourseBundle/Repository/CQuizRepository.php index 8368f7b7da..f411f16f2f 100644 --- a/src/CourseBundle/Repository/CQuizRepository.php +++ b/src/CourseBundle/Repository/CQuizRepository.php @@ -14,9 +14,9 @@ use Symfony\Component\Routing\RouterInterface; */ final class CQuizRepository extends ResourceRepository implements ResourceWithLinkInterface { - public function getLink(ResourceInterface $exercise, RouterInterface $router, $extraParams = []): string + public function getLink(ResourceInterface $resource, RouterInterface $router, $extraParams = []): string { - $params = ['name' => 'exercise/overview.php', 'exerciseId' => $exercise->getResourceIdentifier()]; + $params = ['name' => 'exercise/overview.php', 'exerciseId' => $resource->getResourceIdentifier()]; if (!empty($extraParams)) { $params = array_merge($params, $extraParams); } diff --git a/src/CourseBundle/Repository/CShortcutRepository.php b/src/CourseBundle/Repository/CShortcutRepository.php index 7dd5bdf777..6e1e5ee0f0 100644 --- a/src/CourseBundle/Repository/CShortcutRepository.php +++ b/src/CourseBundle/Repository/CShortcutRepository.php @@ -36,7 +36,7 @@ final class CShortcutRepository extends ResourceRepository if (null === $shortcut) { $shortcut = new CShortcut(); $shortcut - ->setName($resource->getName()) + ->setName($resource->getResourceName()) ->setShortCutNode($resource->getResourceNode()) ->setParent($parent) ->addCourseLink($course, $session);