-
-
Notifications
You must be signed in to change notification settings - Fork 312
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TwigComponent] Fix Live embedded component with namespace
- Loading branch information
Showing
3 changed files
with
28 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\UX\TwigComponent\Twig; | ||
|
||
final class TemplateNameParser | ||
{ | ||
/** | ||
* Copied from Twig\Loader\FilesystemLoader, and adjusted to needs for this class (no namespace returned). | ||
* | ||
* @see \Twig\Loader\FilesystemLoader::parseName | ||
*/ | ||
public static function parse(string $name): mixed | ||
{ | ||
if (isset($name[0]) && '@' == $name[0]) { | ||
if (false === $pos = strpos($name, '/')) { | ||
throw new \LogicException(sprintf('Malformed namespaced template name "%s" (expecting "@namespace/template_name").', $name)); | ||
} | ||
|
||
return substr($name, $pos + 1); | ||
} | ||
|
||
return $name; | ||
} | ||
} |