From 79cc408310f0432ace4cdacbc678ae87d556e7de Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Mon, 22 Jan 2018 15:30:51 +0100 Subject: [PATCH] Minor - Update settings options, use class ChoiceType instead of string --- .../Settings/AgendaSettingsSchema.php | 9 ++-- .../Settings/CourseSettingsSchema.php | 44 ++++++++++--------- .../Settings/DisplaySettingsSchema.php | 20 ++++----- .../Settings/DocumentSettingsSchema.php | 24 +++++----- .../Settings/ForumSettingsSchema.php | 10 ++--- .../Settings/GlossarySettingsSchema.php | 12 ++--- .../Settings/GradebookSettingsSchema.php | 14 +++--- .../Settings/PlatformSettingsSchema.php | 26 +++++------ .../Settings/RegistrationSettingsSchema.php | 8 ++-- .../Settings/SearchSettingsSchema.php | 8 ++-- .../Settings/SurveySettingsSchema.php | 8 ++-- .../Controller/SettingsController.php | 1 + 12 files changed, 95 insertions(+), 89 deletions(-) diff --git a/src/CoreBundle/Settings/AgendaSettingsSchema.php b/src/CoreBundle/Settings/AgendaSettingsSchema.php index 249ddbb974..752d24f59c 100644 --- a/src/CoreBundle/Settings/AgendaSettingsSchema.php +++ b/src/CoreBundle/Settings/AgendaSettingsSchema.php @@ -4,9 +4,9 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; /** * Class AgendaSettingsSchema @@ -52,15 +52,14 @@ class AgendaSettingsSchema extends AbstractSettingsSchema //->add('number_of_upcoming_events') ->add( 'default_calendar_view', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'month' => 'Month', - 'week' => 'Week' + 'Month' => 'month', + 'Week' => 'week' ] ] ) - ; } } diff --git a/src/CoreBundle/Settings/CourseSettingsSchema.php b/src/CoreBundle/Settings/CourseSettingsSchema.php index 61732210d9..2dc614bd78 100644 --- a/src/CoreBundle/Settings/CourseSettingsSchema.php +++ b/src/CoreBundle/Settings/CourseSettingsSchema.php @@ -4,6 +4,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Chamilo\CoreBundle\Entity\Course; use Chamilo\CoreBundle\Entity\Manager\CourseManager; use Chamilo\CoreBundle\Entity\Repository\CourseRepository; @@ -146,18 +147,21 @@ class CourseSettingsSchema extends AbstractSettingsSchema $builder ->add( 'homepage_view', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'activity' => 'activity', - 'activity_big' => 'activity_big', + 'HomepageView2column' => '2column', + 'HomepageView3column' => '3column', + 'HomepageViewVerticalActivity' => 'vertical_activity', + 'HomepageViewActivity' => 'activity', + 'HomepageViewActivityBig' => 'activity_big', ], ] ) ->add('show_tool_shortcuts', YesNoType::class) ->add( 'active_tools_on_create', - 'choice', + ChoiceType::class, [ 'choices' => $tools, 'multiple' => true, @@ -170,26 +174,26 @@ class CourseSettingsSchema extends AbstractSettingsSchema ->add('go_to_course_after_login', YesNoType::class) ->add( 'show_navigation_menu', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'false' => 'No', - 'icons' => 'IconsOnly', - 'text' => 'TextOnly', - 'iconstext' => 'IconsText', + 'No' => 'false', + 'IconsOnly' => 'icons', + 'TextOnly' => 'text', + 'IconsText' => 'iconstext' ], ] ) ->add('enable_tool_introduction', YesNoType::class) ->add( 'breadcrumbs_course_homepage', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'course_home' => 'CourseHomepage', - 'course_code' => 'CourseCode', - 'course_title' => 'CourseTitle', - 'session_name_and_course_title' => 'SessionNameAndCourseTitle', + 'CourseHomepage' => 'course_home', + 'CourseCode' => 'course_code', + 'CourseTitle' => 'course_title', + 'SessionNameAndCourseTitle' => 'session_name_and_course_title', ], ] ) @@ -203,7 +207,7 @@ class CourseSettingsSchema extends AbstractSettingsSchema ->add('course_validation_terms_and_conditions_url', 'url') ->add( 'course_hide_tools', - 'choice', + ChoiceType::class, [ 'choices' => $tools, 'multiple' => true, @@ -213,13 +217,13 @@ class CourseSettingsSchema extends AbstractSettingsSchema ->add('scorm_cumulative_session_time', YesNoType::class) ->add( 'courses_default_creation_visibility', - 'choice', + ChoiceType::class, [ 'choices' => [ - '3' => 'Public', - '2' => 'Open', - '1' => 'Private', - '0' => 'Closed', + 'Public' => '3', + 'Open' => '2', + 'Private' => '1', + 'Closed' => '0' ], ] ) diff --git a/src/CoreBundle/Settings/DisplaySettingsSchema.php b/src/CoreBundle/Settings/DisplaySettingsSchema.php index f7d251b725..2ccb2566c8 100644 --- a/src/CoreBundle/Settings/DisplaySettingsSchema.php +++ b/src/CoreBundle/Settings/DisplaySettingsSchema.php @@ -4,7 +4,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -72,12 +72,12 @@ class DisplaySettingsSchema extends AbstractSettingsSchema ->add('show_teacher_data', YesNoType::class) ->add( 'showonline', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'course' => 'Course', - 'users' => 'Users', - 'world' => 'World', + 'Course' => 'course', + 'Users' => 'users', + 'World' => 'world', ], ] ) @@ -96,13 +96,13 @@ class DisplaySettingsSchema extends AbstractSettingsSchema ->add('accessibility_font_resize', YesNoType::class) ->add( 'show_admin_toolbar', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'do_not_show' => 'DoNotShow', - 'show_to_admin' => 'ShowToAdminsOnly', - 'show_to_admin_and_teachers' => 'ShowToAdminsAndTeachers', - 'show_to_all' => 'ShowToAllUsers' + 'DoNotShow' => 'do_not_show', + 'ShowToAdminsOnly' => 'show_to_admin', + 'ShowToAdminsAndTeachers' => 'show_to_admin_and_teachers', + 'ShowToAllUsers' => 'show_to_all' ] ] ) diff --git a/src/CoreBundle/Settings/DocumentSettingsSchema.php b/src/CoreBundle/Settings/DocumentSettingsSchema.php index 24a2e8671e..61f76d64fa 100644 --- a/src/CoreBundle/Settings/DocumentSettingsSchema.php +++ b/src/CoreBundle/Settings/DocumentSettingsSchema.php @@ -4,8 +4,8 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Chamilo\SettingsBundle\Transformer\ArrayToIdentifierTransformer; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -86,11 +86,11 @@ class DocumentSettingsSchema extends AbstractSettingsSchema ->add('permanently_remove_deleted_files', YesNoType::class) ->add( 'upload_extensions_list_type', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'blacklist' => 'Blacklist', - 'whitelist' => 'Whitelist', + 'Blacklist' => 'blacklist', + 'Whitelist' => 'whitelist', ], ] ) @@ -102,12 +102,12 @@ class DocumentSettingsSchema extends AbstractSettingsSchema ->add('permissions_for_new_files') ->add( 'show_glossary_in_documents', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'none' => 'ShowGlossaryInDocumentsIsNone', - 'ismanual' => 'ShowGlossaryInDocumentsIsManual', - 'isautomatic' => 'ShowGlossaryInDocumentsIsAutomatic', + 'ShowGlossaryInDocumentsIsNone' => 'none', + 'ShowGlossaryInDocumentsIsManual' => 'ismanual', + 'ShowGlossaryInDocumentsIsAutomatic' => 'isautomatic', ] ] ) @@ -126,7 +126,7 @@ class DocumentSettingsSchema extends AbstractSettingsSchema ->add('enable_webcam_clip', YesNoType::class) ->add( 'tool_visible_by_default_at_creation', - 'choice', + ChoiceType::class, [ 'multiple' => true, 'choices' => [ @@ -142,11 +142,11 @@ class DocumentSettingsSchema extends AbstractSettingsSchema ) ->add( 'if_file_exists_option', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'rename' => 'Rename', - 'overwrite' => 'Overwrite', + 'Rename' => 'rename', + 'Overwrite' => 'overwrite', ] ] ) diff --git a/src/CoreBundle/Settings/ForumSettingsSchema.php b/src/CoreBundle/Settings/ForumSettingsSchema.php index 2e91947a3e..87872932b5 100644 --- a/src/CoreBundle/Settings/ForumSettingsSchema.php +++ b/src/CoreBundle/Settings/ForumSettingsSchema.php @@ -4,7 +4,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -42,12 +42,12 @@ class ForumSettingsSchema extends AbstractSettingsSchema $builder ->add( 'default_forum_view', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'flat' => 'Flat', - 'threaded' => 'Threaded', - 'nested' => 'Nested', + 'Flat' => 'flat', + 'Threaded' => 'threaded', + 'Nested' => 'nested', ], ] ) diff --git a/src/CoreBundle/Settings/GlossarySettingsSchema.php b/src/CoreBundle/Settings/GlossarySettingsSchema.php index 79603090d0..4fd9280508 100644 --- a/src/CoreBundle/Settings/GlossarySettingsSchema.php +++ b/src/CoreBundle/Settings/GlossarySettingsSchema.php @@ -4,7 +4,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -40,13 +40,13 @@ class GlossarySettingsSchema extends AbstractSettingsSchema $builder ->add( 'show_glossary_in_extra_tools', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'none' => 'None', - 'exercise' => 'Exercise', - 'lp' => 'LearningPath', - 'exercise_and_lp' => 'ExerciseAndLearningPath' + 'None' => 'none', + 'Exercise' => 'exercise', + 'LearningPath' => 'lp', + 'ExerciseAndLearningPath' => 'exercise_and_lp' ] ] ) diff --git a/src/CoreBundle/Settings/GradebookSettingsSchema.php b/src/CoreBundle/Settings/GradebookSettingsSchema.php index fcea448f44..68747fb105 100644 --- a/src/CoreBundle/Settings/GradebookSettingsSchema.php +++ b/src/CoreBundle/Settings/GradebookSettingsSchema.php @@ -4,9 +4,9 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; /** * Class GradebookSettingsSchema @@ -76,11 +76,13 @@ class GradebookSettingsSchema extends AbstractSettingsSchema ->add('my_display_coloring') ->add( 'student_publication_to_take_in_gradebook', - 'choice', - ['choices' => [ - 'first' => 'First', - 'last' => 'Last' - ]] + ChoiceType::class, + [ + 'choices' => [ + 'First' => 'first', + 'Last' => 'last', + ], + ] ) ->add('gradebook_detailed_admin_view') ->add('openbadges_backpack') diff --git a/src/CoreBundle/Settings/PlatformSettingsSchema.php b/src/CoreBundle/Settings/PlatformSettingsSchema.php index 0736410a51..25ff05cca1 100644 --- a/src/CoreBundle/Settings/PlatformSettingsSchema.php +++ b/src/CoreBundle/Settings/PlatformSettingsSchema.php @@ -5,7 +5,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; use Chamilo\SettingsBundle\Transformer\ArrayToIdentifierTransformer; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -44,13 +44,13 @@ class PlatformSettingsSchema extends AbstractSettingsSchema 'use_custom_pages' => 'false', 'pdf_logo_header' => '', 'allow_my_files' => 'true', - 'chamilo_database_version' => '2.0.0', 'registered' => 'false', 'load_term_conditions_section' => 'login', 'server_type' => 'false', 'show_full_skill_name_on_skill_wheel' => 'false', 'show_official_code_whoisonline' => 'false', - 'show_tabs' => [] + 'show_tabs' => [], + 'chamilo_database_version' => '2.0.0' // //('catalog_show_courses_sessions', '0', 'CatalogueShowOnlyCourses'), //('catalog_show_courses_sessions', '1', 'CatalogueShowOnlySessions'), @@ -111,10 +111,10 @@ class PlatformSettingsSchema extends AbstractSettingsSchema ->add('gravatar_enabled', YesNoType::class) ->add( 'gravatar_type', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'mm' => 'mistery-man', + 'mistery-man' => 'mm', 'identicon' => 'identicon', 'monsterid' => 'monsterid', 'wavatar' => 'wavatar', @@ -128,11 +128,11 @@ class PlatformSettingsSchema extends AbstractSettingsSchema ->add('course_catalog_hide_private', YesNoType::class) ->add( 'catalog_show_courses_sessions', - 'choice', + ChoiceType::class, ['choices' => [ - '0' => 'CatalogueShowOnlyCourses', - '1' => 'CatalogueShowOnlySessions', - '2' => 'CatalogueShowCoursesAndSessions', + 'CatalogueShowOnlyCourses' => '0', + 'CatalogueShowOnlySessions' => '1', + 'CatalogueShowCoursesAndSessions' => '2', ]] ) ->add('use_custom_pages', YesNoType::class) @@ -143,11 +143,11 @@ class PlatformSettingsSchema extends AbstractSettingsSchema ->add('registered', YesNoType::class) ->add( 'load_term_conditions_section', - 'choice', + ChoiceType::class, [ 'choices' => [ - '0' => 'Login', - '1' => 'Course', + 'Login' => '0', + 'Course' => '1', ], ] ) @@ -156,7 +156,7 @@ class PlatformSettingsSchema extends AbstractSettingsSchema ->add('show_official_code_whoisonline', YesNoType::class) ->add( 'show_tabs', - 'choice', + ChoiceType::class, [ 'multiple' => true, 'choices' => $tabs, diff --git a/src/CoreBundle/Settings/RegistrationSettingsSchema.php b/src/CoreBundle/Settings/RegistrationSettingsSchema.php index e30b3bb91e..3b368bf544 100644 --- a/src/CoreBundle/Settings/RegistrationSettingsSchema.php +++ b/src/CoreBundle/Settings/RegistrationSettingsSchema.php @@ -85,10 +85,10 @@ class RegistrationSettingsSchema extends AbstractSettingsSchema [ 'multiple' => true, 'choices' => [ - 'officialcode' => 'officialcode', - 'email' => 'email', - 'language' => 'language', - 'phone' => 'phone', + 'Official code' => 'officialcode', + 'E-mail' => 'email', + 'Language' => 'language', + 'Phone' => 'phone', ], ] ) diff --git a/src/CoreBundle/Settings/SearchSettingsSchema.php b/src/CoreBundle/Settings/SearchSettingsSchema.php index be138d0520..c15ca94e17 100644 --- a/src/CoreBundle/Settings/SearchSettingsSchema.php +++ b/src/CoreBundle/Settings/SearchSettingsSchema.php @@ -4,7 +4,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -45,11 +45,11 @@ class SearchSettingsSchema extends AbstractSettingsSchema ->add('search_prefilter_prefix', YesNoType::class) ->add( 'search_show_unlinked_results', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'true' => 'SearchShowUnlinkedResults', - 'false' => 'SearchHideUnlinkedResults', + 'SearchShowUnlinkedResults' => 'true', + 'SearchHideUnlinkedResults' => 'false', ], ] ) diff --git a/src/CoreBundle/Settings/SurveySettingsSchema.php b/src/CoreBundle/Settings/SurveySettingsSchema.php index d20055e574..b7c4ac4e83 100644 --- a/src/CoreBundle/Settings/SurveySettingsSchema.php +++ b/src/CoreBundle/Settings/SurveySettingsSchema.php @@ -4,7 +4,7 @@ namespace Chamilo\CoreBundle\Settings; use Chamilo\CoreBundle\Form\Type\YesNoType; -use Sylius\Bundle\SettingsBundle\Schema\SchemaInterface; +use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Sylius\Bundle\SettingsBundle\Schema\SettingsBuilderInterface; use Symfony\Component\Form\FormBuilderInterface; @@ -42,11 +42,11 @@ class SurveySettingsSchema extends AbstractSettingsSchema $builder ->add( 'survey_email_sender_noreply', - 'choice', + ChoiceType::class, [ 'choices' => [ - 'coach' => 'CourseCoachEmailSender', - 'noreply' => 'NoReplyEmailSender', + 'CourseCoachEmailSender' => 'coach', + 'NoReplyEmailSender' => 'noreply', ], ] ) diff --git a/src/CourseBundle/Controller/SettingsController.php b/src/CourseBundle/Controller/SettingsController.php index d4755a5202..115a4111c3 100644 --- a/src/CourseBundle/Controller/SettingsController.php +++ b/src/CourseBundle/Controller/SettingsController.php @@ -32,6 +32,7 @@ class SettingsController extends Controller public function updateAction(Request $request, $namespace, $course) { $manager = $this->getSettingsManager(); + $schemaAlias = $manager->convertNameSpaceToService($namespace); $settings = $manager->load($namespace);