Redaxscript\Assetic\Loader::concat PHP Method

concat() public method

concat the collection
Since: 3.0.0
public concat ( array $optionArray = [], array $rewriteArray = [] ) : Loader
$optionArray array
$rewriteArray array
return Loader
    public function concat($optionArray = [], $rewriteArray = [])
    {
        $bundleArray = [];
        $restArray = [];
        /* prevent as needed */
        if ($this->_registry->get('noCache')) {
            return $this;
        }
        /* process collection */
        foreach ($this->_collectionArray as $collectionKey => $attributeArray) {
            $path = $attributeArray[$optionArray['attribute']];
            $fileArray = pathinfo($path);
            if (is_file($path) && $fileArray['extension'] === $optionArray['extension']) {
                $bundleArray[] = $attributeArray[$optionArray['attribute']];
            } else {
                $restArray[] = $attributeArray;
            }
        }
        /* cache as needed */
        $cache = new Cache();
        $cache->init($optionArray['directory'], $optionArray['extension']);
        /* load from cache */
        if ($cache->validate($bundleArray, $optionArray['lifetime'])) {
            $this->_collectionArray = $restArray;
            $this->_collectionArray['bundle'] = [$optionArray['attribute'] => $cache->getPath($bundleArray)];
            if ($optionArray['extension'] === 'css') {
                $this->_collectionArray['bundle']['rel'] = 'stylesheet';
            }
        } else {
            $content = $this->_getContent($bundleArray, $rewriteArray);
            $cache->store($bundleArray, $content);
        }
        return $this;
    }