@param Folder|null $folder

@return $this|Folder
489231
public function folder(Folder $folder = null)
    {
        if (is_null($folder)) {
            return $this->folder;
        }

        $this->folder = $folder;

        return $this;
    }
681500
public void addSourceFolder(File folder) {
		Assert.notNull(folder, "Folder must not be null");
		Assert.isTrue(!folder.isFile(), "Folder '" + folder + "' must not be a file");
		synchronized (this.monitor) {
			checkNotStarted();
			this.folders.put(folder, null);
		}
	}
861893
public function createFolder(Folder $folder)
	{
		// validating folder before creation
		foreach ($this->folderUploadFilters as $filter) {
			$filter->validateFolder($folder);
		}

		$this->createBothFoldersInFileSystem($folder);
	}
134574
public function show($folder)
    {
        $this->manager->resetPath($folder);

        if (!$this->manager->blobExists()) {
            return $this->json('File not found.', 404);
        }

        $list = $this->manager->folderContent();

        return $this->json($list);
    }
204975
public function removeFolder($folders = null)
    {
        $folders = (array) $folders;
        $folders = array_map([$this->paths, 'getFolder'], $folders);
        $folders = implode(' ', $folders);

        return $this->modulable->run('rm -rf '.$folders);
    }
436399
public function addChildren(Folder $folder)
    {
        $ids = '';
        foreach ($folder->getChildren() as $child) {
            $ids .= ' and folder.id != '.$child->getId();
            $ids .= $this->addChildren($child);
        }

        return $ids;
    }
706827
public function getFolder(...$folder)
    {
        $folder = implode('/', $folder);
        $folder = $this->modulable->replacePatterns($folder);

        $base = $this->connections->is('local') ? getcwd() : $this->getHomeFolder();
        $base = $base.'/';
        $stage = $this->connections->getCurrentConnectionKey()->stage;
        if ($folder && $stage) {
            $base .= $stage.'/';
        }

        // Replace base and cap it
        $folder = preg_replace('#^'.$base.'#', null, $folder);
        $folder = $base.$folder;

        return $folder;
    }
920382
public function setRootFolder( string $folder ) : VfsHandler
   {

      if ( ! @\is_dir( $folder ) )
      {
         throw new ArgumentException(
            'folder',
            $folder,
            'The defined VFS root directory not exists!'
         );
      }

      $this->_rootFolder = \rtrim( $folder, '/\\' );

      return $this;

   }
1324705
private function createBothFoldersInFileSystem(FileAbstraction $folder = null)
	{
		if ($folder instanceof File) {
			$folder = $folder->getParent();
		}

		$this->createFolderInFileSystem($this->getExternalPath(), $folder);
		$this->createFolderInFileSystem($this->getInternalPath(), $folder);
	}
674385
public function trashRestoreFolderAction(Folder $folder)
    {
        $folder->setIsDeleted(false);

        $this->persist($folder, true);

        $this->addFlash('success', 'Папка восстановлена.');

        return $this->redirectToRoute('cms_admin_structure_trash');
    }
595307
public function update(Folder $folder)
    {
        $this->em->persist($folder);
        $this->em->flush($folder);

        $uriPart = $folder->getUriPart();

        // Если не указан сегмент URI, тогда он устанавливается в ID папки.
        if (empty($uriPart) and $folder->getId() > 1) {
            $folder->setUriPart($folder->getId());
            $this->em->persist($folder);
            $this->em->flush($folder);
        }

        return $this;
    }
885914
public function runInFolder($folder = null, $tasks = [])
    {
        // Convert to array
        if (!is_array($tasks)) {
            $tasks = [$tasks];
        }

        // Prepend folder
        array_unshift($tasks, 'cd '.$this->paths->getFolder($folder));

        return $this->run($tasks);
    }
168030
protected function getIterator($folder)
    {
        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator($folder,
                \RecursiveDirectoryIterator::SKIP_DOTS),
            \RecursiveIteratorIterator::SELF_FIRST,
            \RecursiveIteratorIterator::CATCH_GET_CHILD // Ignore "Permission denied"
        );
        $files = new RegexIterator($iterator, '/^.+Exception\.php$/i', RecursiveRegexIterator::GET_MATCH);

        return $files;
    }
937009
public function trashPurgeFolderAction(Folder $folder)
    {
        $this->get('cms.folder')->remove($folder);

        $this->addFlash('success', 'Папка удалена.');

        return $this->redirectToRoute('cms_admin_structure_trash');
    }
27134
public function addFolder($folder, $extension): ConfigCollection {
        $extLen = strlen($extension);
        $files = scandir($folder, SCANDIR_SORT_ASCENDING);
        foreach ($files as $file) {
            if (in_array($file, ['.','..'])) {
                continue;
            }
            if (substr($file, -$extLen) != $extension) {
                continue;
            }
            $config = FileConfig::load(paths($folder, $file), false);
            if ($config) {
                $this->addConfig($config);
            }
        }
        return $this;
    }
689462
public static function addFolder(&$array, $folder)
    {
        if (is_array($folder)) {
            foreach ($folder as $item) {
                self::addFolder($array, $item);
            }
        } else {
            if (is_dir($folder) && !in_array($folder, $array)) {
                $array[] = $folder;
            }
        }
    }
639498
protected function setCurrentFolder(FileFolder $value = null)
    {
        if ($value !== $this->currentFolder) {
            $this->currentFolder = $value;
            $this->currentFolderPermissions = null;
        }

        return $this;
    }