Copy temporary project data to persistent storage.

@param string[] $with
@throws ReadException
173
private function updateStorage($with = [])
    {
        $data = array_merge($this->data, $with);
        $this->fs->create($this->fsPath, json_encode($data));
    }
422328
public static function copyFrom($src, StreamInterface $dest)
    {
        $srcStream = $src instanceof StreamInterface ? $src : new Stream($src, Stream::MODE_READ_ONLY_FROM_BEGIN);

        static::copy($srcStream, $dest);

        $srcStream->close();
    }
1002992
public static function prepend_each_line($string, $with)
    {
        $lines = explode("\n", $string);
        $append = '';
        if ("\n" === substr($string, -1) && '' === end($lines)) {
            // Last line might be empty because $string was terminated
            // with a newline, remove it from the $lines array,
            // we'll restore state by re-terminating the string at the end
            array_pop($lines);
            $append = "\n";
        }
        foreach ($lines as &$line) {
            $line = $with . $line;
        }
        unset($line);

        return implode("\n", $lines) . $append;
    }
1102058
public function loadFile($with = array())
    {
        return $this->getManager()->loadModel($this->owner->{$this->idAttribute}, $with);
    }
1351247
public static function indexFile( $withAccessPath = true )
    {
        $sys  = self::instance();
        $text = $sys->IndexFile;

        if ( $withAccessPath && ( isset( $sys->AccessPath['siteaccess']['url'][0] ) || isset( $sys->AccessPath['path']['url'][0] ) ) )
        {
            $ini = eZINI::instance();
            if ( isset( $sys->AccessPath['siteaccess']['url'][0] ) &&
                 $ini->variable( 'SiteAccessSettings', 'RemoveSiteAccessIfDefaultAccess' ) === 'enabled' )
            {
                $defaultAccess = $ini->variable( 'SiteSettings', 'DefaultAccess' );
                // 1st is proper match where code has used updated api as of 4.4, do not use siteaccess
                if ( $sys->AccessPath['siteaccess']['name'] === $defaultAccess )
                    $accessPath = implode( '/', $sys->AccessPath['path']['url'] );
                // 2nd is for compatability with older code that used eZSys api withouth defining scopes, shift default siteaccess path
                elseif ( $sys->AccessPath['siteaccess']['name'] === 'undefined' && $sys->AccessPath['siteaccess']['url'][0] === $defaultAccess )
                {
                    $accessPathArray = $sys->AccessPath;
                    array_shift( $accessPathArray['siteaccess']['url'] ); //remove default siteaccess
                    $accessPath = implode( '/', array_merge( $accessPathArray['siteaccess']['url'], $accessPathArray['path']['url'] ) );
                }
                // In case there is no default siteaccess match use full url
                else
                    $accessPath = implode( '/', array_merge( $sys->AccessPath['siteaccess']['url'], $sys->AccessPath['path']['url'] ) );
            }
            else
            {
                $accessPath = implode( '/', array_merge( $sys->AccessPath['siteaccess']['url'], $sys->AccessPath['path']['url'] ) );
            }

            $text .= '/' . $accessPath;

            // Make sure we never return just a single '/' in case where siteaccess was shifted
            if ( $text === '/' )
                $text = '';
        }
        return $text;
    }
738161
public function with($with)
    {
        if (! is_array($with)) {
            $with = func_get_args();
        }

        $this->with = $with;

        return $this;
    }
477502
public function save(array $answers)
    {
        $path = $this->directory . DIRECTORY_SEPARATOR . $this->file;

        if (!file_exists($path)) {
            if (!is_writable($this->directory)) {
                throw new WritableException(
                    sprintf(
                        'The env file is not present and the directory `%s` is not writeable!',
                        $this->directory
                    )
                );
            }

            touch($path);
        }

        if (!is_writable($path)) {
            throw new WritableException(sprintf('The env file `%s` is not writeable!', $path));
        }

        $text = '';
        foreach ($answers as $key => $value) {
            $text .= sprintf("%s=%s\n", $key, $value);
        }

        file_put_contents($path, $text);
    }
412775
public function copyCellCollection(PHPExcel_Worksheet $parent) {
		parent::copyCellCollection($parent);
		//	Get a new id for the new file name
		$baseUnique = $this->_getUniqueID();
		$newCachePrefix = substr(md5($baseUnique),0,8).'.';
		$cacheList = $this->getCellList();
		foreach($cacheList as $cellID) {
			if ($cellID != $this->_currentObjectID) {
				$success = false;
				$obj = wincache_ucache_get($this->_cachePrefix.$cellID.'.cache', $success);
				if ($success === false) {
					//	Entry no longer exists in WinCache, so clear it from the cache array
					parent::deleteCacheData($cellID);
					throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in Wincache');
				}
				if (!wincache_ucache_add($newCachePrefix.$cellID.'.cache', $obj, $this->_cacheTime)) {
					$this->__destruct();
					throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in Wincache');
				}
			}
		}
		$this->_cachePrefix = $newCachePrefix;
	}
1164025
public static function copy(StreamInterface $src, StreamInterface $dest)
    {
        if ($src->isSeekable()) {
            $src->rewind();
        }

        while (!$src->eof()) {
            $dest->write($src->read(4096));
        }
    }
82380
public function copyCellCollection(PHPExcel_Worksheet $parent) {
        parent::copyCellCollection($parent);
        //    Get a new id for the new file name
        $baseUnique = $this->_getUniqueID();
        $newCachePrefix = substr(md5($baseUnique),0,8).'.';
        $cacheList = $this->getCellList();
        foreach($cacheList as $cellID) {
            if ($cellID != $this->_currentObjectID) {
                $obj = apc_fetch($this->_cachePrefix.$cellID.'.cache');
                if ($obj === FALSE) {
                    //    Entry no longer exists in APC, so clear it from the cache array
                    parent::deleteCacheData($cellID);
                    throw new PHPExcel_Exception('Cell entry '.$cellID.' no longer exists in APC');
                }
                if (!apc_store($newCachePrefix.$cellID.'.cache',$obj,$this->_cacheTime)) {
                    $this->__destruct();
                    throw new PHPExcel_Exception('Failed to store cell '.$cellID.' in APC');
                }
            }
        }
        $this->_cachePrefix = $newCachePrefix;
    }
536586
public function copy(string $source, string $destination) : bool
    {
        $status = @copy($source, $destination);

        if (false === $status) {
            throw new FileException('Cannot copy source to destination.');
        }

        return $status;
    }
297430
public function all(array $with = [], $all = false)
    {
        $query = $this->with($with);

        if (!$all) {
            $query->published();
        }

        // Query ORDER BY
        $query->order();

        // Get
        return $query->get();
    }
1339764
public function copyCellCollection(PHPExcel_Worksheet $parent)
    {
        parent::copyCellCollection($parent);
        //    Open a new stream for the cell cache data
        $newFileHandle = fopen('php://temp/maxmemory:' . $this->memoryCacheSize, 'a+');
        //    Copy the existing cell cache data to the new stream
        fseek($this->fileHandle, 0);
        while (!feof($this->fileHandle)) {
            fwrite($newFileHandle, fread($this->fileHandle, 1024));
        }
        $this->fileHandle = $newFileHandle;
    }
1229449
public function save($con = null)
    {
        if (!method_exists($this->getFullyQualifiedModel(), 'save')) {
            throw new ReadOnlyModelException('Cannot save objects on a read-only model');
        }
        if (null === $con) {
            $con = $this->getWriteConnection();
        }
        $con->transaction(function () use ($con) {
            /** @var $element ActiveRecordInterface */
            foreach ($this as $element) {
                $element->save($con);
            }
        });
    }
931625
public function merge(ModelInformationInterface $with)
    {
        if ( ! empty($with->model)) {
            $this->model = $with->model;
        }

        if ( ! empty($with->original_model)) {
            $this->original_model = $with->original_model;
        }

        $mergeAttributes = [
            'single',
            'meta',
            'verbose_name',
            'translated_name',
            'verbose_name_plural',
            'translated_name_plural',
            'allow_delete',
            'delete_condition',
            'delete_strategy',
            'confirm_delete',
            'list',
            'form',
            'show',
            'export',
            'reference',
            'includes',
        ];

        foreach ($mergeAttributes as $attribute) {
            $this->mergeAttribute($attribute, $with->{$attribute});
        }
    }
1016155
public function copy($from, $to)
    {
        $from = ltrim($from, "/");
        $to   = ltrim($to, "/");

        if (!$this->exists($from)) {
            $path = $this->bucket . "/" . $from;
            throw new ExceptionStorage("Object {$path} Not found", static::E_NOT_IS_DIR);
        }

        if ($this->exists($to)) {
            $path = $this->bucket . "/" . $to;
            throw new ExceptionStorage("Object {$path} exists");
        }

        // Copia Object
        $this->clientS3->copyObject(array(
            'Bucket'     => $this->bucket,
            'Key'        => $to,
            'CopySource' => $this->bucket . '/' . rawurlencode($from),
            'ACL'        => static::ACL_PUBLIC_READ,
            'MetadataDirective' => 'COPY',
        ));

        $pathFrom = trim($from, '/') . '/';

        $iterator = $this->clientS3->getIterator('ListObjects', array(
            'Bucket' => $this->bucket,
            'Prefix' => $pathFrom,
        ));

        foreach ($iterator as $object)
        {
            $pattern = preg_quote($pathFrom, "/");
            $Key = preg_replace("/^{$pattern}/", "", $object['Key']);

            if (!empty($Key))
            {
                $pattern = preg_quote($pathFrom, "/");
                $Key = preg_replace("/^{$pattern}/", "", $object['Key']);

                $origem  = $this->bucket . '/' . $object['Key'];
                $destino = trim($to, "/") . "/" . $Key;

                // Copia Object
                $this->clientS3->copyObject(array(
                    'Bucket'     => $this->bucket,
                    'Key'        => $destino,
                    'CopySource' => $origem,
                    'ACL'        => static::ACL_PUBLIC_READ,
                    'MetadataDirective' => 'COPY'
                ));
            }
        }

        return true;
    }
1131385
protected function copyExtras($files): void
    {
        foreach ($files as $source => $target) {
            $this->copy(
                $this->vendorPath . DS . $source,
                PATH_ROOT . DS . $target
            );
        }
    }