Add data in batch from an array
@param array $data
@param bool $overwrite
@return Data
504913
public function add($data, $overwrite = true)
    {
        foreach ($data as $property => $value) {
            if ($overwrite || !$this->offsetExists($property)) {
                $this->set($property, $value);
            }
        }
        return $this;
    }
115592
public function add(RendererInterface $item, $overWrite = false)
    {
        $uid = sha1(get_class($item).'_'.sha1(json_encode($item->supportedExtensions())));

        foreach ($item->supportedExtensions() as $ext) {
            if ($this->has($ext) && ! $overWrite) {
                throw new Exception('The collection ['. 1 .'] already collects for the path ['. 1 .']');
            }
        }

        $this->items[$uid] = $item;

        foreach ($item->supportedExtensions() as $ext) {
            $this->lookupTable[$ext] = $uid;
        }
    }
518977
public function addElement( $tag, $element, $overwrite = FALSE )
	{
		$this->add( array( $tag => $element ), $overwrite );
	}
862541
public function append($append = [], $override = false)
    {
        $this->append = $override ? $append : array_merge($this->append, $append);

        return $this;
    }
1177399
public function setConfig(array $config, $overwrite = false)
    {
        if ($overwrite) {
            $this->config = $this->mergeConfig($this->config, $config);
        } else {
            $this->config = $this->mergeConfig($config, $this->config);
        }
    }
153899
private function parse_files($path, $overwrite = true)
    {
        if (\is_dir($path)) {
            $files = \glob($path . '*.php');
        }

        if (!empty($files)) {
            foreach ($files as $file) {
                /** @noinspection PhpIncludeInspection */
                $parsed_options = require $file;

                $option_set = $this->get_filename($file);

                if (!\is_array($parsed_options)) {
                    continue;
                }

                if (isset($this->config[ $option_set ])) {
                    if ($overwrite) {
                        $this->config[ $option_set ] = \array_merge($this->config[ $option_set ], $parsed_options);
                    } else {
                        $this->config[ $option_set ] = \array_merge($parsed_options, $this->config[ $option_set ]);
                    }
                } else {
                    $this->config[ $option_set ] = $parsed_options;
                }
            }
        }
    }
200944
public function set( $key, $value, $overwrite = true )
    {
        Option::set( $this->_map, $this->_hashKey( $key ), $value, $overwrite );

        return $this;
    }
938701
private function loadFromFile($filename, $overwrite = false)
    {
        try {
            $yamlDatas = Yaml::parse(file_get_contents($filename));

            if (is_array($yamlDatas)) {
                if (true === $this->debug) {
                    $this->debug_data[$filename] = $yamlDatas;
                }

                if (self::CONFIG_FILE.'.'.self::EXTENSION === basename($filename) ||
                    self::CONFIG_FILE.'.'.$this->environment.'.'.self::EXTENSION === basename($filename)) {
                    foreach ($yamlDatas as $component => $config) {
                        if (!is_array($config)) {
                            $this->container->get('logger')->error('Bad configuration, array expected, given : '.$config);
                        }
                        $this->setSection($component, $config, $overwrite);
                    }
                } else {
                    $this->setSection(basename($filename, '.'.self::EXTENSION), $yamlDatas, $overwrite);
                }
            }
        } catch (ParseException $e) {
            throw new InvalidConfigException($e->getMessage(), null, $e, $e->getParsedFile(), $e->getParsedLine());
        }
    }
120106
public function copyFiles($files, $overwrite = null)
	{
		/*
		 * To allow for manual override on the overwriting flag, we check to see if
		 * the $overwrite flag was set and is a boolean value.  If not, use the object
		 * allowOverwrite flag.
		 */

		if (is_null($overwrite) || !is_bool($overwrite))
		{
			$overwrite = $this->overwrite;
		}

		/*
		 * $files must be an array of filenames.  Verify that it is an array with
		 * at least one file to copy.
		 */
		if (is_array($files) && count($files) > 0)
		{

			foreach ($files as $file)
			{
				// Get the source and destination paths
				$filesource = Path::clean($file['src']);
				$filedest = Path::clean($file['dest']);
				$filetype = array_key_exists('type', $file) ? $file['type'] : 'file';

				if (!file_exists($filesource))
				{
					/*
					 * The source file does not exist.  Nothing to copy so set an error
					 * and return false.
					 */
					$this->log(LogLevel::WARNING, Text::sprintf('JLIB_INSTALLER_ERROR_NO_FILE', $filesource));

					return false;
				}
				elseif (($exists = file_exists($filedest)) && !$overwrite)
				{

					// It's okay if the manifest already exists
					if ($this->getPath('manifest') == $filesource)
					{
						continue;
					}

					// The destination file already exists and the overwrite flag is false.
					// Set an error and return false.
					$this->log(LogLevel::WARNING, Text::sprintf('JLIB_INSTALLER_ERROR_FILE_EXISTS', $filedest));

					return false;
				}
				else
				{
					// Copy the folder or file to the new location.
					if ($filetype == 'folder')
					{
						if (!(Folder::copy($filesource, $filedest, null, $overwrite)))
						{
							$this->log(LogLevel::WARNING, Text::sprintf('JLIB_INSTALLER_ERROR_FAIL_COPY_FOLDER', $filesource, $filedest));

							return false;
						}

						$step = array('type' => 'folder', 'path' => $filedest);
					}
					else
					{
						if (!(File::copy($filesource, $filedest, null)))
						{
							$this->log(LogLevel::WARNING, Text::sprintf('JLIB_INSTALLER_ERROR_FAIL_COPY_FILE', $filesource, $filedest));

							// In 3.2, TinyMCE language handling changed.  Display a special notice in case an older language pack is installed.
							if (strpos($filedest, 'media/editors/tinymce/jscripts/tiny_mce/langs'))
							{
								$this->log(LogLevel::WARNING, Text::_('JLIB_INSTALLER_NOT_ERROR'));
							}

							return false;
						}

						$step = array('type' => 'file', 'path' => $filedest);
					}

					/*
					 * Since we copied a file/folder, we want to add it to the installation step stack so that
					 * in case we have to roll back the installation we can remove the files copied.
					 */
					if (!$exists)
					{
						$this->stepStack[] = $step;
					}
				}
			}
		}
		else
		{
			// The $files variable was either not an array or an empty array
			return false;
		}

		return count($files);
	}
756838
public function copy($dest, $overwrite = true)
    {
        if (!$this->exists() || is_file($dest) && !$overwrite) {
            return false;
        }

        return copy($this->path, $dest);
    }
606811
public function add(array $translations, $override = false)
    {
        if ($override) {
            $this->_data = array_merge($this->_data, $translations);
        } else {
            $this->_data = array_merge($translations, $this->_data);
        }

        return true;
    }
96762
public function options($options, bool $overwrite = false)
    {
        if ($overwrite) {
            $this->options = $options;
        } else {
            $this->options = array_replace_recursive($this->options, $options);
        }

        return $this;
    }
40112
public function update($key, $data, $overide = false)
    {
        if (!$this->has($key)) {
            return false;
        }

        if (!is_array($this->storage[$key]) || $overide === true) {
            $this->storage[$key] = $data;

            return true;
        }

        if (!is_array($data)) {
            $data = [$data];
        }

        $this->storage[$key] = array_merge($this->storage[$key], $data);

        return true;
    }
394066
public function make($data, $code, $overwrite = false)
    {
        // Status returned.
        $status = (preg_match('/^(1|2|3)/', $code)) ? 'success' : 'error';

        // Change object to array.
        if (is_object($data))
        {
            $data = $data->toArray();
        }

        // Data as a string.
        if (is_string($data))
        {
            $data = array('message' => $data);
        }

        // Overwrite response format.
        if ($overwrite === true)
        {
            $response = $data;
        }
        else
        {
            $message = $this->statuses[$code];

            // Custom return message.
            if (isset($data['message']))
            {
                $message = $data['message'];

                unset($data['message']);
            }

            // Available data response.
            $response = array(
                'status'     => $status,
                'code'       => $code,
                'message'    => $message,
                'data'       => $data,
                'pagination' => null
            );

            // Merge if data has anything else.
            if (isset($data['data']))
            {
                $response = array_merge($response, $data);
            }

            // Remove empty array.
            $response = array_filter($response, function($value)
            {
                return ! is_null($value);
            });

            // Remove empty data.
            if ($this->config['removeEmptyData'] && empty($response['data']))
            {
                unset($response['data']);
            }
        }

        // Header response.
        $header = ($this->config['httpResponse']) ? $code : 200;

        return Response::make($response, $header);
    }
128002
public function copyItem(string $targetId, string $itemId, bool $overwrite = false):array
    {
        $parameters = $this->buildHttpQuery(
            [
                'targetid'  => $targetId,
                'overwrite' => $overwrite,
            ]
        );

        return $this->post("Items({$itemId})/Copy?{$parameters}");
    }
428661
public function createGroup($name, $overwrite = false)
    {
        if (isset($this->groups[$name])) {
            return $this->groups[$name];
        }

        $assets = $this->createAssetArray($name);
        $filters = $this->createFilterArray($name);
        $coll = new AssetCollection($assets, $filters);

        if ($output = $this->getConfig($name, 'output')) {
            $coll->setTargetPath($output);
        }

        // check output cache
        $write_output = true;
        if (!$overwrite) {
            if (file_exists($output = public_path($coll->getTargetPath()))) {
                $output_mtime = filemtime($output);
                $asset_mtime = $coll->getLastModified();

                if ($asset_mtime && $output_mtime >= $asset_mtime) {
                    $write_output = false;
                }
            }
        }

        // store assets
        if ($overwrite || $write_output) {
            $writer = new AssetWriter(public_path());
            $writer->writeAsset($coll);
        }

        return $this->groups[$name] = $coll;
    }
45063
public function add($key, $value, $override = false)
    {
        if ($override || !isset($this->_data[$key])) {
            $this->_data[$key] = $value;
        }
    }