public function save()
    {
        $location = $this->location;

        // no location given from commandline -> use config values or fallback to default location
        if (empty($location)) {
            $location = $this->parameters->get(
                'write_location',
                $this->parameters->get(
                    'location',
                    $this->getDefaultLocation()
                )
            );
        }

        $this->location = $location;

        $data = array();
        foreach ($this->settings as $setting) {
            $data[] = $setting->toArray();
        }

        $flags = 0;
        if ($this->parameters->get('pretty', true) && version_compare(PHP_VERSION, '5.4.0') >= 0) {
            $flags |= JSON_PRETTY_PRINT;
        }

        $content = json_encode($data, $flags);

        if (false === $content) {
            throw new \Exception('Could not json_encode cachable settings. Nothing written to cache.');
        }

        $success = (false !== file_put_contents($location, $content));

        $success &= chmod($location, 0600); // only current user should read/write potentially sensitive info

        return $success;
    }
public function save()
    {
        $location = $this->location;

        // no location given from commandline -> use config values or fallback to default location
        if (empty($location)) {
            $location = $this->parameters->get(
                'write_location',
                $this->parameters->get(
                    'location',
                    $this->getDefaultLocation()
                )
            );
        }

        $this->location = $location;

        $data = array();
        foreach ($this->settings as $setting) {
            $data[] = $setting->toArray();
        }

        $flags = 0;
        if ($this->parameters->get('pretty', true) && version_compare(PHP_VERSION, '5.4.0') >= 0) {
            $flags |= JSON_PRETTY_PRINT;
        }

        $content = json_encode($data, $flags);

        if (false === $content) {
            throw new \Exception('Could not json_encode cachable settings. Nothing written to cache.');
        }

        $success = (false !== file_put_contents($location, $content));

        $success &= chmod($location, 0600); // only current user should read/write potentially sensitive info

        return $success;
    }
public function save ( ) { $ location = $ this -> location ; // no location given from commandline -> use config values or fallback to default location if ( empty ( $ location ) ) { $ location = $ this -> parameters -> get ( 'write_location' , $ this -> parameters -> get ( 'location' , $ this -> getDefaultLocation ( ) ) ) ; } $ this -> location = $ location ; $ data = array ( ) ; foreach ( $ this -> settings as $ setting ) { $ data [ ] = $ setting -> toArray ( ) ; } $ flags = 0 ; if ( $ this -> parameters -> get ( 'pretty' , true ) && version_compare ( PHP_VERSION , '5.4.0' ) >= 0 ) { $ flags |= JSON_PRETTY_PRINT ; } $ content = json_encode ( $ data , $ flags ) ; if ( false === $ content ) { throw new \ Exception ( 'Could not json_encode cachable settings. Nothing written to cache.' ) ; } $ success = ( false !== file_put_contents ( $ location , $ content ) ) ; $ success &= chmod ( $ location , 0600 ) ; // only current user should read/write potentially sensitive info return $ success ; }
Writes the current set of ISetting instances to the cache file location.

@return boolean true when cache file writing succeeded

@throws \Exception if content could not be encoded
Writes the current set of ISetting instances to the cache file location .