Sulu\Component\Util\SuluNodeHelper::extractSnippetTypeFromPath PHP Method

extractSnippetTypeFromPath() public method

Extract the snippet path from the given path.
public extractSnippetTypeFromPath ( string $path ) : string
$path string
return string
    public function extractSnippetTypeFromPath($path)
    {
        if (substr($path, 0, 1) !== '/') {
            throw new \InvalidArgumentException(sprintf('Path must be absolute, got "%s"', $path));
        }
        $snippetsPath = '/' . $this->getPath('base') . '/' . $this->getPath('snippet') . '/';
        $newPath = PathHelper::getParentPath($path);
        $newPath = substr($newPath, strlen($snippetsPath));
        if (false === $newPath) {
            throw new \InvalidArgumentException(sprintf('Cannot extract snippet template type from path "%s"', $path));
        }
        return $newPath;
    }