Create and return directory.

@param string $directory
@param ContainerBuilder $container

@return string
963578
private function createOrGetFolder($directory, ContainerBuilder $container)
    {
        $filesystem = new Filesystem();

        $directory = $container->getParameterBag()->resolveValue($directory);
        if (!file_exists($directory)) {
            $filesystem->mkdir($directory);
        }

        return $directory;
    }
866960
public function createEmptyDirectory($directory)
    {
        if (!is_dir($directory)) {
            mkdir($directory, 0777, true);
        } else {
            $this->deleteTree($directory, false);
        }
    }
467281
private function getDirectoryIterator(string $directory): \DirectoryIterator
    {
        if ($directory === 'default') {
            return new \DirectoryIterator($this->dataDirectory);
        }
        return new \DirectoryIterator($directory);
    }
924250
private function write($directory): void
    {
        $dockerfile = [];
        // Insert a FROM instruction if the file does not start with one.
        if (empty($this->commands) || $this->commands[0]['type'] !== 'FROM') {
            $dockerfile[] = 'FROM base';
        }
        foreach ($this->commands as $command) {
            switch ($command['type']) {
                case 'FROM':
                    $dockerfile[] = 'FROM '.$command['image'];
                    break;
                case 'RUN':
                    $dockerfile[] = 'RUN '.$command['command'];
                    break;
                case 'ADD':
                    $dockerfile[] = 'ADD '.$this->getFile($directory, $command['content']).' '.$command['path'];
                    break;
                case 'ADDFILE':
                    $dockerfile[] = 'ADD '.$this->getFileFromDisk($directory, $command['file']).' '.$command['path'];
                    break;
                case 'ADDSTREAM':
                    $dockerfile[] = 'ADD '.$this->getFileFromStream($directory, $command['stream']).' '.$command['path'];
                    break;
                case 'COPY':
                    $dockerfile[] = 'COPY '.$command['from'].' '.$command['to'];
                    break;
                case 'ENV':
                    $dockerfile[] = 'ENV '.$command['name'].' '.$command['value'];
                    break;
                case 'WORKDIR':
                    $dockerfile[] = 'WORKDIR '.$command['workdir'];
                    break;
                case 'EXPOSE':
                    $dockerfile[] = 'EXPOSE '.$command['port'];
                    break;
                case 'VOLUME':
                    $dockerfile[] = 'VOLUME '.$command['volume'];
                    break;
                case 'USER':
                    $dockerfile[] = 'USER '.$command['user'];
                    break;
            }
        }

        if (!empty($this->entrypoint)) {
            $dockerfile[] = 'ENTRYPOINT '.$this->entrypoint;
        }

        if (!empty($this->command)) {
            $dockerfile[] = 'CMD '.$this->command;
        }

        $this->fs->dumpFile($directory.DIRECTORY_SEPARATOR.'Dockerfile', \implode(PHP_EOL, $dockerfile));
    }
949884
private function setStandardThemeDirectories(ContainerBuilder $container)
    {
        if (!$container->hasParameter('kernel.bundles_metadata')) {
            return;
        }

        $bundlesMetaData = $container->getParameter('kernel.bundles_metadata');
        if (!isset($bundlesMetaData['EzPublishCoreBundle']['path'])) {
            return;
        }

        $templatesPathMap = $container->hasParameter('ezdesign.templates_path_map')
            ? $container->getParameter('ezdesign.templates_path_map')
            : [];

        $templatesPathMap['standard'][] = $bundlesMetaData['EzPublishCoreBundle']['path'] . '/Resources/views';

        $container->setParameter('ezdesign.templates_path_map', $templatesPathMap);
    }
508368
private function getDefinitionDir($type, array $driverConfig, ContainerBuilder $container)
    {
        $defaultDir = sprintf('%s/Resources/As3ModlrBundle', $container->getParameter('kernel.root_dir'));

        $folder = sprintf('%ss', $type);
        $key = sprintf('%s_dir', $type);

        return isset($driverConfig['parameters'][$key])
            ? Utility::locateResource($driverConfig['parameters'][$key], $container)
            : sprintf('%s/%s', $defaultDir, $folder)
        ;
    }
356878
public function directories($directory)
    {
        return collect($this->filesystem->directories($directory))
            ->map(function ($file) {
                return new File($file, $this);
            });
    }
523218
protected function createDir($dir)
    {
        if (!is_dir($dir) && !mkdir($dir, 0755, true)) {
            throw new \RuntimeException(
                sprintf('Unable to create cache directory %s, check permissions', $dir)
            );
        }

        if (!is_writable($dir)) {
            throw new BadPermissionException(
                sprintf('Cache directory %s is not writable, check permissions', $dir)
            );
        }
    }
642593
public function buildPath($key, $directory, $create)
    {
        $this->ensureDirectoryExists($directory, $create);

        return $this->normalizeDirectoryPath($directory . '/' . $key);
    }
708201
private function getFileSystem(ContainerInterface $container): FileSystemInterface
    {
        assert($container->has(FileSystemInterface::class));

        /** @var FileSystemInterface $fileSystem */
        $fileSystem = $container->get(FileSystemInterface::class);

        return $fileSystem;
    }
698582
public function build(ContainerBuilder $container)
    {
        parent::build($container);

        $container->addCompilerPass(new WidgetContentResolverPass());
        //get widgetItems
        $container->addCompilerPass(new WidgetItemPass());
    }
721553
public function setDirectory(Directory $directory)
    {
        $this->directory = $directory;
        $this->iterator = new \ArrayIterator($directory->children());
    }
1328639
public static function create(string $dir = ''): bool
    {
        $ret = true;
        $dir = static::normalizePath($dir);
        if (static::verifyPath($dir) && !\file_exists($dir)) {
            $components = \explode(DIRECTORY_SEPARATOR, $dir);
            $newDirectory = '';

            foreach ($components as $component) {
                $newDirectory .= $component.DIRECTORY_SEPARATOR;
                if (static::verifyPath($dir) && !\file_exists($newDirectory)) {
                    @\mkdir($newDirectory, static::$newDirectoryMode);
                    @\chmod($newDirectory, static::$newDirectoryMode);
                }
            }
            return \file_exists($dir) ? true : false;
        }
        return $ret;
    }
15402
protected function createDirectory($directory)
    {
        // create parent directory if needed
        $parent = \Gaufrette\Util\Path::dirname($directory);
        if (!$this->isDir($parent)) {
            $this->createDirectory($parent);
        }

        // create the specified directory
        $created = ftp_mkdir($this->getConnection(), $directory);
        if (false === $created) {
            throw new \RuntimeException(sprintf('Could not create the \'%s\' directory.', $directory));
        }
    }
220138
protected function createFileLocator($directory)
    {
        if (!is_dir($directory) || !is_readable($directory)) {
            throw new \InvalidArgumentException(sprintf('Could not create procedure loader as directory does not exist or is not readable: "%s"', $directory));
        }

        return new FileLocator($directory);
    }
826931
public function mkdir($directory) {
        if (false === @ftp_mkdir($this->getConnection(), $directory)) {
            throw $this->newFTPException(sprintf("mkdir %s failed", $directory));
        }
        return $this;
    }
1065498
public function mkdir(string $directory, int $mode = null): bool {
    if (!empty($directory)) {
      if ($folders = explode(DIRECTORY_SEPARATOR, Path::replaceOSSeparator($directory))) {
        $fullpath = null;
        if (empty($mode)) {
          $mode = AccessMode::MOD_0777;
        }
        foreach ($folders as $folder) {
          if (!empty($folder)) {
            $fullpath .= DIRECTORY_SEPARATOR . $folder;
            $this->createDirectory($fullpath, $mode);
          }
        }
      }
    }
    return file_exists($directory);
  }