{@inheritdoc}
@see FlexObjectInterface::save()
351275
public function save()
    {
        $this->triggerEvent('onBeforeSave');

        $result = $this->getFlexDirectory()->getStorage()->replaceRows([$this->getStorageKey() => $this->prepareStorage()]);

        $value = reset($result);
        $storageKey = key($result);
        if ($value && $storageKey) {
            $this->setStorageKey($storageKey);
            if (!$this->hasKey()) {
                $this->setKey($storageKey);
            }
        }

        if (method_exists($this, 'saveUpdatedMedia')) {
            $this->saveUpdatedMedia();
        }

        try {
            $this->getFlexDirectory()->clearCache();
            if (method_exists($this, 'clearMediaCache')) {
                $this->clearMediaCache();
            }
        } catch (InvalidArgumentException $e) {
            /** @var Debugger $debugger */
            $debugger = Grav::instance()['debugger'];
            $debugger->addException($e);

            // Caching failed, but we can ignore that for now.
        }

        $this->triggerEvent('onAfterSave');

        return $this;
    }
97420
public function save(array $options = [])
    {
        try {
            // Save model to database
            $result = parent::save($options);

            // If save has been aborted from an event/observer
            // or simply returned an empty response, we'll treat
            // it as a failed save and throw an exception.
            if (! $result) {
                throw new SaveFailedException(sprintf('Could not save model [%s]. Reason: Save returned false.', get_class($this)));
            }
        } catch (Exception $e) {
            // Catch exceptions and re-throw
            // as our Nodes "save failed" exceptions
            throw (new SaveFailedException(sprintf('Could not save model [%s]. Reason: %s', get_class($this), $e->getMessage())))->setPreviousException($e);
        } catch (Throwable $e) {
            // Add support for PHP 7 throwable interface.
            // Re-throw as our Nodes "save failed" exceptions.
            throw (new SaveFailedException(sprintf('Could not save model [%s]. Reason: %s', get_class($this), $e->getMessage())))->setPreviousException($e);
        }

        return $result;
    }
1186390
public function save(array $options = null)
    {
        try {
            parent::save($options);
        }
        catch (Exception $ex) {
            $this->throwHalcyonSaveException($ex);
        }
    }
266975
function save ($file = null, $data = array(), $append = false, $fields = array()) {
		if ( empty($file) ) $file = &$this->file;
		$mode = ( $append ) ? 'at' : 'wt' ;
		$is_php = ( preg_match('/\.php$/i', $file) ) ? true : false ;
		return $this->_wfile($file, $this->unparse($data, $fields, $append, $is_php), $mode);
	}
1003359
public function save(){
		$json	= $this->data->toJson();
		if( $this->format )
			$json	= ADT_JSON_Formater::format( $json );
		return FS_File_Writer::save( $this->fileName, $json );
	}
558037
public function save()
    {
        if (!$this->oxrecommlists__oxtitle->value) {
            throw oxNew(\OxidEsales\Eshop\Core\Exception\ObjectException::class, 'EXCEPTION_RECOMMLIST_NOTITLE');
        }
        $this->onSave();

        return parent::save();
    }
1236470
public function save($force = false) {
        if (!$this->writeable) {
            return false;
        }

        if (!$this->dirty && !$force) {
            return null;
        }

        $savetype = $force ? 'forced ' : '';
        if (is_null($force)) {
            $savetype = 'auto ';
        }

        $path = dirname($this->file);
        if (!is_dir($path)) {
            mkdir($path, 0755, true);
        }

        $data = $this->store->dump();
        $conf = version_compare(PHP_VERSION, '5.4', '>=') ? json_encode($data, JSON_PRETTY_PRINT) : json_encode($data);
        unset($data);
        if (!$conf || !json_decode($conf)) {
            return;
        }
        $saved = (bool)$this->writeAtomic($this->file, $conf, 0755);

        if ($saved) {
            $this->dirty = false;
        }

        return $saved;
    }
982982
public function save($data)
    {
        $argv = compact('data');
        $argv = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_PRE_SAVE, $this, $argv);

        $data = $argv['data'];

        if ($data instanceof ModelInterface) {
            $data = $this->getHydrator()->extract($data);
        }

        $pk = $this->getMapper()->getPrimaryKey();
        $id = $data[$pk];
        unset($data[$pk]);

        if (0 === $id || null === $id || '' === $id) {
            $result = $this->getMapper()->insert($data);
            $this->clearCacheTags();
        } else {
            if ($this->getById($id)) {
                $result = $this->getMapper()->update($data, [$pk => $id]);
            } else {
                throw new ServiceException('ID ' . $id . ' does not exist');
            }

            $this->removeCacheItem($id);
        }

        $argv = compact('data', 'result');
        $argv = $this->prepareEventArguments($argv);

        $this->getEventManager()->trigger(self::EVENT_POST_SAVE, $this, $argv);

        return $result;
    }
1308171
public function save() {
        $this->CheckGitIgnore();
        if (!empty($this->beforeLines) && trim(end($this->beforeLines))) {
            array_push($this->beforeLines, '');
        }
        if (empty($this->afterLines) || trim(reset($this->afterLines))) {
            array_unshift($this->afterLines, '');
        }
        $this->readLines = array_merge($this->beforeLines, $this->autoLines, $this->afterLines);
        if (count($this->readLines)) {
            if (!file_put_contents($this->filePath, implode(PHP_EOL, $this->readLines))) {
                throw new AutoGitIgnoreSaveFailedException("Saving to " . $this->filePath . " failed");
            }
        }
        return $this;
    }
507556
public function saveInto(DataObjectInterface $object) {
		if(!$this->canCrop() || !$this->hasSourceFile()) {
			return;
		}
		$object->setField($this->getName() . 'ID', $this->generateCropped()->ID);
		$object->write();
	}
69219
function save($args)
    {
        $args = parent::save($args);

        $this->_load_drivers();

        $data = $args['path'] ? file_get_contents($args['path']) : $args['data'];

        $args['data'] = null;

        $key  = $this->_key($args);
        $data = base64_encode($data);

        $status = $this->cache->write($key, $data);

        if (!$status && $this->mem_cache) {
            $status = $this->mem_cache->write($key, $data);
        }

        if ($status) {
            $args['id'] = $key;
            $args['status'] = true;
        }

        return $args;
    }
214810
function save() {
		if (!$this->id)
			$this->id=uniqid(NULL,TRUE);
		$_SESSION[$this->key][$this->id]=$this->item;
		return $this->item;
	}
1353450
public function save()
    {
        $data = $this->toData();

        if (file_exists($this->_configuration_file) && !is_writable($this->_configuration_file)) {
            chmod($this->_configuration_file, 0644);
        }

        $file = new \SplFileObject($this->_configuration_file, 'w');
        $file->fwrite("<?php\n");
        $file->fwrite("class AnSiteConfig {\n\n");

        $print_array = function($array) use (&$print_array) {

            if (is_array($array)) {

                $values = array();
                $hash   = !is_numeric(key($array));

                foreach ($array as $key => $value) {

                    if ( !is_numeric($key) ) {
                        $key = "'".addslashes($key)."'";
                    }

                    if ( !is_numeric($value) ) {
                        $value = "'".addslashes($value)."'";
                    }

                    $values[] = $hash ? "$key=>$value" : $value;
                }

                return 'array('.implode(',', $values).')';
            }
        };

        $write = function($data) use($file, $print_array) {

            foreach($data as $key => $value) {

                if (is_array($value)) {
                    $value = $print_array($value);
                } elseif ( !is_numeric($value) ) {
                    $value = "'".addslashes($value)."'";
                }

                $file->fwrite("   var \$$key = $value;\n");
            }
        };

        $write_group = function($keys, $comment = null) use (&$data, $file, $write) {

            $values = array();

            foreach ($keys as $key) {

                if (isset($data[$key])) {
                    $values[$key] = $data[$key];
                    unset($data[$key]);
                }
            }

            if (!empty($values)) {

                if (!empty($comment)) {
                    $file->fwrite("   /*$comment*/\n");
                }

                $write($values);
                $file->fwrite("\n");
            }
        };

        $write_group(array('sitename'), 'Site Settings');
        $write_group(array('dbtype', 'host', 'user', 'password', 'db', 'dbprefix'), 'Database Settings');
        $write_group(array('sef_rewrite', 'live_site', 'secret', 'error_reporting', 'tmp_path', 'log_path', 'force_ssl'), 'Server Settings');
        $write_group(array('mailer', 'mailfrom', 'fromname', 'sendmail', 'smtpauth', 'smtpuser', 'smtppass', 'smtphost'), 'Mail Settings');
        $write_group(array('debug'), 'Debug Settings');
        $write_group(array_keys($data), 'Other configurations');
        $file->fwrite("}");

        $this->_clearCache();
    }
399447
final public function saveObject($objectURI = NULL, $objectType = NULL, $objectId = NULL, $forceNew = false )
    {

        $isNew = (empty($objectId) && empty($objectURI)) ? true : (($forceNew)? true : false );

        //if we are forcing a new object;

        //Get a randomstring for the objectURI
        $objectURI = empty($objectURI) ? getRandomString(10, false, true) : $objectURI;
        $objectType = empty($objectType) ? 'entity' : $objectType;
        //$objectId = empty($objectId) ?  (!empty($this->objectId) ? $this->objectId : null ) : $objectId;
        //Ensure we have all the properties
        if (empty($this->propertyModel) || empty($this->propertyData))
            return false; //We have nothing to save

        //Use a transaction;
        $this->database->startTransaction();
        $pquery = "INSERT IGNORE INTO ?properties (property_name, property_label, property_datatype, property_charsize, property_default, property_indexed) VALUES\n";
        $pqueryV = array();
        foreach ($this->propertyModel as $property => $definition) {
            $values = array($this->database->quote($property), $this->database->quote($definition[0]), $this->database->quote($definition[1])); //Name, Label, DataType
            $values[] = (isset($definition[2])) ? $this->database->quote($definition[2]) : $this->database->quote(""); //Charsize
            $values[] = (isset($definition[3])) ? $this->database->quote($definition[3]) : $this->database->quote(""); //Default
            $values[] = (isset($definition[4]) && $definition[4]) ? $this->database->quote(1) : $this->database->quote(0); //Indexed

            $pqueryV[] = " (" . implode(', ', $values) . " )";
        }
        $pquery .= implode(', ', $pqueryV);


        //update the properties
        $this->database->query($pquery);

        //If objectId is NULL then NEW Create new object
        if ($isNew):

            //Log::message("Object ID is {$objectId}");

            $timestamp = Time::stamp();

            $oquery = $this->database->insert("?objects", array("object_uri" => $this->database->quote($objectURI), "object_type" => $this->database->quote($objectType), "object_created_on" => $this->database->quote($timestamp)), FALSE, NULL, FALSE);
            $this->database->query($oquery);

            $this->setLastSavedObjectURI($objectURI);
        endif;



        //If property exists and value doesnt insert new value row
        //If property exists and value exists update value
        //if property does not exists, insert property and insert value
        $vtable = "?{$this->valueGroup}property_values";

        $iquery = "REPLACE INTO {$vtable} (property_id, object_id, value_data)";
        $iqueryV = array();
        foreach ($this->propertyData as $propertyName => $valueData):
            //@TODO validate the data?
            if (empty($valueData))
                continue; //There is no point in storing empty values;


//@TODO also check that value data has data for fields demarkated as allowempty=false;
            $iqueryV[] = "\nSELECT p.property_id, o.object_id, {$this->database->quote($valueData)}  FROM `?properties` AS p JOIN `?objects` AS o WHERE o.object_uri={$this->database->quote($objectURI)} AND p.property_name={$this->database->quote($propertyName)}";
        endforeach;
        $iquery .= implode("\nUNION ALL", $iqueryV);

        $this->database->query($iquery);
        //Update the object URI so the last update field is auto updated
        //$this->database->exec( "UPDATE ?objects SET objected_updated_on=CURRENT_TIMESTAMP" WHERE object_uri=" );

        if (!$this->database->commitTransaction()) {
            throw new Exception("Could not commit transaction");
            return false;
        }

        return true;
    }
427746
public function save($entity)
    {
        $this
            ->objectManager
            ->persist($entity);

        $this
            ->objectManager
            ->flush($entity);
    }
208081
public function saveAs($extension = NULL)
	{
		$extension = (!is_null($extension) ? $extension : $this->extension);

		$converter = $this->extracter->converter();
		$converter->setExtension($extension);
		$data = $converter->toNative($this->params);
	
		// We need to rename the file's extension
		$this->rename(NULL, $extension);

		$this->fs->dumpFile($this->file, $data);	
	}
483005
public function save()
    {

        $ok = $this->dataConnector->saveToolConsumer($this);
        if ($ok) {
            $this->settingsChanged = false;
        }

        return $ok;

    }