public function toggleProfileAction(Request $request)
    {
        $settingName = $this->getParameter('ongr_settings.active_profiles');
        $manager = $this->get('ongr_settings.settings_manager');

        #TODO Not sure where is the right place to put active profiles setting initiating
        if (!$manager->has($settingName)) {
            $manager->create(
                [
                    'name' => $settingName,
                    'value' => [],
                    'type' => 'hidden',
                ]
            );
        }

        $profileName = $request->get('name');
        $activeProfiles = (array)$manager->getValue($settingName, []);

        $key = array_search($profileName, $activeProfiles);
        if ($key === false) {
            $activeProfiles[] = $profileName;
        } else {
            unset($activeProfiles[$key]);
        }

        $manager->update($settingName, [
            'value' => array_values($activeProfiles)
        ]);

        $this->get('ong_settings.cache_provider')->deleteAll();

        return new JsonResponse(['error' => false]);
    }
public function toggleProfileAction(Request $request)
    {
        $settingName = $this->getParameter('ongr_settings.active_profiles');
        $manager = $this->get('ongr_settings.settings_manager');

        #TODO Not sure where is the right place to put active profiles setting initiating
        if (!$manager->has($settingName)) {
            $manager->create(
                [
                    'name' => $settingName,
                    'value' => [],
                    'type' => 'hidden',
                ]
            );
        }

        $profileName = $request->get('name');
        $activeProfiles = (array)$manager->getValue($settingName, []);

        $key = array_search($profileName, $activeProfiles);
        if ($key === false) {
            $activeProfiles[] = $profileName;
        } else {
            unset($activeProfiles[$key]);
        }

        $manager->update($settingName, [
            'value' => array_values($activeProfiles)
        ]);

        $this->get('ong_settings.cache_provider')->deleteAll();

        return new JsonResponse(['error' => false]);
    }
public function toggleProfileAction ( Request $ request ) { $ settingName = $ this -> getParameter ( 'ongr_settings.active_profiles' ) ; $ manager = $ this -> get ( 'ongr_settings.settings_manager' ) ; #TODO Not sure where is the right place to put active profiles setting initiating if ( ! $ manager -> has ( $ settingName ) ) { $ manager -> create ( [ 'name' => $ settingName , 'value' => [ ] , 'type' => 'hidden' , ] ) ; } $ profileName = $ request -> get ( 'name' ) ; $ activeProfiles = ( array ) $ manager -> getValue ( $ settingName , [ ] ) ; $ key = array_search ( $ profileName , $ activeProfiles ) ; if ( $ key === false ) { $ activeProfiles [ ] = $ profileName ; } else { unset ( $ activeProfiles [ $ key ] ) ; } $ manager -> update ( $ settingName , [ 'value' => array_values ( $ activeProfiles ) ] ) ; $ this -> get ( 'ong_settings.cache_provider' ) -> deleteAll ( ) ; return new JsonResponse ( [ 'error' => false ] ) ; }
Toggle profile activation.

@param Request $request

@return JsonResponse
Toggle profile activation .