| Conditions | 6 |
| Paths | 8 |
| Total Lines | 107 |
| Code Lines | 85 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 36 | #[Route('/list', name: 'platform_config_list', methods: ['GET'])] |
||
| 37 | public function list(SettingsManager $settingsManager): Response |
||
| 38 | { |
||
| 39 | $requestSession = $this->getRequest()->getSession(); |
||
| 40 | |||
| 41 | $configuration = [ |
||
| 42 | 'settings' => [], |
||
| 43 | 'studentview' => $requestSession->get('studentview'), |
||
| 44 | 'plugins' => [], |
||
| 45 | 'visual_theme' => $this->themeHelper->getVisualTheme(), |
||
| 46 | 'oauth2_providers' => $this->authenticationConfigHelper->getEnabledOAuthProviders(), |
||
| 47 | ]; |
||
| 48 | |||
| 49 | $configuration['settings']['registration.allow_registration'] = $settingsManager->getSetting('registration.allow_registration', true); |
||
| 50 | $configuration['settings']['course.course_catalog_published'] = $settingsManager->getSetting('course.course_catalog_published', true); |
||
| 51 | $configuration['settings']['course.catalog_hide_public_link'] = $settingsManager->getSetting('course.catalog_hide_public_link', true); |
||
| 52 | $configuration['settings']['course.allow_course_extra_field_in_catalog'] = $settingsManager->getSetting('course.allow_course_extra_field_in_catalog', true); |
||
| 53 | $configuration['settings']['course.course_catalog_display_in_home'] = $settingsManager->getSetting('course.course_catalog_display_in_home', true); |
||
| 54 | $configuration['settings']['course.courses_catalogue_show_only_category'] = $settingsManager->getSetting('course.courses_catalogue_show_only_category', true); |
||
| 55 | $configuration['settings']['display.allow_students_to_browse_courses'] = $settingsManager->getSetting('display.allow_students_to_browse_courses', true); |
||
| 56 | $configuration['settings']['session.catalog_allow_session_auto_subscription'] = $settingsManager->getSetting('session.catalog_allow_session_auto_subscription', true); |
||
| 57 | $configuration['settings']['session.catalog_course_subscription_in_user_s_session'] = $settingsManager->getSetting('session.catalog_course_subscription_in_user_s_session', true); |
||
| 58 | $rawSetting = $settingsManager->getSetting('course.course_catalog_settings', true); |
||
| 59 | $configuration['settings']['course.course_catalog_settings'] = $this->decodeSettingArray($rawSetting); |
||
| 60 | |||
| 61 | $variables = []; |
||
| 62 | |||
| 63 | if ($this->isGranted('ROLE_USER')) { |
||
| 64 | $variables = [ |
||
| 65 | 'platform.site_name', |
||
| 66 | 'platform.timezone', |
||
| 67 | 'platform.registered', |
||
| 68 | 'platform.donotlistcampus', |
||
| 69 | 'platform.load_term_conditions_section', |
||
| 70 | 'platform.cookie_warning', |
||
| 71 | 'platform.show_tabs', |
||
| 72 | 'platform.catalog_show_courses_sessions', |
||
| 73 | 'admin.administrator_name', |
||
| 74 | 'admin.administrator_surname', |
||
| 75 | 'editor.enabled_mathjax', |
||
| 76 | 'editor.translate_html', |
||
| 77 | 'display.show_admin_toolbar', |
||
| 78 | 'registration.allow_terms_conditions', |
||
| 79 | 'agenda.allow_personal_agenda', |
||
| 80 | 'agenda.personal_calendar_show_sessions_occupation', |
||
| 81 | 'social.social_enable_messages_feedback', |
||
| 82 | 'social.disable_dislike_option', |
||
| 83 | 'skill.allow_skills_tool', |
||
| 84 | 'gradebook.gradebook_enable_grade_model', |
||
| 85 | 'gradebook.gradebook_dependency', |
||
| 86 | 'course.course_validation', |
||
| 87 | 'course.student_view_enabled', |
||
| 88 | 'course.allow_edit_tool_visibility_in_session', |
||
| 89 | 'session.limit_session_admin_role', |
||
| 90 | 'session.allow_session_admin_read_careers', |
||
| 91 | 'session.limit_session_admin_list_users', |
||
| 92 | 'platform.redirect_index_to_url_for_logged_users', |
||
| 93 | 'language.platform_language', |
||
| 94 | 'language.language_priority_1', |
||
| 95 | 'language.language_priority_2', |
||
| 96 | 'language.language_priority_3', |
||
| 97 | 'language.language_priority_4', |
||
| 98 | 'profile.allow_social_map_fields', |
||
| 99 | 'forum.global_forums_course_id', |
||
| 100 | 'document.students_download_folders', |
||
| 101 | 'social.hide_social_groups_block', |
||
| 102 | 'course.show_course_duration', |
||
| 103 | 'attendance.attendance_allow_comments', |
||
| 104 | 'attendance.multilevel_grading', |
||
| 105 | 'attendance.enable_sign_attendance_sheet', |
||
| 106 | 'exercise.allow_exercise_auto_launch', |
||
| 107 | 'course.access_url_specific_files', |
||
| 108 | 'platform.course_catalog_hide_private', |
||
| 109 | 'course.show_courses_descriptions_in_catalog', |
||
| 110 | 'session.session_automatic_creation_user_id', |
||
| 111 | ]; |
||
| 112 | |||
| 113 | $user = $this->userHelper->getCurrent(); |
||
| 114 | |||
| 115 | $configuration['settings']['display.show_link_ticket_notification'] = 'false'; |
||
| 116 | |||
| 117 | if (!empty($user)) { |
||
| 118 | $userIsAllowedInProject = $this->ticketProjectHelper->userIsAllowInProject(1); |
||
| 119 | |||
| 120 | if ($userIsAllowedInProject |
||
| 121 | && 'true' === $settingsManager->getSetting('display.show_link_ticket_notification') |
||
| 122 | ) { |
||
| 123 | $configuration['settings']['display.show_link_ticket_notification'] = 'true'; |
||
| 124 | } |
||
| 125 | } |
||
| 126 | |||
| 127 | $configuration['plugins']['bbb'] = [ |
||
| 128 | 'show_global_conference_link' => Bbb::showGlobalConferenceLink([ |
||
| 129 | 'username' => $user->getUserIdentifier(), |
||
| 130 | 'status' => $user->getStatus(), |
||
| 131 | ]), |
||
| 132 | 'listingURL' => (new Bbb('', '', true, $user->getId()))->getListingUrl(), |
||
| 133 | ]; |
||
| 134 | } |
||
| 135 | |||
| 136 | foreach ($variables as $variable) { |
||
| 137 | $value = $settingsManager->getSetting($variable, true); |
||
| 138 | |||
| 139 | $configuration['settings'][$variable] = $value; |
||
| 140 | } |
||
| 141 | |||
| 142 | return new JsonResponse($configuration); |
||
| 143 | } |
||
| 211 |