@param string $chunkName
@return array list of assets for the given chunk

@throws ChunkNotFoundException
329992
public function getAssets($chunkName)
    {
        if (!isset($this->assetsByChunkName[$chunkName])) {
            throw ChunkNotFoundException::create($chunkName);
        }

        return (array) $this->assetsByChunkName[$chunkName];
    }
220016
public function chunk($size)
    {
        $chunked = array_chunk($this->array, $size);

        return new static(array_map(function ($item) {
            return new static($item);
        }, $chunked));
    }
625433
protected function readRow($handle, $chunkSize)
    {
        $row = str_getcsv($this->readLine($handle, 0), $this->separator, $this->delimiter);

        if ($this->isSkippableRow($row)) {
            return [];
        }

        if (!$this->hasHeader) {
            return array_map( function ($value) { return $this->convertEncoding($value); }, $row);
        }

        $namedRow = [];

        foreach ($this->header as $i=>$column) {
            $namedRow[$column] = $this->convertEncoding($row[$i]);
        }

        return $namedRow;
    }
270761
private function parseChunk($chunk)
    {
        /**
         * Base Case
         */
        if (!$chunk) {
            return [];
        }

        /**
         * 100 is a special case
         */
        if ($chunk == 100) {
            return ['cem'];
        }

        /**
         * Testing contractions (11~19)
         */
        if (($chunk < 20) && ($chunk > 10)) {
            return [self::$contractions[$chunk % 10]];
        }

        $i = strlen($chunk) - 1;
        $n = (int) $chunk[0];
        $word = self::$words[$i][$n];

        return array_merge([$word], $this->parseChunk(substr($chunk, 1)));
    }
489933
public function find($name)
    {
        $name = $this->config->get("basset.aliases.assets.{$name}", $name);

        // Spin through an array of methods ordered by the priority of how an asset should be found.
        // Once we find a non-null path we'll return that path breaking from the loop.
        foreach (array('RemotelyHosted', 'PackageAsset', 'WorkingDirectory', 'PublicPath', 'AbsolutePath') as $method)
        {
            if ($path = $this->{'find'.$method}($name))
            {
                return $path;
            }
        }

        throw new AssetNotFoundException;
    }
845553
protected function getSavedChunksFiles()
    {
        $chunkFileName = preg_replace(
            "/\.[\d]+\.".ChunkStorage::CHUNK_EXTENSION.'$/', '', $this->handler()->getChunkFileName()
        );

        return $this->chunkStorage->files(function ($file) use ($chunkFileName) {
            return false === str_contains($file, $chunkFileName);
        });
    }
16904
public static function assets($assetName = null)
	{
		//get the server name from global $_SERVER[] array()
		$base  = $_SERVER['SERVER_NAME']; 

		$url = Registry::getUrl();

		//check if there is a uri string
		if ( ! empty($url) ) 
		{
			//prepend installation folder to server name
			$base .= substr($_SERVER['REQUEST_URI'], 0,  strpos($_SERVER['REQUEST_URI'], Registry::getUrl()));

		}
		//there is no query string, 
		else
		{
			//prepend installation folder to server name
			$base .= substr($_SERVER['REQUEST_URI'], 0);

		}


    	//use https if its defined in the $_SERVER global variable
    	$protocol = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != "off") ? "https" : "http";

		//compose the url string
		return $protocol . '://' . $base . 'public/' . $assetName;

	}
812340
public function dump($fileName)
    {
        $fileDir = $this->assetsResolver->resolveAssetSourcePath($this->module->getCode(), false, $fileName, $this->parser);

        if (null !== $fileDir) {
            $content = file_get_contents($fileDir . DS . $fileName);
            if (false === $content) {
                $content = "";
            }
        } else {
            $content = sprintf("ERR: Unknown file %s for module %s", $fileName, $this->module->getCode());
        }

        return $content;
    }
517178
protected function createResampledAsset($filename) {
        $fullpath = Director::baseFolder() . '/' . $filename;
        $asset = ContentServiceAsset::get()->filter('Filename', $filename)->first();

		if(!$asset) {
            $asset = new ContentServiceAsset();
        }

        $this->service = singleton('ContentService');


        $asset->Filename = $filename;
        $asset->SourceID = $this->ID;
        $asset->ParentID = $this->ParentID;
        $mtime = time();

        $writer = $this->service->getWriterFor($asset, 'FilePointer', $this->targetStore());
        if ($writer) {
            if (file_exists($fullpath)) {
                // likely that cached image never got built correctly.
                $name = \Controller::join_links(dirname($filename), $mtime, basename($filename));
                $writer->write(fopen($fullpath, 'r'), $name);

                $asset->FilePointer = $writer->getContentId();
                $asset->write();

                $reader = $writer->getReader();
                if ($reader && $reader->exists()) {
                    singleton('ContentDeliveryService')->removeLocalFile($fullpath);
                }
            } else {
                $asset = null;
            }
        } else {
            $asset = null;
        }

        return $asset;
    }
877663
private function loadFile(string $filename) : array
    {
        Assertion::file($filename, 'File "' . $filename . '" does not exist.');
        Assertion::readable($filename, 'File "' . $filename . '" is not readable.');

        /** @var string $fileContent */
        $fileContent = file_get_contents($filename);

        Assertion::string($fileContent);

        if (preg_match('/[^ -~\s]/', $fileContent)) {
            throw new \RuntimeException('File "' . $filename . '" contains Non-ASCII-Characters.');
        }

        $jsonParser = new JsonParser();

        try {
            return $jsonParser->parse($fileContent, JsonParser::DETECT_KEY_CONFLICTS | JsonParser::PARSE_TO_ASSOC);
        } catch (ParsingException $e) {
            throw new \RuntimeException(
                'File "' . $filename . '" had invalid JSON.',
                0,
                $e
            );
        }
    }
1327583
public function directories($directoryName)
    {
        if (!$this->isDir($directoryName)) {
            throw new FileNotFoundException('Directory not found in the path [ ' . $directoryName . ' ].');
        }

        $iterator = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($directoryName,
                RecursiveDirectoryIterator::CURRENT_AS_FILEINFO)
        );

        $directories = [];

        foreach($iterator as $file) {
            if($file->isDir()) {
                if( !(substr($file,-2) === '..')) {
                    $directories[] = trim($file,'.');
                }
            }
        }

        array_shift($directories);

        return $directories;
    }
318552
private function getSuccessUploadedChunks(): array
    {
        $path = $this->getChunkListFilePath();

        if (!file_exists($path)) {
            return [];
        }

        $data = file_get_contents($path);
        $data = explode(',', $data);
        unset($data[count($data) - 1]);
        sort($data);

        return $data;
    }
1042659
function filename_info(json, assets_base_url)
{
	const assets_by_chunk = json.assetsByChunkName

	const assets_chunks =
	{
		javascript: {},
		styles: {}
	}

	// gets asset paths by name and extension of their chunk
	function get_assets(name, extension)
	{
		let chunk = json.assetsByChunkName[name]

		// a chunk could be a string or an array, so make sure it is an array
		if (!(Array.isArray(chunk)))
		{
			chunk = [chunk]
		}

		return chunk
			// filter by extension
			.filter(name => path.extname(name).split('?')[0] === `.${extension}`)
			// adjust the real path (can be http, filesystem)
			.map(name => assets_base_url + name)
	}

	// for each chunk name ("main", "common", ...)
	Object.keys(assets_by_chunk).forEach(function(name)
	{
		// log.debug(`getting javascript and styles for chunk "${name}"`)

		// get javascript chunk real file path

		const javascript = get_assets(name, 'js')[0]
		// the second asset is usually a source map

		if (javascript)
		{
			// log.debug(` (got javascript)`)
			assets_chunks.javascript[name] = javascript
		}

		// get style chunk real file path

		const style = get_assets(name, 'css')[0]
		// the second asset is usually a source map

		if (style)
		{
			// log.debug(` (got style)`)
			assets_chunks.styles[name] = style
		}
	})

	return assets_chunks
}
1024836
public function getStubsNamesInDirectory($directoryName)
    {
        if (!$path = $this->getStubDirPath($directoryName)) {
            return [];
        }

        return array_map(
            function($file) {
                return basename($file, '.stub');
            },
            glob("$path/*.stub")
        );
    }
798500
public function findAssets () : array
    {
        $assets = [];

        foreach ($this->namespaces as $namespace => $dir)
        {
            if (!\is_dir($dir))
            {
                continue;
            }

            $finder = new Finder();

            $finder
                ->files()
                ->followLinks()
                ->in($dir);

            foreach ($finder as $foundFile)
            {
                $assets[] = new Asset($namespace, $foundFile->getRelativePathname());
            }
        }

        return $assets;
    }
187378
public function getAssetUrl(\Twig_Environment $twig, $path, $packageName = null)
    {
        /** @var AssetExtension $asset */
        $asset = $twig->getExtension('Symfony\Bridge\Twig\Extension\AssetExtension');

        if (isset($this->assetMap[$path])) {
            $path = $this->assetMap[$path];
        }

        return $asset->getAssetUrl($path, $packageName);
    }
451680
public function renderChunk( $chunk, $data = []) {
		foreach ( $data as $key => $value ) {
			$data['{' . strtoupper( $key ) . '}'] = $value;
		}
		
		return strtr( $chunk, $data );
	}