Minor - format code, remove unused code

pull/3215/head
Julio Montoya 5 years ago
parent 843d7c134f
commit 53594ca32e
  1. 26
      .travis.yml
  2. 2
      composer.json
  3. 2
      config/bundles.php
  4. 2
      config/packages/fos_rest.yaml
  5. 5
      config/packages/framework.yaml
  6. 20
      src/CoreBundle/Controller/ResourceController.php
  7. 4
      src/CoreBundle/Controller/ResourceUploadController.php
  8. 1
      src/CoreBundle/Entity/Resource/AbstractResource.php
  9. 2
      src/CoreBundle/Entity/Resource/ResourceFile.php
  10. 4
      src/CoreBundle/Entity/Resource/ResourceNode.php
  11. 4
      src/CoreBundle/EventListener/LocaleListener.php
  12. 3
      src/CoreBundle/EventListener/LogoutSuccessHandler.php
  13. 3
      src/CoreBundle/EventListener/UserLocaleListener.php
  14. 26
      src/SettingsBundle/Manager/SettingsManager.php

@ -1,4 +1,5 @@
dist: bionic
os: linux
language: php
php:
7.2
@ -38,12 +39,12 @@ before_install:
- php -m
- php -ini | grep memory_limit
# Fix travis error https://github.com/travis-ci/travis-ci/issues/8607
- sudo rm -vf /etc/apt/sources.list.d/*riak*
- rm -vf /etc/apt/sources.list.d/*riak*
- google-chrome-stable --headless --disable-gpu --remote-debugging-port=9222 http://localhost &
# Get Chrome driver
- wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip && unzip chromedriver_linux64.zip
- sudo mv chromedriver /usr/bin
- sudo chmod +x /usr/bin/chromedriver
- mv chromedriver /usr/bin
- chmod +x /usr/bin/chromedriver
- chromedriver --version
# Get Selenium
@ -53,8 +54,8 @@ before_install:
- java -jar selenium-server-standalone-3.141.59.jar -log selenium.log > /dev/null &
# Use default config
- sudo apt-get update
- sudo apt-get install php php-mysql php-xml php-gd php-intl php-soap php-bcmath
- apt-get update
- apt-get install php php-mysql php-xml php-gd php-intl php-soap php-bcmath
#- sudo apt-get install php7.3 php7.3-mysql php7.3-xml php7.3-gd php7.3-intl php7.3-soap php7.3-bcmath
#- sudo a2enmod rewrite actions fastcgi alias
@ -63,8 +64,8 @@ before_install:
- bash tests/travis/setup-apache.sh
# Starting Apache
- sudo service apache2 restart
- sudo cat /etc/hosts
- service apache2 restart
- cat /etc/hosts
- curl http://localhost/php.php
install:
@ -73,16 +74,16 @@ install:
# Install bundle js/css
- php bin/console assets:install
# Permissions
- sudo chmod -R 777 var public
- chmod -R 777 var public
# Dump js routes
- php bin/console fos:js-routing:dump --format=json --target=public/js/fos_js_routes.json
# Install third party js/css libraries
- yarn install
- ./node_modules/.bin/encore dev
# Permissions
- sudo chown -R www-data:www-data $TRAVIS_BUILD_DIR
- sudo chown -R 775 $TRAVIS_BUILD_DIR
- sudo chmod +x /home/travis/build
- chown -R www-data:www-data $TRAVIS_BUILD_DIR
- chown -R 775 $TRAVIS_BUILD_DIR
- chmod +x /home/travis/build
- ls -la public/build
script:
@ -121,8 +122,9 @@ script:
- ../../vendor/behat/behat/bin/behat features/toolLink.feature -v
- ../../vendor/behat/behat/bin/behat features/toolLp.feature -v
- ../../vendor/behat/behat/bin/behat features/toolWork.feature -v
after_failure:
- sudo cat /var/log/apache2/error.log
- cat /var/log/apache2/error.log
# configure notifications (email, IRC, campfire etc)
notifications:

@ -54,7 +54,7 @@
"doctrine/doctrine-fixtures-bundle": "^3.0",
"doctrine/doctrine-migrations-bundle": "~2.0",
"doctrine/orm": "~2.7",
"endroid/qr-code": "~3.4",
"endroid/qr-code": "~3.7",
"erusev/parsedown": "~1.7",
"essence/essence": "~3.0",
"ext-bcmath": "*",

@ -2,7 +2,6 @@
return [
Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
@ -72,4 +71,5 @@ return [
Translation\Bundle\TranslationBundle::class => ['all' => true],
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
Twig\Extra\TwigExtraBundle\TwigExtraBundle::class => ['all' => true],
Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
];

@ -5,7 +5,7 @@ fos_rest:
format_listener:
rules:
- {path: '^/api', priorities:['json'], fallback_format: json, prefer_extension: false}
- {path: '^/', priorities: [ 'html', '*/*'], fallback_format: ~, prefer_extension: true}
- {path: '^/', priorities: ['html', '*/*'], fallback_format: ~, prefer_extension: true}
view:
view_response_listener: true
# formats:

@ -9,8 +9,9 @@ framework:
templating:
engines: ['twig']
session:
# handler_id set to null will use default session handler from php.ini
handler_id: session.handler.native_file
# # handler_id set to null will use default session handler from php.ini
# handler_id: session.handler.native_file
# save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%'
name: chamilo2
http_method_override: true
annotations:

@ -134,12 +134,6 @@ class ResourceController extends AbstractResourceController implements CourseCon
$grid->setRouteUrl($this->generateUrl($routeName, $resourceParams));
//$grid->hideFilters();
//$grid->setLimits(20);
//$grid->isReadyForRedirect();
//$grid->setMaxResults(1);
//$grid->setLimits(2);
//$grid->setColumns($columns);
$routeParams = $resourceParams;
$routeParams['id'] = null;
@ -329,15 +323,16 @@ class ResourceController extends AbstractResourceController implements CourseCon
$setVisibleParameters = function (RowAction $action, Row $row) use ($routeParams) {
/** @var AbstractResource $resource */
$resource = $row->getEntity();
$allowedEdit = $this->isGranted(ResourceNodeVoter::EDIT, $resource->getResourceNode());
$resourceNode = $resource->getResourceNode();
$allowedEdit = $this->isGranted(ResourceNodeVoter::EDIT, $resourceNode);
if (false === $allowedEdit) {
return null;
}
$id = $resource->getResourceNode()->getId();
$id = $resourceNode->getId();
$icon = 'fa-eye-slash';
if ($this->hasCourse()) {
$link = $resource->getCourseSessionResourceLink($this->getCourse(), $this->getSession());
} else {
@ -347,6 +342,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
if (null === $link) {
return null;
}
if (ResourceLink::VISIBILITY_PUBLISHED === $link->getVisibility()) {
$icon = 'fa-eye';
}
@ -379,7 +375,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
}
// More action.
$myRowAction = new RowAction(
/*$myRowAction = new RowAction(
$this->trans('More'),
'chamilo_core_resource_preview',
false,
@ -388,7 +384,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
);
$myRowAction->addManipulateRender($setNodeParameters);
$grid->addRowAction($myRowAction);
$grid->addRowAction($myRowAction);*/
// Delete action.
$myRowAction = new RowAction(
@ -775,7 +771,7 @@ class ResourceController extends AbstractResourceController implements CourseCon
}
$em->remove($resourceNode);
$this->addFlash('success', $this->trans('Deleted'));
$this->addFlash('success', $this->trans('Deleted').': '.$resourceNode->getSlug());
$em->flush();
$routeParams = $this->getResourceParams($request);

@ -26,8 +26,6 @@ class ResourceUploadController extends BlueimpController
/**
* This will upload an image to the selected node id.
* This action is listend by the ResourceUploadListener.
*
* @return JsonResponse
*/
public function upload(): JsonResponse
{
@ -77,13 +75,11 @@ class ResourceUploadController extends BlueimpController
/** @var UploadedFile $file */
foreach ($files as $file) {
try {
//$title = $file->getClientOriginalName();
if (!($file instanceof FileInterface)) {
$file = new FilesystemFile($file);
}
$this->validate($file, $request, $response);
$this->dispatchPreUploadEvent($file, $response, $request);
$resource = $repo->saveUpload($file, $course, $session);

@ -97,6 +97,7 @@ abstract class AbstractResource
$result = null;
if ($resourceNode && $resourceNode->getResourceLinks()->count() > 0) {
$result = $resourceNode->getResourceLinks()->matching($criteria)->first();
if ($result) {
return $result;
}

@ -122,7 +122,7 @@ class ResourceFile
/**
* @var ResourceNode
*
* @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="resourceFile", fetch="EAGER")
* @ORM\OneToOne(targetEntity="Chamilo\CoreBundle\Entity\Resource\ResourceNode", mappedBy="resourceFile")
*/
protected $resourceNode;

@ -74,7 +74,7 @@ class ResourceNode
/**
* @var ResourceLink[]
*
* @ORM\OneToMany(targetEntity="ResourceLink", mappedBy="resourceNode", cascade={"remove"}, fetch="EAGER")
* @ORM\OneToMany(targetEntity="ResourceLink", mappedBy="resourceNode", cascade={"remove"})
*/
protected $resourceLinks;
@ -82,7 +82,7 @@ class ResourceNode
* @var ResourceFile
* @Groups({"list"})
*
* @ORM\OneToOne(targetEntity="ResourceFile", inversedBy="resourceNode", orphanRemoval=true, fetch="EAGER")
* @ORM\OneToOne(targetEntity="ResourceFile", inversedBy="resourceNode", orphanRemoval=true)
* @ORM\JoinColumn(name="resource_file_id", referencedColumnName="id", onDelete="CASCADE")
*/
protected $resourceFile;

@ -46,6 +46,7 @@ class LocaleListener implements EventSubscriberInterface
if (!$installed) {
return;
}
// Try to see if the locale has been set as a _locale routing parameter (from lang switcher)
//if ($locale = $request->getSession('_locale')) {
if (false) {
@ -62,12 +63,11 @@ class LocaleListener implements EventSubscriberInterface
if (!empty($platformLocale)) {
$localeList['platform_lang'] = $platformLocale;
}
// 2. Check user locale
// _locale_user is set when user logins the system check UserLocaleListener
$userLocale = $request->getSession()->get('_locale_user');
if (!empty($userLocale)) {
//$locale = $userLocale;
$localeList['user_profil_lang'] = $userLocale;
}

@ -73,9 +73,6 @@ class LogoutSuccessHandler implements LogoutSuccessHandlerInterface
$query = 'DELETE FROM '.$online_table." WHERE login_user_id = $userId";
Database::query($query);
/*require_once api_get_path(SYS_PATH) . 'main/chat/chat_functions.lib.php';
exit_of_chat($userId);*/
$login = $this->router->generate('home');
return new RedirectResponse($login);

@ -21,8 +21,6 @@ class UserLocaleListener
{
/** @var SessionInterface */
private $session;
/** @var SettingsManager */
//private $settings;
/**
* UserLocaleListener constructor.
@ -30,7 +28,6 @@ class UserLocaleListener
public function __construct(SessionInterface $session)
{
$this->session = $session;
//$this->settings = $settings;
}
/**

@ -75,6 +75,7 @@ class SettingsManager implements SettingsManagerInterface
$this->repository = $repository;
$this->eventDispatcher = $eventDispatcher;
$this->request = $request;
$this->schemaList = [];
}
/**
@ -200,26 +201,15 @@ class SettingsManager implements SettingsManagerInterface
public function loadAll()
{
$session = $this->request->getCurrentRequest()->getSession();
/*$session = $this->request->getCurrentRequest()->getSession();
$schemaList = $session->get('schemas');
if (!empty($schemaList)) {
$this->schemaList = $schemaList;
return true;
}
*/
if (empty($this->schemaList)) {
$schemas = array_keys($this->getSchemas());
/**
* @var string
* @var SchemaInterface $schema
*/
$schemaList = [];
$settingsBuilder = new SettingsBuilder();
$all = $this->getAllParametersByCategory();
/** @var SchemaInterface $schema */
foreach ($schemas as $schema) {
$schemaRegister = $this->schemaRegistry->get($schema);
$schemaRegister->buildSettings($settingsBuilder);
@ -237,13 +227,12 @@ class SettingsManager implements SettingsManagerInterface
}
}
}
$parameters = $settingsBuilder->resolve($parameters);
$settings->setParameters($parameters);
$schemaList[$name] = $settings;
}
$this->schemaList = $schemaList;
$session->set('schemas', $schemaList);
//$session->set('schemas', $schemaList);
}
}
@ -318,9 +307,8 @@ class SettingsManager implements SettingsManagerInterface
}
}
$settings->setParameters($parameters);
$persistedParameters = $this->repository->findBy(
['category' => $this->convertServiceToNameSpace($settings->getSchemaAlias())]
);
$category = $this->convertServiceToNameSpace($settings->getSchemaAlias());
$persistedParameters = $this->repository->findBy(['category' => $category]);
$persistedParametersMap = [];
/** @var SettingsCurrent $parameter */

Loading…
Cancel
Save