Create a new AssetCollection instance for the given group.

@param  string                         $name
@param  bool                           $overwrite force writing
@return \Assetic\Asset\AssetCollection
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;
    }
96762
public function options($options, bool $overwrite = false)
    {
        if ($overwrite) {
            $this->options = $options;
        } else {
            $this->options = array_replace_recursive($this->options, $options);
        }

        return $this;
    }
1322931
public static function set($name, $value = null, $range = null, $overwrite=true)
    {
        static::_init();
        
        $range = $range ?: self::$range;
        if (!isset(self::$data[$range])) {
            self::$data->set($range, []);
        }
        
        if (!$name && is_array($value)) {
            foreach ($value as $k => $v) {
                self::set($k, $v, $range, $overwrite);
            }
            return self::$data[$range];
        } elseif (is_string($name)) {
            $old = static::$data->get($range);
            if (!strpos($name, '.')) {
                $temp = [$name => $value];
                
                if ($overwrite || !isset($old[$name])) {
                    $new = ArrayHelper::merge($old, $temp);
                    static::$data->set($range, $new);
                }
                
                return self::$data[$range][$name];
            } else {
                // has '.'
                $names = explode('.', $name, 2);
                $temp = [$names[0] => [$names[1] => $value]];
                
                if ($overwrite || !isset( $old[$names[0]][$names[1]] )) {
                    $new = ArrayHelper::merge($old, $temp);
                    static::$data->set($range, $new);
                }
                
                return self::$data[$range][$names[0]][$names[1]];
            }
        } elseif (is_array($name)) {
            // batch set
            if (!empty($value) && is_string($value)) {
                return static::set($value, $name, null, $overwrite);
            } else {
                foreach ($name as $k => $v){
                    self::set($k, $v, $range, $overwrite);
                }
                return self::$data[$range];
            }
        } else {
            // if no name return config
            return self::$data[$range];
        }
    }
993291
public function createCollection($name, $options = [])
    {
        try {
            if (isset($options['capped'])) {
                $options['capped'] = (bool) $options['capped'];
            }

            $this->db->createCollection($name, $options);
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            return false;
        }

        return $this->selectCollection($name);
    }
832177
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;
        }

        $config = array();

        /*
         * $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 = JPath::clean($file['src']);
                $filedest = JPath::clean($file['dest']);
                $filetype = array_key_exists('type', $file) ? $file['type'] : 'file';

                $config[$this->relativeTargetPath($filedest)] = $this->relativeJoomlaTargetPath($filedest);

                $filedestCopy = $this->rewriteTargetPath($filedest);
                $filedestCopyContainer = dirname($filedestCopy);

                if (!file_exists(dirname($filedest))) {
                    mkdir(dirname($filedest), 0777, true);
                }

                if (!file_exists($filesource))
                {
                    /*
                     * The source file does not exist.  Nothing to copy so set an error
                     * and return false.
                     */
                    JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_NO_FILE', $filesource), JLog::WARNING, 'jerror');

                    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.
                    JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_FILE_EXISTS', $filedest), JLog::WARNING, 'jerror');

                    return false;
                }
                else
                {
                    // Copy the folder or file to the new location.
                    if ($filetype == 'folder')
                    {
                        if (!(JFolder::copy($filesource, $filedest, null, $overwrite))) {
                            JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_FAIL_COPY_FOLDER', $filesource, $filedest), JLog::WARNING, 'jerror');

                            return false;
                        }

                        if (!is_dir($filedestCopyContainer)) {
                            mkdir($filedestCopyContainer, 0775, true);
                        }

                        if (!(JFolder::copy($filedest, $filedestCopy, null, $overwrite))) {
                            JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_FAIL_COPY_FOLDER', $filedest, $filedestCopy), JLog::WARNING, 'jerror');

                            return false;
                        }

                        $step = array('type' => 'folder', 'path' => $filedest);
                    }
                    else
                    {
                        if (!(JFile::copy($filesource, $filedest, null))) {
                            JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_FAIL_COPY_FILE', $filesource, $filedest), JLog::WARNING, 'jerror');

                            // 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'))
                            {
                                JLog::add(JText::_('JLIB_INSTALLER_NOT_ERROR'), JLog::WARNING, 'jerror');
                            }

                            return false;
                        }

                        if (!is_dir($filedestCopyContainer)) {
                            mkdir($filedestCopyContainer, 0775, true);
                        }

                        if (!(JFile::copy($filedest, $filedestCopy, null))) {
                            JLog::add(JText::sprintf('JLIB_INSTALLER_ERROR_FAIL_COPY_FILE', $filedest, $filedestCopy), JLog::WARNING, 'jerror');

                            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;
        }

        self::$assetInstaller->addToConfig($config);
        self::$assetInstaller->install();

        return count($files);
    }
605926
public static function asset($string, $name = null, $return = true)
    {

        $filePath = '';
        if (!file_exists($filePath)) {
            $filePath = BASE_DIR . $string;
        }
        $filenamePath = AssetsParser::findDomainPath($string, $filePath);

        $filePath = self::processAsset($string, $name, $return, $filenamePath);
        $basePath = Config::getParam('resources.cdn.url', Request::getInstance()->getRootUrl());
        $returnPath = empty($name) ? $basePath . '/' . $filePath : $name;
        return $return ? $returnPath : '';
    }
207327
public static function create(string $path, string $content = '', bool $overwrite = true): self
    {
        $path = normalize_path($path);

        if (is_file($path) && $overwrite) {
            self::unlink($path);
        }
        if (!is_file($path)) {
            if (is_writeable(dirname($path))) {
                if ($handle = fopen($path, 'w')) {
                    fwrite($handle, $content);
                    fclose($handle);

                    return new static($path);
                }
                throw new FileException('Creating file ('.$path.') failed');
            }
            throw new FileException('Cannot create file, because the directory ('.dirname($path).') is not accessible',
                FileException::NOT_WRITEABLE);
        }
        throw new FileException('Cannot create file, because the file path ('.$path.') already exist', FileException::ALREADY_EXIST);
    }
386006
protected function doCreateCollection($name, array $options)
    {
        $this->mongoDB->createCollection($name, $options);

        return $this->doSelectCollection($name);
    }
41107
protected function _generateScaledImagesForId($id, $overwrite = false) {
        if (!$id) {
            return;
        }

        $imageModel = new Model_Image();
        $record     = $imageModel->fetchById($id);
        return $this->_generateScaledImagesForFilename($record->filename);
    }
1217884
public function set($name, $url, $overwrite = false)
    {
        if (!$overwrite && array_key_exists($name, $this->aliases)) {
            return false;
        }
        $this->aliases[$name] = $url;
        return true;
    }
194977
public function bcc($address, $name = null, $override = false)
    {
        if ($override) {
            $this->swift->setBcc($address, $name);

            return $this;
        }

        return $this->addAddresses($address, $name, 'Bcc');
    }
1133936
public static function config($name = null, $config = null, $override = false)
    {
        $overrideAll = (is_array($name) && is_bool($config)) ? $config : false;

        return Util::operateArray(self::$agentsConfig, $name, $config, [], function ($name, array $config) use ($override) {
            self::modifyConfig($name, $config, $override);
        }, $overrideAll, function (array $origin) {
            foreach (array_keys($origin) as $name) {
                if (self::hasAgent("$name")) {
                    self::getAgent("$name")->config([], true);
                }
            }
        });
    }
1072911
public function addAttribute(string $name, string $value, $overwrite = false): FieldTypeInterface
    {
        if (isset($this->options['attributes'][$name]) && ! $overwrite) {
            $this->options['attributes'][$name] .= ' '.$value;
        } else {
            $this->options['attributes'][$name] = $value;
        }

        return $this;
    }
150526
public function addMetaData($key, $value, $overwrite = true)
    {
        $this->meta[$key] = isset($this->meta[$key])
            ? $overwrite ? $value : $this->meta[$key]
            : $value;

        return $this;
    }
1356564
public function create($overrides = array(), $associated = array()) {
        $data = $this->build($overrides, $associated);
        $this->_collection->insert($data,array("w"=>1));
        return $data;
    }
639421
public function save($filename, $overwrite = false)
    {

        if ($this->html)
        {
            $this->snappy->generateFromHtml($this->html, $filename, $this->options, $overwrite);
        }
        elseif ($this->file)
        {
            $this->snappy->generate($this->file, $filename, $this->options, $overwrite);
        }

        return $this;
    }
242871
public function rename($name = '', $append = '', $prepend = '', $overwrite = false) {
        if (is_callable($name)) {
            $name = call_user_func_array($name, array($this->name(), $this));
        } else {
            $name = $name ?: $this->name();
        }

        // Add boundaries
        $name = (string) $prepend . $name . (string) $append;

        // Remove unwanted characters
        $name = preg_replace('/[^_\-\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/imu', '-', $name);

        // Rename file
        $ext = $this->ext() ?: MimeType::getExtFromType($this->type(), true);
        $newName = $name;

        // Don't overwrite
        if (!$overwrite) {
            $no = 1;

            while (file_exists($this->dir() . $newName . '.' . $ext)) {
                $newName = $name . '-' . $no;
                $no++;
            }
        }

        $targetPath = $this->dir() . $newName . '.' . $ext;

        if (rename($this->path(), $targetPath)) {
            $this->reset($targetPath);

            return true;
        }

        return false;
    }