@param ExtendedFolderInterface $folder

@return array
512580
private function findStatusByFolder(ExtendedFolderInterface $folder)
    {
        $qb = $this->folderUsageRepository->createQueryBuilder('u');
        $qb
            ->select('u.status')
            ->join('u.folder', 'f')
            ->where($qb->expr()->eq('f.id', $qb->expr()->literal($folder->getId())));

        return array_column($qb->getQuery()->getScalarResult(), 'status');
    }
1365932
public function get_permflags($folder)
    {
        if (!strlen($folder)) {
            return array();
        }

        if (!$this->check_connection()) {
            return array();
        }

        if ($this->conn->select($folder)) {
            $permflags = $this->conn->data['PERMANENTFLAGS'];
        }
        else {
            return array();
        }

        if (!is_array($permflags)) {
            $permflags = array();
        }

        return $permflags;
    }
1187513
public static function delFolder($bucket, $folder) {
        if (empty($bucket) || empty($folder)) {
            return array(
                    'code' => COSAPI_PARAMS_ERROR,
                    'message' => 'bucket or path is empty');
        }

        $folder = self::normalizerPath($folder, True);

        return self::delBase($bucket, $folder);
    }
1112414
private function filterOutFolderMask(string $folder): string
    {
        $mask = '**';

        $folder = str_replace($mask . DIRECTORY_SEPARATOR, '', $folder);
        $folder = str_replace($mask, '', $folder);

        return $folder;
    }
664346
public function onGoToFolder()
    {
        $path = Input::get('path');

        if (Input::get('clearCache')) {
            MediaLibrary::instance()->resetCache();
        }

        if (Input::get('resetSearch')) {
            $this->setSearchTerm(null);
        }

        $this->setCurrentFolder($path);
        $this->prepareVars();

        return [
            '#'.$this->getId('item-list') => $this->makePartial('item-list'),
            '#'.$this->getId('folder-path') => $this->makePartial('folder-path')
        ];
    }
883080
public function folderContent()
    {
        $result = [];
        $path = $this->ensureUserPath($this->blob->path);

        $list = collect($this->storage->getDriver()->listContents($path))
            ->pluck('path');

        $exclude = (new ThumbService($this->package))->getSizes()->all();
        $isExcluded = function ($path) use ($exclude) {
            $parts = explode('/', Str::normalizePath($path));
            if (count($parts) > 0) {
                return array_key_exists($parts[0], $exclude);
            }

            return false;
        };

        $list->each(function ($glob) use (&$result, $isExcluded) {
            if ($isExcluded($glob)) {
                // skip any thumbs dir and do not show it for users
                return;
            }

            $result[] = (new Blob($this->package))
                ->setPath($glob)
                ->fullDetails();
        });

        return $result;
    }
367736
protected function resolveExtends()
    {
        $extend = [];
        foreach ($this->_targets as $name => $target) {
            if (empty($target['extend'])) {
                continue;
            }
            $parent = $target['extend'];
            if (empty($this->_targets[$parent])) {
                throw new RuntimeException("Invalid extend in '$name'. There is no '$parent' target defined.");
            }
            $extend[] = $name;
        }

        $expander = function ($target) use (&$expander, $extend) {
            $config = $this->_targets[$target];
            $parentConfig = false;

            // Recurse through parents to collect all config.
            if (in_array($target, $extend)) {
                $parentConfig = $expander($config['extend']);
            }
            if (!$parentConfig) {
                return $config;
            }
            $config['files'] = array_merge($parentConfig['files'], $config['files']);
            $config['filters'] = array_merge($parentConfig['filters'], $config['filters']);
            $config['theme'] = $parentConfig['theme'] || $config['theme'];
            return $config;
        };

        foreach ($extend as $target) {
            $this->_targets[$target] = $expander($target);
        }
    }
973385
public function getStatusInfo( $folder = NULL )
	{
		$address	= $this->connection->getAddress( $folder );
		$info		= imap_status( $this->connection->getStream(), $address, SA_ALL );
		if( !$info )
			throw new Exception( "imap_status() failed: ". imap_lasterror() );
		return array(
			"messages"	=> $info->messages,
			"recent"	=> $info->recent,
			"unseen"	=> $info->unseen,
		);
	}
850920
public function files(String $path, String $extension = NULL) : Array
    {
        $list = ftp_nlist($this->connect, $path);

        if( ! empty($list) ) foreach( $list as $file )
        {
            if( $file !== '.' && $file !== '..' )
            {
                if( ! empty($extension) && $extension !== 'dir' )
                {
                    if( Filesystem::getExtension($file) === $extension )
                    {
                        $files[] = $file;
                    }
                }
                else
                {
                    if( $extension === 'dir' )
                    {
                        $extens = Filesystem::getExtension($file);

                        if( empty($extens) )
                        {
                            $files[] = $file;
                        }
                    }
                    else
                    {
                        $files[] = $file;
                    }
                }
            }
        }

        if( ! empty($files) )
        {
            return $files;
        }
        else
        {
            return [];
        }
    }
593962
public function createFolderJson(Folder $folder)
    {
        $size = self::ICON_SIZE;
        $file = Injector::inst()->get('File');

        return array(
            'id' => $folder->ID,
            'parentID' => $folder->ParentID,
            'title' => $folder->Title,
            'filename' => $folder->Filename,
            'type' => 'folder',
            'extension' => self::FOLDER_EXTENSION,
            'created' => $folder->Created,
            'iconURL' => $folder->getPreviewThumbnail($size, $size)->URL,
            'canEdit' => $folder->canEdit(),
            'canCreate' => $folder->canCreate(),
            'canDelete' => $folder->canDelete(),
            'canUpload' => $folder->canEdit() && $file->canCreate()
        );
    }
436399
public function addChildren(Folder $folder)
    {
        $ids = '';
        foreach ($folder->getChildren() as $child) {
            $ids .= ' and folder.id != '.$child->getId();
            $ids .= $this->addChildren($child);
        }

        return $ids;
    }
166592
public function getUsedIn(ExtendedFolderInterface $folder)
    {
        $qb = $this->folderUsageRepository->createQueryBuilder('u');
        $qb
            ->select(['u.usageType', 'u.usageId', 'u.status'])
            ->join('u.folder', 'f')
            ->where($qb->expr()->eq('f.id', $qb->expr()->literal($folder->getId())));

        $usedIn = [];
        foreach ($qb->getQuery()->getScalarResult() as $row) {
            $usedIn[] = [
                'usage_type' => $row['usageType'],
                'usage_id' => $row['usageId'],
                'status' => $row['status'],
            ];
        }

        return $usedIn;
    }
681482
private function mapFolders(SS_List $folders, $searchQuery=null) {
        $result=array();
        
        foreach($folders as $folder) {
            if(!empty($searchQuery) && $searchQuery!==false) {
                $searchEngine=Config::inst()->get('CodeBank', 'snippet_search_engine');
                if($searchEngine && class_exists($searchEngine) && in_array('ICodeBankSearchEngine', class_implements($searchEngine))) {
                    $searchEngine=new $searchEngine();
                }else {
                    //Class is missing or invalid so fallback to the default
                    $searchEngine=new DefaultCodeBankSearchEngine();
                }
                
                $snippets=$searchEngine->doSnippetSearch($searchQuery, false, $folder->ID);
            }else {
                $snippets=$folder->Snippets();
            }
            
            $snippets=$this->overviewList($snippets, 'Title', 'ID', 'LanguageID');
            
            if(!empty($searchQuery) && $searchQuery!==false && count($snippets)==0) {
                continue;
            }
            
            $result[]=array(
                            'id'=>$folder->ID,
                            'name'=>$folder->Name,
                            'languageID'=>$folder->LanguageID,
                            'folders'=>$this->mapFolders($folder->Folders(), $searchQuery),
                            'snippets'=>$snippets
                        );
        }
        
        return $result;
    }
927632
public static function getList(): array
    {
        $result = [];
        $path = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'Types';
        $dir = new Folder($path);

        $files = $dir->find('.*\.php');

        if (empty($files)) {
            return $result;
        }

        foreach ($files as $file) {
            $name = str_replace('.php', '', $file);
            $value = Inflector::underscore($name);
            $result[$value] = $name;
        }

        return $result;
    }
1368428
private function validateFolder(FolderInterface $folder)
    {
        $errorList = $this->get('validator')->validate($folder);
        if ($errorList->count()) {
            return $errorList->get(0)->getMessage();
        }
        return true;
    }
966899
public static function getFiles($folder, $excludeFolders = self::INCLUDE_FOLDERS)
    {
        $files = [];

        if (false === is_dir($folder)) {
            return [];
        }

        $handle = opendir($folder);
        while (false !== ($entry = readdir($handle))) {
            if (true === in_array($entry, self::getDirSymbols())) {
                continue;
            }

            if (self::EXCLUDE_FOLDERS === $excludeFolders && true === is_dir(sprintf('%s/%s', $folder, $entry))) {
                continue;
            }

            $files[] = $entry;
        }

        closedir($handle);

        return $files;
    }
865626
public static function ListAllFiles( string $folder, bool $recursive = false ) : array
   {

      // Init the array that should contain the resulting file paths
      $files = [];

      if ( ! @\is_dir( $folder ) )
      {
         // No folder = we are done here
         return $files;
      }

      if ( ! $recursive )
      {
         // List only files directly contained inside $folder (none from sub folders)

         // Open the directory pointer
         $d = \dir( $folder );
         // Ignore . and ..
         $d->read(); $d->read();
         // loop the rest
         while ( false !== ( $entry = $d->read() ) )
         {
            $tmp = Path::Combine( $folder, $entry );
            if ( ! \is_file( $tmp ) )
            {
               // Ignore sub folders
               continue;
            }
            $files[] = $tmp;
         }
         $d->close();
         return $files;
      }

      // List all files, also from sub folders
      static::_listRecursive( $files, $folder );

      return $files;

   }