Resolve a category by path.

@param array $path category names indexed from parent to children.
@return int category ID.
328835
public static function resolve_category_by_path(array $path) {
        global $DB;
        $cache = cache::make('tool_uploadcourse', 'helper');
        $cachekey = 'cat_path_' . serialize($path);
        if (($id = $cache->get($cachekey)) === false) {
            $parent = 0;
            $sql = 'name = :name AND parent = :parent';
            while ($name = array_shift($path)) {
                $params = array('name' => $name, 'parent' => $parent);
                if ($records = $DB->get_records_select('course_categories', $sql, $params, null, 'id, parent')) {
                    if (count($records) > 1) {
                        // Too many records with the same name!
                        $id = -1;
                        break;
                    }
                    $record = reset($records);
                    $id = $record->id;
                    $parent = $record->id;
                } else {
                    // Not found.
                    $id = -1;
                    break;
                }
            }
            $cache->set($cachekey, $id);
        }

        // We save -1 when the category has not been found to be able to know if the cache was set.
        if ($id == -1) {
            $id = false;
        }
        return $id;
    }
1221649
public function getPath($path)
    {
        if (! is_array($path)) {
            $path = [$path];
        }

        $search_for = [
            '%BASE',
            '%STORAGE',
        ];

        $replace_by = [
            base_path(),
            storage_path(),
        ];

        if (function_exists('app_path')) {
            $search_for[] = '%APP';
            $replace_by[] = app_path();
        }

        if (function_exists('public_path')) {
            $search_for[] = '%PUBLIC';
            $replace_by[] = public_path();
        }

        $folders = str_replace($search_for, $replace_by, $path);

        foreach ($folders as $k => $v) {
            $folders[$k] = realpath($v);
        }

        return $folders;
    }
462426
private static function processReindexPath($path)
    {
        if (is_string($path) || is_integer($path)) {
            // Single level path - one element only
            $path = array(array($path));
        } elseif (is_array($path) && !empty($path) && !is_array($path[0])) {
            // Single level path - multiple elements
            // Check each path element is either a string or an integer
            foreach ($path as $key) {
                if (!(is_string($key) || is_integer($key))) {
                    throw new InvalidArgumentException('Invalid reindex path.');
                }
            }

            $path = array($path);
        } elseif (is_array($path) && !empty($path) && is_array($path[0])) {
            // Multilevel path
            // Check each path element is an array (a sub-path)
            foreach ($path as $subpath) {
                if (!is_array($subpath) || empty($subpath)) {
                    throw new InvalidArgumentException('Invalid reindex path.');
                }

                // Check each sub-path element is a valid array key (either a string or an integer)
                foreach ($subpath as $key) {
                    if (!(is_string($key) || is_integer($key))) {
                        throw new InvalidArgumentException('Invalid reindex path.');
                    }
                }
            }
        } else {
            throw new InvalidArgumentException('Invalid reindex path.');
        }

        return $path;
    }
1073233
private function resolveRemotePath($path)
    {
        if (!isset($this->resolvedRemotePath[$path])) {
            $resolvedPath = $this->volatileFolder->getNewPath();
            if ($this->remoteFilesystem->copy($path, $path, $resolvedPath) !== true) {
                throw new Exception\PathNotFound($path);
            }
            $this->resolvedRemotePath[$path] = $resolvedPath;
        }

        return $this->resolvedRemotePath[$path];
    }
1009458
public function browseAction($path)
    {
        $currentProfile = $this->getCurrentProfile();

        $repository = $this->getDoctrine()->getRepository('HarvestCloudCoreBundle:Category');

        $category = $repository->findOneByPath($path);

        if (!$category)
        {
            throw $this->createNotFoundException('No category found for path '.$path);
        }

        // Set up and empty filter
        $filter = new ProductFilter();
        $filter->setLatitude($currentProfile->getDefaultLocation()->getLatitude());
        $filter->setLongitude($currentProfile->getDefaultLocation()->getLongitude());
        $filter->setRange(100);
        $filter->category = $category;

        $products = $this->getRepo('Product')
            ->findForSearchFilter($filter, $this->getCurrentCart())
        ;

        return $this->render('HarvestCloudMarketPlaceBuyerBundle:Default:index.html.twig', array(
          'products' => $products,
        ));
    }
1041455
public function resolve($path)
    {
        $path = str_replace('/', '.', preg_replace('/\/:\w+/', '', $path));

        $finder = $this->container['view.finder'];

        try {
            $finder->find($path);
        } catch (InvalidArgumentException $e) {
            $explodedPath = explode('.', $path);


            if ($explodedPath[0] === 'static') {
                return null;
            }

            if (count($explodedPath) > 1) {
                $explodedPath[0] = 'shared';
                $explodedPath = array('shared', end($explodedPath));
                try {
                    $finder->find(implode('.', $explodedPath));
                    $path = implode('.', $explodedPath);
                } catch (InvalidArgumentException $e) {
                    $this->app->error($e);
                }
            }
        }

        return $path;
    }
1060343
protected function get_folders( $path ) {
		if ( isset( $this->subfolders[ $path ] ) ) {
			return $this->subfolders[ $path ];
		}

		$this->subfolders[ $path ] = $this->search_folders( $path );
		return $this->subfolders[ $path ];
	}
808760
public function _pathAsArray($path)
    {
        $result = explode(self::PS, $path);
        // unset empty nodes
        foreach ($result as $key => $item) {
            if (!$item && $item !== "0") {
                unset($result[$key]);
            }
        }
        // re-index array
        $result = array_values($result);
        return $result;
    }
240604
public static function resolve($path)
    {
        if (empty($path)) {
            return false;
        }

        $path = Uri::canonpath($path);

        if ($path . '/' === self::path() || strpos($path, self::path()) === 0) {
            return $path;
        }

        return self::path() . $path;
    }
820961
public static function parsePath($path){
		//strip prefix
		$path = str_replace(self::getPrefix(),'',$path);
		//break off the query string if we can
		if(strpos($path,'?') !== false){
			$query = substr($path,strpos($path,'?'));
			$path = substr($path,0,(strlen($path)-strlen($query)));
			//remove the questionmark
			$query = str_replace('?','',$query);
		}
		//setup opts
		$opts['path'] = $path;
		$opts['params'] = array();
		if(isset($query)) parse_str($query,$opts['params']);
		return $opts;
	}
58031
protected function getPath($path)
	{
		$paths = array();

		// If `$path` is an array
		if (is_array($path))
		{
			foreach ($path as $unverifiedPath)
			{
				$paths = array_merge($paths, $this->getPath($unverifiedPath));
			}

			return $paths;
		}

		// If `$path` is a directory
		if (is_dir($path))
		{
			$paths = glob($path . '/*.*');

			return $paths;
		}

		// If `$path` is a file
		if (file_exists($path))
		{
			$paths[] = $path;
		}

		return $paths;
	}
653275
public function resolveProfilePath($path, $profile)
    {
        $path = $this->resolvePath($path);
        return preg_replace_callback('|\[\[([\w\_/]+)\]\]|', function ($matches) use ($profile) {
            $name = $matches[1];
            switch ($name) {
                case 'profile':
                    return $profile;
            }
            return '[[' . $name . ']]';
        }, $path);
    }
1097357
private function resolveStylesheetUrl($path){
        $websource = WebsourceManager::singleton()->getWebsource($this->get(ThemeRegistry::WEBSOURCE));
        if(strpos($path , ThemeRegistry::WEBSOURCE) === 0) {
                return $websource->getAccessUrl(substr($path, strlen(ThemeRegistry::WEBSOURCE)));
        }
        else {
            $assetService = $this->getServiceManager()->get(AssetService::SERVICE_ID);
            return $assetService->getAsset($path);
        }
    }
481380
private function resolvePath($path)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException(
                'Path needs to be a string'
            );
        }

        $basePath = $this->basePath();
        $path = trim($path, '/\\');

        if ($basePath && strpos($path, $basePath) === false) {
            $path = $basePath.$path;
        }

        return $path;
    }
697129
public static function getParentPath($path)
    {
        if ($path === '/') {
            $parentPath = '';
        } elseif (strrpos($path, '/') === 0) {
            $parentPath = '/';
        } else {
            $parentPath = substr($path, 0, strrpos($path, '/'));
        }

        return $parentPath;
    }
413383
public function resolve(
        AbsolutePathInterface $basePath,
        PathInterface $path
    ) {
        if ($path instanceof AbsolutePathInterface) {
            return $path;
        }
        if ($path instanceof RelativeWindowsPathInterface) {
            if ($path->isAnchored()) {
                return $path->joinDrive($basePath->drive());
            }
            if ($path->hasDrive() && !$path->matchesDrive($basePath->drive())) {
                return $path->toAbsolute();
            }
        }

        return $basePath->join($path);
    }
1263065
protected function resolvePath($path)
    {
        $parts = explode('.', $path);
        $settings = $this->settings;
        foreach ($parts as $part) {
            if (!isset($settings[$part])) {
                return null;
            }
        
            $settings = $settings[$part];
        }
        
        return $settings;
    }