Save the persitable model.

@param \Rubix\ML\Persistable $persistable
@throws \RuntimeException
162469
public function save(Persistable $persistable) : void
    {
        if ($this->history and is_file($this->path)) {
            $filename = $this->path . '.' . (string) time() . self::HISTORY_EXT;

            if (!rename($this->path, $filename)) {
                throw new RuntimeException('Failed to rename history,'
                 . ' file, check path and permissions.');
            }
        }

        if (is_file($this->path) and !is_writable($this->path)) {
            throw new RuntimeException("File $this->path is not writable.");
        }

        $data = $this->serializer->serialize($persistable);

        if (!file_put_contents($this->path, $data, LOCK_EX)) {
            throw new RuntimeException('Failed to save persistable to'
                . ' filesystem, check path and permissions.');
        }
    }
687047
public function persist($entity)
    {
        if (!$this->isRepositoryWritable()) {
            throw $this->createNotWritableException();
        }

        return $this->trigger(__FUNCTION__, [
            'entity' => $entity,
        ]);
    }
1202977
public function save(File $file, $preparedPath)
    {
        if (false === ($i = array_search($preparedPath, $this->preparedPaths))) {
            throw new \RuntimeException("{$preparedPath} is not prepared by the filemanager");
        }
        unset($this->preparedPaths[$i]);
        $existed = $this->fs->exists($preparedPath);
        @$this->fs->remove($preparedPath);

        try {
            $this->dispatchEvent($existed ? ResourceEvent::REPLACED : ResourceEvent::CREATED, $preparedPath);
            $file->move(dirname($preparedPath), basename($preparedPath));
        } catch (FileException $fileException) {
            throw new FileException(
                $fileException->getMessage() . "\n(hint: check the 'upload_max_filesize' in php.ini)",
                0,
                $fileException
            );
        }
    }
129727
public function persist($model)
    {
        if (!$this->save($model)) {
            if ($model->hasErrors()) {
                throw new SaveFailedException(get_class($model), print_r($model->getErrors(), true));
            }

            throw new SaveFailedException(get_class($model));
        }

        if (!$this->isSaved($model)) {
            $this->markSaved($model);
        }
    }
1133823
public function save($data): void
    {
        $filepath = $this->filepath;
        $dir = $this->getPath();

        if (!$this->mkdir($dir)) {
            throw new \RuntimeException('Creating directory failed for ' . $filepath);
        }

        try {
            if ($this->handle) {
                $tmp = true;
                // As we are using non-truncating locking, make sure that the file is empty before writing.
                if (@ftruncate($this->handle, 0) === false || @fwrite($this->handle, $data) === false) {
                    // Writing file failed, throw an error.
                    $tmp = false;
                }
            } else {
                // Create file with a temporary name and rename it to make the save action atomic.
                $tmp = $this->tempname($filepath);
                if (@file_put_contents($tmp, $data) === false) {
                    $tmp = false;
                } elseif (@rename($tmp, $filepath) === false) {
                    @unlink($tmp);
                    $tmp = false;
                }
            }
        } catch (\Exception $e) {
            $tmp = false;
        }

        if ($tmp === false) {
            throw new \RuntimeException('Failed to save file ' . $filepath);
        }

        // Touch the directory as well, thus marking it modified.
        @touch($dir);
    }
651099
public function save(EventInterface $event) {
        $request = $event->getRequest();
        $database = $event->getDatabase();

        $user = $request->getUser();
        $imageIdentifier = $request->getImage()->getImageIdentifier();

        try {
            $database->updateMetadata(
                $user,
                $imageIdentifier,
                $this->properties
            );
        } catch (DatabaseException $e) {
            $database->deleteImage($user, $imageIdentifier);

            throw new RuntimeException('Could not store EXIF-metadata', 500);
        }
    }
1249234
public function rollback()
    {
        try {
            $this->persistenceHandler->rollback();
        } catch (Exception $e) {
            throw new RuntimeException($e->getMessage(), 0, $e);
        }
    }
1097401
private function insert() {
        if ($this->isPersistent()) throw new RuntimeException('Cannot insert already persistent '.$this);

        // pre-processing hook
        if ($this->beforeInsert() !== true)
            return $this;

        $mapping = $this->dao()->getMapping();

        // collect column values
        $values = [];
        foreach ($mapping['columns'] as $column => $property) {
            $values[$column] = $this->getPhysicalValue($column);
        };

        // perform insertion
        $id = $this->doInsert($values);
        $this->_modified = false;

        // assign the returned identity value
        $idName = $mapping['identity']['name'];
        if ($this->$idName === null)
            $this->$idName = $id;

        // post-processing hook
        $this->afterInsert();
        return $this;
    }
1083491
public function saved(Model $model)
    {
        if ($model::$__es_enable && $model->shouldIndex())
        {
            Queue::push('Iverberk\Larasearch\Jobs\ReindexJob', $this->findAffectedModels($model));
        }
    }
712943
public function persist() : void
    {
        if ($this->statements) {
            $this->loader->addOperation(static::DESCRIPTION, $this->statements);
            $this->statements = [];
        }
    }
573924
public function persist(PersistableInterface $persistable, $remember = false)
    {
        try
        {
            if ($this->single)
            {
                $this->flush($persistable);
            }

            $code = $persistable->generatePersistenceCode();

            $this->session->put($code);

            if ($remember === true) {
                $this->cookie->put($code);
            }

            $persistence = $this->create($persistable, $code);

            $entityManager = $this->getEntityManager();
            $entityManager->persist($persistence);
            $entityManager->flush();

            return true;
        }
        catch (\Exception $e)
        {
            return false;
        }
    }
559269
public function persist($entity)
    {
        if ($this->evm->hasListeners(Events::prePersist)) {
            $this->evm->dispatchEvent(Events::prePersist, new Event\LifecycleEventArgs($entity, $this->sm));
        }

        $oid = spl_object_hash($entity);
        $this->scheduledForPersist[$oid] = $entity;

        if ($this->evm->hasListeners(Events::postPersist)) {
            $this->evm->dispatchEvent(Events::postPersist, new Event\LifecycleEventArgs($entity, $this->sm));
        }
    }
52243
private function initializeDoctrine()
    {
        if ($this->cm !== null) {
            return;
        }

        if (! self::$entityManager) {
            throw new RuntimeException('No runtime entity manager set. Call PersistentObject#setEntityManager().');
        }

        $this->cm = self::$entityManager->getClassMetadata(static::class);
    }
272220
protected function persist($entity)
    {
        $manager = $this->getDoctrine()->getManager();
        $manager->persist($entity);
        $manager->flush();
    }
1095360
function setModelPersist(MongoDB\BSON\Persistable $persistable)
    {
        // reset _query collection
        $this->_q = null;
        
        $this->typeMap['root'] = get_class($persistable);
        $this->persist = $this->typeMap['root'];
        return $this;
    }
468408
public function load() : Persistable
    {
        if (!is_readable($this->path)) {
            throw new RuntimeException("File $this->path does not"
                . ' exist or is a folder, check path and permissions.');
        }
            
        $data = file_get_contents($this->path) ?: '';

        $persistable = $this->serializer->unserialize($data);

        if (!$persistable instanceof Persistable) {
            throw new RuntimeException('Model could not be reconstituted.');
        }

        return $persistable;
    }
880493
public function handlePersist(PersistEvent $event)
    {
        if (!$this->supports($event->getDocument())) {
            return;
        }

        $this->persistEvents[] = $event;
    }