Get folder ancestors
@param Folder $folder the folder we want to get its ancestors
@return \Symfony\Component\HttpFoundation\Response
@Rest\ParamConverter(name="folder", class="BackBee\NestedNode\MediaFolder")
963353
public function getAncestorsAction(MediaFolder $folder)
    {
        $ancestors = $this->getMediaFolderRepository()->getAncestors($folder);

        return $this->createJsonResponse($ancestors);
    }
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;
    }
193061
public function getRoot($folderId)
    {
        $folder = FolderQuery::create()->findPk($folderId);

        if (0 !== $folder->getParent()) {
            $parentFolder = FolderQuery::create()->findPk($folder->getParent());

            if (null !== $parentFolder) {
                $folderId = $this->getRoot($parentFolder->getId());
            }
        }

        return $folderId;
    }
601277
public function createFolder($folder = null)
    {
        $folder = $this->paths->getFolder($folder);
        $this->modulable->toHistory('mkdir '.$folder);

        return $this->modulable->getConnection()->createDir($folder);
    }
1072150
public function getFolder()
    {
        if (is_null($this->_folder)) {
            $this->_folder = new Folder(
                array(
                    'name' => $this->details->getPath()
                )
            );
        }
        return $this->_folder;
    }
208074
public function getFolder($folderId)
    {
        $em = $this->getEntityManager();

        $folder = $em->getRepository('VictoireMediaBundle:Folder')->find($folderId);
        if (!$folder) {
            throw new EntityNotFoundException('The id given for the folder is not valid.');
        }

        return $folder;
    }
1205915
public function getMediaFolderByLevels($levels)
    {
        $qb = $this->createQueryBuilder('mf')
                   ->andWhere('mf._level IN (:levels)')
                   ->setParameter('levels', $levels)
                   ->orderBy('mf._leftnode', 'asc');

        return $qb->getQuery()->getResult();
    }
345686
public function getOldAncestors()
    {
        // No need to access DB to get ancestors as they are given by the materialized path.
        $parts = preg_split('/-(\d+)'.ResourceNode::PATH_OLDSEPARATOR.'/', $this->path, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
        $ancestors = [];
        $countAncestors = count($parts);
        for ($i = 0; $i < $countAncestors; $i += 2) {
            if (array_key_exists($i + 1, $parts)) {
                $ancestors[] = [
                    'id' => (int) $parts[$i + 1],
                    'name' => $parts[$i],
                ];
            }
        }

        return $ancestors;
    }
1006986
public function getFolderParent()
    {
        if ($this->isRootFolder()) {
            return null;
        }

        $parents = $this->getParents($this->getSession()->getDefaultContext());

        // return the first element of the array
        $parent = reset($parents);

        if (!$parent instanceof FolderInterface) {
            return null;
        }

        return $parent;
    }
519715
public function getNodeAncestors($maxLevel = 3)
    {
        $ancestors = [];
        $level = 0;

        $node = $this->parentNode;

        while ($node && !($node instanceof DOMDocument)) {
            $ancestors[] = $node;
            $level++;
            if ($level === $maxLevel) {
                break;
            }
            $node = $node->parentNode;
        }

        return $ancestors;
    }
1240580
public function getFolders()
    {
        if(!$this->isPropertyAvailable("Folders")){
            $this->setProperty("Folders",
                new FolderCollection($this->getContext(), new ResourcePathEntity($this->getContext(),$this->getResourcePath(), "folders")));
        }
        return $this->getProperty("Folders");
    }
643212
public function get_ancestors() {
        global $DB;
        $ancestors = array();
        $ancestorsids = explode('/', trim($this->get('path'), '/'));
        // Drop the root item from the array /0/.
        array_shift($ancestorsids);
        if (!empty($ancestorsids)) {
            list($insql, $params) = $DB->get_in_or_equal($ancestorsids, SQL_PARAMS_NAMED);
            $ancestors = self::get_records_select("id $insql", $params);
        }
        return $ancestors;
    }
743897
public function getFolders( $folder = "*" )
	{
		$list		= array();
		$address	= $this->connection->getAddress();
		$folders	= imap_getmailboxes( $this->connection->getStream(), $address, "*" );
		foreach( $folders as $folder )
			$list[]	= str_replace( $address, "", imap_utf7_decode( $folder->name ) );
		return $list;
	}
234398
public function save(Folder $folder)
    {
        $em = $this->getEntityManager();
        $parent = $folder->getParent();

        $em->beginTransaction();

        try {
            if (!is_null($parent)) {
                $this->persistInOrderedTree($folder, $parent);
            } else {
                $em->persist($folder);
            }
            $em->commit();
            $em->flush();
        } catch (\Exception $e) {
            $em->rollback();

            throw $e;
        }
    }
25407
public function folder_data($folder)
    {
        if (!strlen($folder)) {
            $folder = $this->folder !== null ? $this->folder : 'INBOX';
        }

        if ($this->conn->selected != $folder) {
            if (!$this->check_connection()) {
                return array();
            }

            if ($this->conn->select($folder)) {
                $this->folder = $folder;
            }
            else {
                return null;
            }
        }

        $data = $this->conn->data;

        // add (E)SEARCH result for ALL UNDELETED query
        if (!empty($this->icache['undeleted_idx'])
            && $this->icache['undeleted_idx']->get_parameters('MAILBOX') == $folder
        ) {
            $data['UNDELETED'] = $this->icache['undeleted_idx'];
        }

        return $data;
    }
835783
public function folder_namespace($folder)
    {
        if ($folder == 'INBOX') {
            return 'personal';
        }

        foreach ($this->namespace as $type => $namespace) {
            if (is_array($namespace)) {
                foreach ($namespace as $ns) {
                    if ($len = strlen($ns[0])) {
                        if (($len > 1 && $folder == substr($ns[0], 0, -1))
                            || strpos($folder, $ns[0]) === 0
                        ) {
                            return $type;
                        }
                    }
                }
            }
        }

        return 'personal';
    }
788530
public function getFolder($folder = ''){
        $conn = substr($this->server,0,strpos($this->server, '}') + 1).$folder;
        return $conn;
    }