Assigne saved files into the layoutFiles array defintion.

@param array $layoutFiles
@param string $path
491483
protected function handleLayoutFile(&$layoutFiles, $path)
    {
        $aliased = Yii::getAlias($path, false);
        $filePath = $aliased ? $aliased : $path;
        
        if (is_dir($filePath)) {
            foreach ($this->getFilesFromFolder($filePath) as $file) {
                $handler = $this->importLayoutFile($file, $path);
                if ($handler) {
                    $layoutFiles[] = $handler;
                }
            }
        } else {
            $handler = $this->importLayoutFile($filePath, $path);
            if ($handler) {
                $layoutFiles[] = $handler;
            }
        }
    }
47121
public static function load(string $path): void
    {
        $filePath = \absolute_path($path, static::FILE);
        if (!\is_readable($filePath) || !\is_file($filePath)) {
            return;
        }

        $array = self::optimizeGet($path, $filePath);

        if ($array === false) {
            $array = \parse_ini_file($filePath, false, INI_SCANNER_RAW);
        }

        foreach ($array as $name => $value) {
            static::set($name, $value);
        }

        self::optimizeSet($path, $array, $filePath);
    }
1211048
public function afterLayout($layoutFile) {
		$content = $this->_View->Blocks->get('content');
		$content = $this->_prepareHtmlContent($content);

		if (!isset($this->InlineCss)) {
			$options = [
				'engine' => InlineCssLib::ENGINE_CSS_TO_INLINE,
				'xhtmlOutput' => true,
			];
			$this->InlineCss = new InlineCssLib($options);
		}
		$content = trim($this->InlineCss->process($content));

		$this->_View->Blocks->set('content', $content);
	}
848159
private function compactDimensionGroups( &$nodes, $path = "" )
	{
		if ( $this->includeDefaults ) return;

		foreach ( $nodes as $nodeKey => &$node )
		{
			// If there are no children then its a leaf node so there is nothing to do
			if ( ! isset( $node['children'] ) || count( $node['children'] ) === 0 ) continue;

			// Process nodes recursively
			$this->compactDimensionGroups( $node['children'], "$path/{$node['label']}" );

			if ( isset( $child ) ) unset( $child );

			// Once the child nodes have been processed, compact this node
			// This node will be compacted if there is only one child and that child is the default member
			if ( $node['nodeclass'] === 'dimension' )
			{
				// If its a dimension node does the node have a default member?
				// If there are only non-default children keep this node
				if ( ! isset( $node['hasdefault'] ) || ! $node['hasdefault'] ) continue;

				// If it has a default member is there only one member?
				if ( ! isset( $node['children'] ) ) continue;
				if ( count( $node['children'] ) > 1 ) continue;

				// Is the child the default node?
				// Child may have been set before
				// unset( $child );
				$child = reset( $node['children'] );
				if ( ! isset( $child['default'] ) || ! $child['default'] ) continue;

				$retainChildren = isset( $child['retainchildren'] );
				if ( $retainChildren ) $node['retainchildren'] = true;

				// The child is the only member and it is a default,  It can be removed.
				if ( isset( $child['elements'] ) )
				{
					// Bump the elements of the child up to the current node
					$node['elements'] = $child['elements'];

					if ( ! $retainChildren )
					{
						// Remove the child as a member of 'children' if it exists
						if ( isset( $node['children'][ $child['label'] ] ) )
						{
							unset( $node['children'][ $child['label'] ] );
							unset( $node['children'] );
						}
					}
				}
				else
				{
					$retainChildren = true;
					$node['defaulttext'] = $child['text'];
				}

				if ( $retainChildren )
				{
					// Bump the children up.  This is legit and will not override any other children
					// because the check above confirms this is the only child of $node
					$node['children'] = $child['children'];
					// Child may have been set before
					unset( $child );
					// And reset the parent
					foreach ( $node['children'] as $childKey => &$child )
					{
						$child['parent'] = $node['label'];
					}
				}

				$node['default'] = true;
			}
			elseif ( $node['nodeclass'] === 'member' )
			{
				// If its a member node is it a default member?
				if ( ( ! isset( $node['default'] ) || ! $node['default'] ) &&
					 ! array_reduce( $node['children'], function( $carry, $item ) { return $carry === true ? true : isset( $item['default'] ) && $item['default']; }, false )
				   ) continue;

				// If it's a dimension,then process any children.  If the child is a dimension
				// without children delete it as it has been processed and found to be have
				// only default members.

				foreach ( $node['children'] as $childKey => $child )
				{
					if ( $child['nodeclass'] === 'dimension' && isset( $child['default'] ) && $child['default'] )
					{
						// If the child is the only member and it is a default then it can be removed.
						if ( isset( $child['elements'] ) && count( $child['elements'] ) > 0 ) continue;
						if ( isset( $child['children'] ) && count( $child['children'] ) > 0 ) continue;
						unset( $node['children'][ $childKey ] );
					}
					else if ( $child['nodeclass'] === 'primaryitem' )
					{
						$node['retainchildren'] = true;
					}
				}

				// If there is more than one child or none then move along
				if ( ! isset( $node['children'] ) || count( $node['children'] ) !== 1 ) continue;

				// If there is only one child remaining then if it has elements promote them as elements of this node
				// Child may have been set before
				unset( $child );
				$child = reset( $node['children'] );
				if ( $child['nodeclass'] !== 'primaryitem' )
				{
					if ( $child['nodeclass'] === 'dimension' && isset( $child['children'] ) && count( $child['children'] ) > 1 )
					{
						// Or are all the children non-dimensional (eg primary items)?
						if ( count( array_filter( $child['children'],
							function( $node ) {
								return $node['nodeclass'] === 'dimension' ||
								$node['nodeclass'] === 'member';
							} ) ) !== 0
						)
						continue;
					}

					$retainChildren = isset( $child['retainchildren'] );
					if ( $retainChildren ) $node['retainchildren'] = true;

					if ( isset( $child['elements'] ) && count( $child['elements'] ) > 0 )
					{
						if ( isset( $node['elements'] ) )
						{
							// $node['elements'] = array_merge( $node['elements'], $child['elements'] );
							foreach ( $child['elements'] as $elementKey => $element )
							{
								if ( ! $this->entry_is_unique( $node['elements'], $element, $element['entity'] ) ) continue;
								$node['elements'][] = $element;
							}
						}
						else
						{
							$node['elements'] = $child['elements'];
						}

						if ( ! $retainChildren )
						{
							if ( isset( $node['children'][ $child['label'] ] ) )
							{
								unset( $node['children'][ $child['label'] ] );
								unset( $node['children'] );
							}
						}
					}
					else
					{
						$retainChildren = true;
					}

					if ( $retainChildren )
					{
						$node['children'] = $child['children'];
						// Child may have been set before
						unset( $child );
						foreach ( $node['children'] as $childKey => &$child )
						{
							$child['parent'] = $node['label'];
						}
					}

					$node['default'] = true;
				}
			}
			else
			{
				// The node is not dimension or member so check to see if the only child is a default
				// If it is, remove it.
				if ( ! isset( $node['children'] ) ) continue;
				if ( count( $node['children'] ) === 0 )
				{
					unset( $node['children'] );
					continue;
				}

				// There's more than one so move along
				if ( count( $node['children'] ) > 1 ) continue;

				// Is the child a dimension?
				// unset( $child );
				$child = reset( $node['children'] );
				if ( $child['nodeclass'] !== 'dimension' ) continue;
				if ( isset( $child['children'] ) && count( $child['children'] ) > 1 )
				{
					// Or are all the children non-dimensional (eg primary items)?
					if ( count( array_filter( $child['children'],
						function( $node ) {
							return $node['nodeclass'] === 'dimension' ||
							$node['nodeclass'] === 'member';
						} ) ) !== 0
					)
					continue;
				}

				// OK, is the child a default
				if ( ! isset( $child['hasdefault'] ) || ! isset( $child['default'] ) || ! $child['default'] ) continue;

				$retainChildren = isset( $child['retainchildren'] );

				if ( isset( $child['elements'] ) && count( $child['elements'] ) > 0 )
				{
					if ( isset( $node['elements'] ) )
					{
						// $node['elements'] = array_merge( $node['elements'], $child['elements'] );
						foreach ( $child['elements'] as $elementKey => $element )
						{
							if ( ! $this->entry_is_unique( $node['elements'], $element, $element['entity'] ) ) continue;
							$node['elements'][] = $element;
						}
					}
					else
					{
						$node['elements'] = $child['elements'];
					}

					if ( ! $retainChildren )
					{
						if ( isset( $node['children'][ $child['label'] ] ) )
						{
							unset( $node['children'][ $child['label'] ] );
							unset( $node['children'] );
						}
					}
				}
				else
				{
					$retainChildren = true;
				}

				if ( $retainChildren )
				{
					$node['children'] = $child['children'];
					// Child may have been set before
					unset( $child );
					foreach ( $node['children'] as $childKey => &$child )
					{
						$child['parent'] = $node['label'];
					}
				}

			}
		}
	}
579659
public function writeFile($path) {
        if (is_array($path)) {
            $this->files = array_merge($this->files, $path);
        }
        elseif (!empty($path)) {
            $this->files[] = $path;
        }
    }
796828
public function addCommands($path)
	{
		if(($commands=$this->findCommands($path))!==array())
		{
			foreach($commands as $name=>$file)
			{
				if(!isset($this->commands[$name]))
					$this->commands[$name]=$file;
			}
		}
	}
1171786
protected  function createFiles($path, $files)
    {

        $this->fs->ensureDirectory($path);
        foreach ( $files as $file ) {
            $fileName = Util::toFileName($file->entity[ 'full_name' ], '.dat');
            #$export   = Util::exportArray($file->toArray());
            $export = serialize($file);
            $this->fs->put(path_join($path, $fileName), $export);
        }
    }
956747
public function save(Layout $layout)
    {
        $archiveDir = $this->getUploadDir().'/archives';
        $templateDir = $this->getUploadDir().'/templates';
        $tmpDir = $this->getUploadDir().'/tmp/'.time();

        // Copy the archive to the archive directory
        $file = $layout->getFile()->move(
            $archiveDir,
            $layout->getFile()->getClientOriginalName()
        );

        // Extract the archive
        $zip = new \ZipArchive();
        $zip->open($archiveDir.'/'.$layout->getFile()->getClientOriginalName());
        $zip->extractTo($tmpDir);
        $zip->close();

        $config = $this->readConfiguration($tmpDir);

        $this->om->beginTransaction();
        try {
            $id = $this->getUniqueId($layout);

            $this->saveInDb(
                $config['label'],
                'uploads/' . $id . '/' . $config['templateName'],
                '/bundles/canaltpmtt/img/uploads/' . $id . '/' . $config['previewFileName'],
                $config['orientation'],
                isset($config['pageSize']) ? $config['pageSize'] : Layout::PAGE_SIZE_A4
            );

            // Move the assets
            $this->moveFiles(array('*.png', '*.jpg'), $tmpDir, $templateDir . '/img/' . $id);
            $this->moveFiles('*.twig', $tmpDir, $templateDir . '/twig/' . $id);
            $this->moveFiles('*.css', $tmpDir, $templateDir . '/css/' . $id, false);

            // If the layout has a fonts directory, we copy this directory to the css one.
            if ($fontsDirs = $this->getDirectories($tmpDir, 'fonts')) {
                $this->filesystem->remove($templateDir . '/css/' . $id . '/fonts');
                $this->filesystem->rename(current($fontsDirs), $templateDir . '/css/' . $id . '/fonts', true);
            }

            // Remove the tmp directory
            $this->filesystem->remove($tmpDir);
            $this->om->commit();
        } catch (\Exception $e) {
            $this->om->rollback();
            throw $e;
        }
    }
645498
private function addFiles($zip, $path = null)
	{
		if (!$path)
		{
			$path = $this->current;
		}

		$source = str_replace('\\', '/', realpath($path));

		if (is_dir($source) === true)
		{
			$files = new \RecursiveIteratorIterator(
				new \RecursiveDirectoryIterator($source), \RecursiveIteratorIterator::SELF_FIRST
			);

			foreach ($files as $file)
			{
				$file = str_replace('\\', '/', $file);

				if (substr($file, 0, 1) == ".")
				{
					continue;
				}

				// Ignore "." and ".." folders
				if (in_array(substr($file, strrpos($file, '/') + 1), array('.', '..')))
				{
					continue;
				}

				$file = str_replace('\\', '/', $file);

				if (is_dir($file) === true)
				{
					$zip->addEmptyDir(str_replace($source . '/', '', $file . '/'));
				}
				else if (is_file($file) === true)
				{
					$zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file));
				}
			}
		}
		else if (is_file($source) === true)
		{
			$zip->addFromString(basename($source), file_get_contents($source));
		}
	}
10161
protected function put(string $path, array $params = [], array $headers = [])
    {
        $body = self::createJsonBody($params);

        if ($body) {
            $headers = self::addJsonContentType($headers);
        }

        return $this->putRaw($path, $body, $headers);
    }
470678
protected function createDirectory($paths)
    {
        if (!is_array($paths)) {
            $paths = array($paths);
        }

        foreach ($paths as $path) {
            if (!is_dir($dir = dirname($path)) && false === @mkdir($dir, 0777, true)) {
                // @codeCoverageIgnoreStart
                throw new \RuntimeException(sprintf('Unable to create directory "%s".', $dir));
                // @codeCoverageIgnoreEnd
            }
        }
    }
838643
public function setTemplatePaths(array $paths)
    {
        $this->paths = [];
        foreach ($paths as $namespace => $path) {
            $this->addTemplatePath($namespace, $path);
        }
    }
390905
public function saveSitemap($path, array $entities)
    {
        $sitemap = new SiteMapEntity();
        foreach ($entities as $location) {
            $sitemap->setLastmod(new \DateTime());
            $sitemap->addLocation($location);
        }

        $this->saveFile($path, $sitemap->getXml());

        return $sitemap;
    }
1362012
private static function createIndexFilesToPreventDirectoryListing($path)
    {
        if (!self::isPathWithinTmpFolder($path)) {
            return;
        }
        $filesToCreate = array(
            $path . '/index.htm',
            $path . '/index.php'
        );
        foreach ($filesToCreate as $file) {
            @file_put_contents($file, 'Nothing to see here.');
        }
    }
1328154
public static function prependIncludePath(...$path): void
    {
        $finalPaths = [];
        foreach ($path as $r) {

            if (is_array($r)) {
                foreach ($r as $t) {
                    $finalPaths[] = $t;
                }
            } else {
                $finalPaths[] = $r;
            }
        }

        foreach (explode(PATH_SEPARATOR, get_include_path()) as $r) {
            $finalPaths[] = $r;
        }

        set_include_path(implode(PATH_SEPARATOR, array_unique($finalPaths)));
    }
57690
protected function processStubs($stubs, $path): void
    {
        $this->makeDirectory($path);
        $this->files->copyDirectory($stubs, $path);

        $files = [
            ($phpunit = $path.DIRECTORY_SEPARATOR.'phpunit.xml.dist') => $this->files->get($phpunit),
            ($composer = $path.DIRECTORY_SEPARATOR.'composer.json') => $this->files->get($composer),
            ($changelog = $path.DIRECTORY_SEPARATOR.'CHANGELOG.md') => $this->files->get($changelog),
            ($readme = $path.DIRECTORY_SEPARATOR.'README.md') => $this->files->get($readme),
        ];

        $module = ucfirst(str_after($this->getNameInput(), '/'));
        $name = implode(' ', array_map('ucfirst', explode('/', $this->getNameInput())));
        $jsonNamespace = implode('\\\\', array_map('ucfirst', explode('/', $this->getNameInput())));

        foreach ($files as $key => &$file) {
            $file = str_replace('DummyModuleName', $name, $file);
            $file = str_replace('Dummy\\\\Module', $jsonNamespace, $file);
            $file = str_replace('DummyModuleServiceProvider', $jsonNamespace."\\\\Providers\\\\{$module}ServiceProvider", $file);

            $file = str_replace('dummy/module', $this->getNameInput(), $file);
            $file = str_replace('dummy-module', str_replace('/', '-', $this->getNameInput()), $file);
            $file = str_replace('dummy:module', str_replace('/', ':', $this->getNameInput()), $file);
            $file = str_replace('dummy.module', str_replace('/', '.', $this->getNameInput()), $file);

            $this->files->put($key, $file);
        }
    }
333614
protected  function createManifest($path, $files)
    {
        $data = [ ];
        foreach ( $files as $file ) {
            $data[] = [
                'type'      => $file[ 'type' ],
                'name'      => $file[ 'entity' ][ 'name' ],
                'full_name' => $file[ 'entity' ][ 'full_name' ],
                'namespace' => $file[ 'entity' ][ 'namespace' ],
            ];
        }
        $this->fs->put($path, Util::exportArray($data));
        return $data;
    }