Internal: Remove unused code

pull/3451/head
Julio Montoya 4 years ago
parent dfb38163c7
commit 155e7e26b9
  1. 2
      src/CoreBundle/Controller/ResourceApiController.php
  2. 1
      src/CoreBundle/Controller/ResourceController.php
  3. 2
      src/CoreBundle/DependencyInjection/ChamiloCoreExtension.php
  4. 2
      src/CoreBundle/Entity/AbstractResource.php
  5. 16
      src/CoreBundle/Framework/Container.php
  6. 205
      src/CoreBundle/Resources/config/admin.yml
  7. 53
      src/CourseBundle/Admin/CDocumentAdmin.php
  8. 49
      src/CourseBundle/Admin/CGroupInfoAdmin.php
  9. 201
      src/CourseBundle/Admin/CourseAdmin.php
  10. 49
      src/CourseBundle/Admin/CourseCategoryAdmin.php
  11. 73
      src/CourseBundle/Admin/CourseRelUserAdmin.php
  12. 55
      src/CourseBundle/Admin/CourseRequestAdmin.php
  13. 2
      src/CourseBundle/DependencyInjection/ChamiloCourseExtension.php
  14. 67
      src/CourseBundle/Resources/config/admin.yml

@ -95,7 +95,7 @@ class ResourceApiController extends AbstractController implements CourseControll
$repository->getEntityManager()->persist($resource);
$repository->getEntityManager()->flush();
return View::create($comment, Response::HTTP_CREATED);
//return View::create($comment, Response::HTTP_CREATED);
}
}
}

@ -28,6 +28,7 @@ use Chamilo\CourseBundle\Controller\CourseControllerInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Criteria;
use Doctrine\ORM\QueryBuilder;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Symfony\Component\Filesystem\Exception\FileNotFoundException;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\HttpFoundation\JsonResponse;

@ -22,7 +22,7 @@ class ChamiloCoreExtension extends Extension
);
$loader->load('services.yml');
$loader->load('admin.yml');
//$loader->load('admin.yml');
$loader->load('tools.yml');
$loader->load('settings.yml');
$loader->load('repositories.yml');

@ -156,7 +156,7 @@ abstract class AbstractResource
{
$resourceNode = $this->getResourceNode();
if ($resourceNode && $resourceNode->getResourceLinks()) {
if ($resourceNode && $resourceNode->getResourceLinks()->count()) {
$result = $resourceNode->getResourceLinks()->first();
if ($result) {
return $result;

@ -532,22 +532,6 @@ class Container
return self::$container->get('Chamilo\CourseBundle\Repository\CThematicAdvanceRepository');
}
/**
* @param UserManager $manager
*/
public static function setUserManager($manager)
{
self::$userManager = $manager;
}
/**
* @return \Sonata\UserBundle\Entity\GroupManager
*/
public static function getGroupManager()
{
return self::$container->get('fos_user.group_manager');
}
/**
* @return \Symfony\Component\Form\FormFactory
*/

@ -1,205 +0,0 @@
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:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "Session"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\Session
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.session_category:
class: Chamilo\CoreBundle\Admin\SessionCategoryAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "Session category"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\SessionCategory
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.career:
class: Chamilo\CoreBundle\Admin\CareerAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "Career"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\Career
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.promotion:
class: Chamilo\CoreBundle\Admin\PromotionAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "Promotion"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\Promotion
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.session_rel_course:
class: Chamilo\CoreBundle\Admin\SessionRelCourseAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "SessionRelCourseAdmin"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\SessionRelCourse
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.session_rel_user:
class: Chamilo\CoreBundle\Admin\SessionRelUserAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "SessionRelUserAdmin"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\SessionRelUser
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.access_url:
class: Chamilo\CoreBundle\Admin\AccessUrlAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "AccessUrlAdmin"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\AccessUrl
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.access_url_rel_course:
class: Chamilo\CoreBundle\Admin\AccessUrlRelCourseAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "AccessUrlRelCourseAdmin"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\AccessUrlRelCourse
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.settings_current:
class: Chamilo\CoreBundle\Admin\SettingsCurrentAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "Settings"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\SettingsCurrent
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.user_group:
class: Chamilo\CoreBundle\Admin\UserGroupAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "UserGroupAdmin"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\UserGroup
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.user_group_rel_user:
class: Chamilo\CoreBundle\Admin\UsergroupRelUser
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "UsergroupRelUser"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\UsergroupRelUser
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.tool:
class: Chamilo\CoreBundle\Admin\ToolAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "Tool"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\Tool
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.tool_resource_right:
class: Chamilo\CoreBundle\Admin\ToolResourceRightAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "ToolResourceRight"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\ToolResourceRight
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.resource_node:
class: Chamilo\CoreBundle\Admin\ResourceNodeAdmin
tags:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "Resource node"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\ResourceNode
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.resource_file:
class: Chamilo\CoreBundle\Admin\ResourceFileAdmin
tags:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "Resource file"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\ResourceFile
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.resource_link:
class: Chamilo\CoreBundle\Admin\ResourceLinkAdmin
tags:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "Resource link"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\ResourceLink
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.resource_right:
class: Chamilo\CoreBundle\Admin\ResourceRightAdmin
tags:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "Resource right"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\ResourceRight
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.resource_type:
class: Chamilo\CoreBundle\Admin\ResourceTypeAdmin
tags:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "Resource type"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\ResourceType
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]

@ -1,53 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Admin;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Sonata\AdminBundle\Show\ShowMapper;
/**
* Class CDocumentAdmin.
*/
class CDocumentAdmin extends AbstractAdmin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('title')
->add('comment')
->add('resourceNode', ModelAutocompleteType::class, ['property' => 'name'])
;
}
protected function configureShowField(ShowMapper $showMapper)
{
$showMapper
->add('course')
->add('title')
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('course')
->add('session')
->add('title')
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->add('course')
->add('filetype')
->addIdentifier('title')
;
}
}

@ -1,49 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Admin;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
/**
* Class CGroupInfoAdmin.
*/
class CGroupInfoAdmin extends AbstractAdmin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name')
->add('description')
->add('course')
->add('status')
;
}
protected function configureShowField(ShowMapper $showMapper)
{
$showMapper
->add('name')
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('name')
->add('status')
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('name')
;
}
}

@ -1,201 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Admin;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\ToolChain;
use Chamilo\CourseBundle\Entity\CTool;
use FOS\CKEditorBundle\Form\Type\CKEditorType;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\CoreBundle\Form\Type\CollectionType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\LanguageType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
/**
* Class CourseAdmin.
*/
class CourseAdmin extends AbstractAdmin
{
protected $toolChain;
/**
* Setting default values
* {@inheritdoc}
*/
public function getNewInstance()
{
$instance = parent::getNewInstance();
$instance->setVisibility('2');
//$instance->setCourseLanguage($this->getLabelTranslatorStrategy()->getLocale());
return $instance;
}
/**
* Very important in order to save the related entities while updating.
*
* @param Course $course
*
* @return mixed|void
*/
public function preUpdate($course)
{
$course->setUsers($course->getUsers());
$course->setUrls($course->getUrls());
$this->updateTools($course);
}
/**
* Very important in order to save the related entities while creation.
*
* @param Course $course
*
* @return mixed|void
*/
public function prePersist($course)
{
$course->setUsers($course->getUsers());
$course->setUrls($course->getUrls());
$this->updateTools($course);
}
/*
* Generate tool inside the course
* @param Course $course
*/
public function updateTools(Course $course)
{
//$toolChain = $this->getToolChain();
//$tools = $toolChain->getTools();
$currentTools = $course->getTools();
// @todo use
//$toolChain->addToolsInCourse($course);
$addedTools = [];
if (!empty($currentTools)) {
foreach ($currentTools as $tool) {
$addedTools[] = $tool->getName();
}
}
/*foreach ($tools as $tool) {
$toolName = $tool->getName();
if (!in_array($toolName, $addedTools)) {
$toolEntity = new CTool();
$toolEntity
->setCourse($course)
->setName($tool->getName())
->setCategory($tool->getCategory())
;
$course->addTools($toolEntity);
}
}*/
}
public function setToolChain(ToolChain $chainTool)
{
$this->toolChain = $chainTool;
}
/**
* @return ToolChain
*/
public function getToolChain()
{
return $this->toolChain;
}
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('title')
->add('code', TextType::class, [
//'read_only' => true,
])
->add('description', CKEditorType::class)
->add('courseLanguage', LanguageType::class)
->add('departmentName')
->add(
'visibility',
ChoiceType::class,
[
'choices' => Course::getStatusList(),
'translation_domain' => 'ChamiloCoreBundle',
]
)
->add('departmentUrl', UrlType::class, ['required' => false])
->add(
'urls',
CollectionType::class,
[
//'cascade_validation' => true,
],
[
'allow_delete' => true,
'by_reference' => false,
'edit' => 'inline',
'inline' => 'table',
//'btn_add' => true,
//'multiple' => true
//'sortable' => 'position',
//'link_parameters' => array('content' => $users),
'admin_code' => 'sonata.admin.access_url_rel_course',
]
)
->add(
'users',
CollectionType::class,
[
//'cascade_validation' => true,
],
[
'allow_delete' => true,
'by_reference' => false,
'edit' => 'inline',
'inline' => 'table',
//'btn_add' => true,
//'multiple' => true
//'sortable' => 'position',
//'link_parameters' => array('content' => $users),
'admin_code' => 'sonata.admin.course_rel_user',
]
)
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('title')
->add('code')
->add(
'visibility',
null,
[],
ChoiceType::class,
['choices' => Course::getStatusList()]
)
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('title')
->addIdentifier('code')
->add('courseLanguage')
->add('visibility', ChoiceType::class, [
'choices' => Course::getStatusList(),
])
;
}
}

@ -1,49 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Admin;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
/**
* Class CourseCategoryAdmin.
*/
class CourseCategoryAdmin extends AbstractAdmin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('name')
->add('code')
->add('parent')
;
}
protected function configureShowField(ShowMapper $showMapper)
{
$showMapper
->add('id')
->add('name')
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('id')
->add('name')
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('name')
;
}
}

@ -1,73 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Admin;
use Chamilo\CoreBundle\Entity\CourseRelUser;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
/**
* Class CourseAdmin.
*/
class CourseRelUserAdmin extends AbstractAdmin
{
protected function configureShowField(ShowMapper $showMapper)
{
$showMapper
->add('id')
;
}
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('user')
//->add('group', 'text')
->add(
'status',
ChoiceType::class,
[
'choices' => CourseRelUser::getStatusList(),
]
)
->add(
'relation_type',
ChoiceType::class,
[
'choices' => CourseRelUser::getRelationTypeList(),
]
)
->end()
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('course')
->add('user')
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('user')
->addIdentifier('course')
//->addIdentifier('group')
->add(
'status',
'sonata_type_translatable_choice',
[
'choices' => CourseRelUser::getStatusList(),
]
)
;
}
}

@ -1,55 +0,0 @@
<?php
/* For licensing terms, see /license.txt */
namespace Chamilo\CourseBundle\Admin;
use Sonata\AdminBundle\Admin\AbstractAdmin;
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Show\ShowMapper;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
/**
* Class CourseRequestAdmin.
*/
class CourseRequestAdmin extends AbstractAdmin
{
protected function configureFormFields(FormMapper $formMapper)
{
$formMapper
->add('title')
->add('description', TextareaType::class, ['attr' => ['class' => 'ckeditor']])
->add('code')
->add('user')
->add('status')
->add('info')
->add('directory')
->add('exemplaryContent', 'checkbox')
->add('courseLanguage', 'language')
;
}
protected function configureShowField(ShowMapper $showMapper)
{
$showMapper
->add('id')
->add('title')
;
}
protected function configureDatagridFilters(DatagridMapper $datagridMapper)
{
$datagridMapper
->add('title')
;
}
protected function configureListFields(ListMapper $listMapper)
{
$listMapper
->addIdentifier('title')
;
}
}

@ -20,6 +20,6 @@ class ChamiloCourseExtension extends Extension
{
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.yml');
$loader->load('admin.yml');
//$loader->load('admin.yml');
}
}

@ -1,67 +0,0 @@
services:
sonata.admin.course:
class: Chamilo\CourseBundle\Admin\CourseAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "Course"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\Course
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
- [setToolChain, ['@Chamilo\CoreBundle\ToolChain']]
sonata.admin.course_rel_user:
class: Chamilo\CourseBundle\Admin\CourseRelUserAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "CourseRelUser"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\CourseRelUser
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.course_category:
class: Chamilo\CourseBundle\Admin\CourseCategoryAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "CourseCategoryAdmin"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\CourseCategory
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.course_request:
class: Chamilo\CourseBundle\Admin\CourseRequestAdmin
tags:
- {name: sonata.admin, manager_type: orm, group: "LMS", label: "CourseRequestAdmin"}
arguments:
- ~
- Chamilo\CoreBundle\Entity\CourseRequest
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.c_group_info:
class: Chamilo\CourseBundle\Admin\CGroupInfoAdmin
tags:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "CGroupInfo"}
arguments:
- ~
- Chamilo\CourseBundle\Entity\CGroupInfo
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
sonata.admin.c_document:
class: Chamilo\CourseBundle\Admin\CDocumentAdmin
tags:
- {name: sonata.admin, manager_type: orm, audit: true, group: "LMS", label: "CDocument"}
arguments:
- ~
- Chamilo\CourseBundle\Entity\CDocument
- ~
calls:
- [setTranslationDomain, [ChamiloCoreBundle]]
Loading…
Cancel
Save