Fix php format

pull/3064/head
Julio 5 years ago
parent 38accd6543
commit 2bf9cf39cc
  1. 2
      ecs.yaml
  2. 2
      src/CoreBundle/Component/Editor/Driver/CourseDriver.php
  3. 2
      src/CoreBundle/Component/Editor/Finder.php
  4. 6
      src/CoreBundle/EventListener/ResourceUploadListener.php
  5. 6
      src/CoreBundle/EventListener/UserLocaleListener.php
  6. 14
      src/CoreBundle/Hook/HookObserver.php
  7. 4
      src/CoreBundle/Menu/NavBuilder.php
  8. 14
      src/CoreBundle/Repository/ResourceRepository.php
  9. 9
      src/CoreBundle/Resources/config/services.yml
  10. 7
      src/CoreBundle/Security/Authorization/Voter/CourseVoter.php
  11. 6
      src/CoreBundle/Security/Authorization/Voter/GroupVoter.php
  12. 7
      src/CoreBundle/Security/Authorization/Voter/SessionVoter.php
  13. 26
      src/CourseBundle/Component/CourseCopy/CourseRestorer.php
  14. 20
      src/LtiBundle/Entity/ExternalTool.php
  15. 4
      src/SettingsBundle/Manager/SettingsManager.php
  16. 1
      src/ThemeBundle/Theme/ThemeManager.php
  17. 2
      src/UserBundle/Admin/UserAdmin.php
  18. 18
      src/UserBundle/Form/Type/AttributeValueType.php
  19. 3
      src/UserBundle/Repository/UserRepository.php
  20. 9
      src/UserBundle/Security/LoginFormAuthenticator.php

@ -2,3 +2,5 @@ parameters:
sets:
- 'clean-code'
- 'symfony'
skip:
SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff: ~

@ -14,7 +14,6 @@ class CourseDriver extends Driver implements DriverInterface
{
public $name = 'CourseDriver';
public $visibleFiles = [];
private $coursePath;
/**
* Setups the folder.
@ -30,7 +29,6 @@ class CourseDriver extends Driver implements DriverInterface
$coursePath = api_get_path(SYS_COURSE_PATH);
$courseDir = $course->getDirectory().'/document';
$baseDir = $coursePath.$courseDir;
$this->coursePath = $baseDir;
$courseInfo = $this->getCourseInfoArray();
// Creates shared folder

@ -145,7 +145,7 @@ class Finder extends \elFinder
$_req = 'POST' == $_SERVER['REQUEST_METHOD'] ? $_POST : $_GET;
$_reqCmd = isset($_req['cmd']) ? $_req['cmd'] : '';
foreach ($opts['bind'] as $cmd => $handlers) {
$doRegist = (false !== strpos($cmd, '*'));
$doRegist = false !== strpos($cmd, '*');
if (!$doRegist) {
$_getcmd = create_function('$cmd', 'list($ret) = explode(\'.\', $cmd);return trim($ret);');
$doRegist = ($_reqCmd && in_array($_reqCmd, array_map($_getcmd, explode(' ', $cmd))));

@ -18,15 +18,15 @@ class ResourceUploadListener
/**
* @var ObjectManager
*/
private $om;
//private $om;
private $router;
/**
* ResourceUploadListener constructor.
*/
public function __construct(ObjectManager $om, RouterInterface $router)
public function __construct(RouterInterface $router)
{
$this->om = $om;
//$this->om = $om;
$this->router = $router;
}

@ -22,15 +22,15 @@ class UserLocaleListener
/** @var SessionInterface */
private $session;
/** @var SettingsManager */
private $settings;
//private $settings;
/**
* UserLocaleListener constructor.
*/
public function __construct(SessionInterface $session, SettingsManager $settings)
public function __construct(SessionInterface $session)
{
$this->session = $session;
$this->settings = $settings;
//$this->settings = $settings;
}
/**

@ -1,11 +1,6 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This file contains an abstract Hook observer class
* Used for Hook Observers in plugins, called when a hook event happens
* (e.g Create user, Webservice registration).
*/
namespace Chamilo\CoreBundle\Hook;
@ -17,12 +12,14 @@ use Doctrine\ORM\EntityManager;
* This abstract class implements Hook Observer Interface to build the base
* for Hook Observer. This class have some public static method,
* e.g for create Hook Observers.
* This file contains an abstract Hook observer class
* Used for Hook Observers in plugins, called when a hook event happens
* (e.g Create user, Webservice registration).
*/
abstract class HookObserver implements HookObserverInterface
{
public $path;
public $pluginName;
private $entityManager;
/**
@ -39,6 +36,11 @@ abstract class HookObserver implements HookObserverInterface
$this->pluginName = $pluginName;
}
public function getEntityManager()
{
return $this->entityManager;
}
public function setEntityManager(EntityManager $entityManager)
{
$this->entityManager = $entityManager;

@ -19,12 +19,10 @@ class NavBuilder implements ContainerAwareInterface
{
use ContainerAwareTrait;
private $regexVoter;
private $factory;
public function __construct(MenuVoter $regexVoter, FactoryInterface $factory)
public function __construct(FactoryInterface $factory)
{
$this->regexVoter = $regexVoter;
$this->factory = $factory;
}

@ -15,7 +15,6 @@ use Chamilo\CoreBundle\Entity\Resource\ResourceNode;
use Chamilo\CoreBundle\Entity\Resource\ResourceRight;
use Chamilo\CoreBundle\Entity\Resource\ResourceType;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\Tool;
use Chamilo\CoreBundle\Entity\Usergroup;
use Chamilo\CoreBundle\Security\Authorization\Voter\ResourceNodeVoter;
use Chamilo\CourseBundle\Entity\CGroupInfo;
@ -779,19 +778,6 @@ class ResourceRepository extends BaseEntityRepository
return $settings;
}
/**
* @param string $tool
*
* @return Tool|null
*/
private function getTool($tool)
{
return $this
->getEntityManager()
->getRepository('ChamiloCoreBundle:Tool')
->findOneBy(['name' => $tool]);
}
private function setLinkVisibility(AbstractResource $resource, int $visibility, bool $recursive = true): bool
{
$resourceNode = $resource->getResourceNode();

@ -62,7 +62,6 @@ services:
- '@doctrine.orm.entity_manager'
- '@Chamilo\CoreBundle\Repository\CourseRepository'
- '@security.authorization_checker'
- '@service_container'
public: false
tags:
- {name: security.voter}
@ -76,7 +75,6 @@ services:
- '@doctrine.orm.entity_manager'
- '@Chamilo\CoreBundle\Repository\CourseRepository'
- '@security.authorization_checker'
- '@service_container'
public: false
tags:
- {name: security.voter}
@ -173,9 +171,7 @@ services:
- {name: kernel.event_subscriber, priority: 15}
# User locale listener
chamilo_core.listener.user_locale_listener:
class: Chamilo\CoreBundle\EventListener\UserLocaleListener
arguments: ['@session', '@chamilo.settings.manager']
Chamilo\CoreBundle\EventListener\UserLocaleListener:
tags:
- {name: kernel.event_listener, event: security.interactive_login, method: onInteractiveLogin, priority: 15}
@ -211,7 +207,7 @@ services:
# Course upload listener
chamilo_core.listener.resource_upload_listener:
class: Chamilo\CoreBundle\EventListener\ResourceUploadListener
arguments: ['@doctrine.orm.entity_manager', '@router']
arguments: ['@router']
tags:
- {name: kernel.event_listener, event: oneup_uploader.post_persist, method: onUpload}
@ -221,7 +217,6 @@ services:
chamilo_core.menu.nav_builder:
class: Chamilo\CoreBundle\Menu\NavBuilder
arguments: ['@menu.voter.regex']
calls:
- [setContainer, ['@service_container']]
tags:

@ -5,12 +5,10 @@
namespace Chamilo\CoreBundle\Security\Authorization\Voter;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Manager\CourseManager;
use Chamilo\CoreBundle\Repository\CourseRepository;
use Chamilo\UserBundle\Entity\User;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
@ -28,18 +26,15 @@ class CourseVoter extends Voter
private $entityManager;
private $courseManager;
private $authorizationChecker;
private $container;
public function __construct(
EntityManagerInterface $entityManager,
CourseRepository $courseManager,
AuthorizationCheckerInterface $authorizationChecker,
ContainerInterface $container
AuthorizationCheckerInterface $authorizationChecker
) {
$this->entityManager = $entityManager;
$this->courseManager = $courseManager;
$this->authorizationChecker = $authorizationChecker;
$this->container = $container;
}
/**

@ -8,7 +8,6 @@ use Chamilo\CoreBundle\Repository\CourseRepository;
use Chamilo\CourseBundle\Entity\CGroupInfo;
use Chamilo\CourseBundle\Repository\CGroupInfoRepository;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
@ -27,20 +26,17 @@ class GroupVoter extends Voter
private $courseManager;
private $groupManager;
private $authorizationChecker;
private $container;
public function __construct(
EntityManager $entityManager,
CourseRepository $courseManager,
CGroupInfoRepository $groupManager,
AuthorizationCheckerInterface $authorizationChecker,
ContainerInterface $container
AuthorizationCheckerInterface $authorizationChecker
) {
$this->entityManager = $entityManager;
$this->courseManager = $courseManager;
$this->groupManager = $groupManager;
$this->authorizationChecker = $authorizationChecker;
$this->container = $container;
}
/**

@ -4,13 +4,11 @@
namespace Chamilo\CoreBundle\Security\Authorization\Voter;
use Chamilo\CoreBundle\Entity\Manager\CourseManager;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Repository\CourseRepository;
use Chamilo\UserBundle\Entity\User;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Authorization\Voter\Voter;
@ -28,18 +26,15 @@ class SessionVoter extends Voter
private $entityManager;
private $courseManager;
private $authorizationChecker;
private $container;
public function __construct(
EntityManagerInterface $entityManager,
CourseRepository $courseManager,
AuthorizationCheckerInterface $authorizationChecker,
ContainerInterface $container
AuthorizationCheckerInterface $authorizationChecker
) {
$this->entityManager = $entityManager;
$this->courseManager = $courseManager;
$this->authorizationChecker = $authorizationChecker;
$this->container = $container;
}
/**

@ -1481,7 +1481,7 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'id' => (false === $tool_intro->id ? '' : self::DBUTF8($tool_intro->id)),
'id' => false === $tool_intro->id ? '' : self::DBUTF8($tool_intro->id),
'intro_text' => self::DBUTF8($tool_intro->intro_text),
'session_id' => $sessionId,
];
@ -1522,7 +1522,7 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'title' => self::DBUTF8($event->title),
'content' => (false === $event->content ? '' : self::DBUTF8($event->content)),
'content' => false === $event->content ? '' : self::DBUTF8($event->content),
'all_day' => $event->all_day,
'start_date' => $event->start_date,
'end_date' => $event->end_date,
@ -1646,7 +1646,7 @@ class CourseRestorer
$params['c_id'] = $this->destination_course_id;
$params['description_type'] = self::DBUTF8($descriptionType);
$params['title'] = self::DBUTF8($title);
$params['content'] = (false === $description_content ? '' : self::DBUTF8($description_content));
$params['content'] = false === $description_content ? '' : self::DBUTF8($description_content);
$params['progress'] = 0;
$id = Database::insert($table, $params);
@ -1687,7 +1687,7 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'title' => self::DBUTF8($announcement->title),
'content' => (false === $announcement->content ? '' : self::DBUTF8($announcement->content)),
'content' => false === $announcement->content ? '' : self::DBUTF8($announcement->content),
'end_date' => $announcement->date,
'display_order' => $announcement->display_order,
'email_sent' => $announcement->email_sent,
@ -1846,7 +1846,7 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'title' => self::DBUTF8($quiz->title),
'description' => (false === $quiz->description ? '' : self::DBUTF8($quiz->description)),
'description' => false === $quiz->description ? '' : self::DBUTF8($quiz->description),
'type' => isset($quiz->quiz_type) ? (int) $quiz->quiz_type : $quiz->type,
'random' => (int) $quiz->random,
'active' => $quiz->active,
@ -1968,7 +1968,7 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'question' => self::DBUTF8($question->question),
'description' => (false === $question->description ? '' : self::DBUTF8($question->description)),
'description' => false === $question->description ? '' : self::DBUTF8($question->description),
'ponderation' => self::DBUTF8($question->ponderation),
'position' => self::DBUTF8($question->position),
'type' => self::DBUTF8($question->quiz_type),
@ -2081,7 +2081,7 @@ class CourseRestorer
'question_id' => $new_id,
'answer' => self::DBUTF8($answer['answer']),
'correct' => $answer['correct'],
'comment' => (false === $answer['comment'] ? '' : self::DBUTF8($answer['comment'])),
'comment' => false === $answer['comment'] ? '' : self::DBUTF8($answer['comment']),
'ponderation' => $answer['ponderation'],
'position' => $answer['position'],
'hotspot_coordinates' => $answer['hotspot_coordinates'],
@ -2378,8 +2378,8 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'code' => self::DBUTF8($survey->code),
'title' => (false === $survey->title ? '' : self::DBUTF8($survey->title)),
'subtitle' => (false === $survey->subtitle ? '' : self::DBUTF8($survey->subtitle)),
'title' => false === $survey->title ? '' : self::DBUTF8($survey->title),
'subtitle' => false === $survey->subtitle ? '' : self::DBUTF8($survey->subtitle),
'author' => self::DBUTF8($survey->author),
'lang' => self::DBUTF8($survey->lang),
'avail_from' => self::DBUTF8($survey->avail_from),
@ -2563,7 +2563,7 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'survey_id' => self::DBUTF8($survey_id),
'survey_question' => (false === $question->survey_question ? '' : self::DBUTF8($question->survey_question)),
'survey_question' => false === $question->survey_question ? '' : self::DBUTF8($question->survey_question),
'survey_question_comment' => self::DBUTF8($question->survey_question_comment),
'type' => self::DBUTF8($question->survey_question_type),
'display' => self::DBUTF8($question->display),
@ -2595,7 +2595,7 @@ class CourseRestorer
$params = [
'c_id' => $this->destination_course_id,
'question_id' => $new_id,
'option_text' => (false === $answer['option_text'] ? '' : self::DBUTF8($answer['option_text'])),
'option_text' => false === $answer['option_text'] ? '' : self::DBUTF8($answer['option_text']),
'sort' => $answer['sort'],
'survey_id' => self::DBUTF8($survey_id),
];
@ -3081,7 +3081,7 @@ class CourseRestorer
);
$params['c_id'] = $this->destination_course_id;
$params['description'] = (false === $glossary->description ? '' : self::DBUTF8($glossary->description));
$params['description'] = false === $glossary->description ? '' : self::DBUTF8($glossary->description);
$params['display_order'] = $glossary->display_order;
$params['name'] = self::DBUTF8($glossary->name);
$params['glossary_id'] = 0;
@ -3137,7 +3137,7 @@ class CourseRestorer
'page_id' => self::DBUTF8($wiki->page_id),
'reflink' => self::DBUTF8($wiki->reflink),
'title' => self::DBUTF8($wiki->title),
'content' => (false === $wiki->content ? '' : self::DBUTF8($wiki->content)),
'content' => false === $wiki->content ? '' : self::DBUTF8($wiki->content),
'user_id' => intval($wiki->user_id),
'group_id' => intval($wiki->group_id),
'dtime' => self::DBUTF8($wiki->dtime),

@ -496,4 +496,24 @@ class ExternalTool
return $newKey;
}
/**
* @return ArrayCollection
*/
public function getChildren(): ArrayCollection
{
return $this->children;
}
/**
* @param ArrayCollection $children
*
* @return ExternalTool
*/
public function setChildren(ArrayCollection $children): self
{
$this->children = $children;
return $this;
}
}

@ -1016,7 +1016,7 @@ class SettingsManager implements SettingsManagerInterface
return $parameters;
}
private function transformParameters(SettingsBuilder $settingsBuilder, array $parameters)
/*private function transformParameters(SettingsBuilder $settingsBuilder, array $parameters)
{
$transformedParameters = $parameters;
@ -1027,5 +1027,5 @@ class SettingsManager implements SettingsManagerInterface
}
return $transformedParameters;
}
}*/
}

@ -57,7 +57,6 @@ class ThemeManager implements ContainerAwareInterface
{
$unsorted = [];
$srcList = [];
$assetList = [];
foreach ($this->javascripts as $id => $scriptDefinition) {
if ($scriptDefinition['location'] == $location) {
$unsorted[$id] = $scriptDefinition;

@ -38,8 +38,6 @@ class UserAdmin extends BaseUserAdmin
->with('ExtraFields', ['class' => 'col-md-4'])->end()
->end();
$now = new \DateTime();
$formMapper
->tab('User')
->with('General')

@ -109,24 +109,6 @@ class AttributeValueType extends AbstractResourceType
*/
public function getName()
{
//return sprintf('sylius_%s_attribute_value', $this->subjectName);
return sprintf('chamilo_%s_extra_field_value', $this->subjectName);
}
/**
* Get attributes.
*
* @return AttributeInterface[]
*/
private function getAttributes(FormBuilderInterface $builder)
{
/** @var \Symfony\Component\Form\FormBuilder $extraField */
$extraField = $builder->get('extraField');
if ($extraField->hasOption('choice_list')) {
return $extraField->getOption('choice_list')->getChoices();
}
return [];
}
}

@ -1368,9 +1368,6 @@ class UserRepository extends ResourceRepository
$user->setCommentedUserSkills([]);
$extraFieldValues = new \ExtraFieldValue('user');
$items = $extraFieldValues->getAllValuesByItem($userId);
//$user->setExtraFields($items);
//$user->setExtraFields([]);
$lastLogin = $user->getLastLogin();
if (empty($lastLogin)) {

@ -6,9 +6,7 @@ namespace Chamilo\UserBundle\Security;
use Chamilo\CoreBundle\Hook\CheckLoginCredentialsHook;
use Chamilo\CoreBundle\Hook\HookFactory;
use Chamilo\SettingsBundle\Manager\SettingsManager;
use Chamilo\UserBundle\Form\LoginType;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
@ -19,7 +17,6 @@ use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Core\Security;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\UserProviderInterface;
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticator;
/**
@ -27,25 +24,19 @@ use Symfony\Component\Security\Guard\Authenticator\AbstractFormLoginAuthenticato
*/
class LoginFormAuthenticator extends AbstractFormLoginAuthenticator
{
private $em;
private $router;
private $passwordEncoder;
private $csrfTokenManager;
private $formFactory;
private $hookFactory;
public function __construct(
EntityManager $em,
RouterInterface $router,
UserPasswordEncoderInterface $passwordEncoder,
CsrfTokenManagerInterface $csrfTokenManager,
FormFactoryInterface $formFactory,
HookFactory $hookFactory
) {
$this->em = $em;
$this->router = $router;
$this->passwordEncoder = $passwordEncoder;
$this->csrfTokenManager = $csrfTokenManager;
$this->formFactory = $formFactory;
//$this->settingsManager = $settingsManager;
$this->hookFactory = $hookFactory;

Loading…
Cancel
Save