/** * Get profile list to display in admin-user select list. * * @return array */ public function getSettings() { $profiles = $this->profileManager->getProfiles(); $settings = []; foreach ($profiles as $profile) { $profileId = 'ongr_settings_profile_' . UnderscoreEscaper::escape($profile['profile']); $settings[$profileId] = ['name' => $profile['profile'], 'category' => 'ongr_settings_profiles']; } return $settings; }
/** * On kernel request. * * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { $settings = $this->generalSettingsManager->getSettings(); foreach ($settings as $id => $value) { $prefix = 'ongr_settings_profile_'; if (strpos($id, $prefix) === 0 && $value === true) { $escapedProfile = mb_substr($id, strlen($prefix), null, 'UTF-8'); $profile = UnderscoreEscaper::unescape($escapedProfile); $this->settingsContainer->addProfile($profile); $this->settingsContainer->addProvider($this->buildProvider($profile)); } } }
/** * Tests unsescape method. * * @param string $expectedOutput * @param string $input * * @dataProvider getUnescapeCases */ public function testUnescape($expectedOutput, $input) { $output = UnderscoreEscaper::unescape($input); $this->assertSame($expectedOutput, $output); }