-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FRW-9287 Added new twig var dumper plugin. (#11241)
FRW-9287 Added new twig var dumper plugin.
- Loading branch information
1 parent
ce248b3
commit 3ad0338
Showing
3 changed files
with
49 additions
and
1 deletion.
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,44 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © 2016-present Spryker Systems GmbH. All rights reserved. | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace Spryker\Shared\Twig\Plugin; | ||
|
||
use Spryker\Service\Container\ContainerInterface; | ||
use Spryker\Shared\TwigExtension\Dependency\Plugin\TwigPluginInterface; | ||
use Symfony\Bridge\Twig\Extension\DumpExtension; | ||
use Symfony\Component\VarDumper\Cloner\VarCloner; | ||
use Twig\Environment; | ||
|
||
class VarDumperTwigPlugin implements TwigPluginInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected const SERVICE_DEBUG = 'debug'; | ||
|
||
/** | ||
* {@inheritDoc} | ||
* - Added pretty print for debug extension. | ||
* | ||
* @api | ||
* | ||
* @param \Twig\Environment $twig | ||
* @param \Spryker\Service\Container\ContainerInterface $container | ||
* | ||
* @return \Twig\Environment | ||
*/ | ||
public function extend(Environment $twig, ContainerInterface $container): Environment | ||
{ | ||
if ($container->has(static::SERVICE_DEBUG) === false || $container->get(static::SERVICE_DEBUG) === false) { | ||
return $twig; | ||
} | ||
|
||
$twig->addExtension(new DumpExtension(new VarCloner())); | ||
|
||
return $twig; | ||
} | ||
} |