[ Index ] |
PHP Cross Reference of phpBB-3.3.14-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 3 /* 4 * This file is part of the Symfony package. 5 * 6 * (c) Fabien Potencier <fabien@symfony.com> 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12 namespace Symfony\Bridge\Twig\Extension; 13 14 use Symfony\Component\Yaml\Dumper as YamlDumper; 15 use Symfony\Component\Yaml\Yaml; 16 use Twig\Extension\AbstractExtension; 17 use Twig\TwigFilter; 18 19 /** 20 * Provides integration of the Yaml component with Twig. 21 * 22 * @author Fabien Potencier <fabien@symfony.com> 23 */ 24 class YamlExtension extends AbstractExtension 25 { 26 /** 27 * {@inheritdoc} 28 */ 29 public function getFilters() 30 { 31 return [ 32 new TwigFilter('yaml_encode', [$this, 'encode']), 33 new TwigFilter('yaml_dump', [$this, 'dump']), 34 ]; 35 } 36 37 public function encode($input, $inline = 0, $dumpObjects = 0) 38 { 39 static $dumper; 40 41 if (null === $dumper) { 42 $dumper = new YamlDumper(); 43 } 44 45 if (\defined('Symfony\Component\Yaml\Yaml::DUMP_OBJECT')) { 46 if (\is_bool($dumpObjects)) { 47 @trigger_error('Passing a boolean flag to toggle object support is deprecated since Symfony 3.1 and will be removed in 4.0. Use the Yaml::DUMP_OBJECT flag instead.', \E_USER_DEPRECATED); 48 49 $flags = $dumpObjects ? Yaml::DUMP_OBJECT : 0; 50 } else { 51 $flags = $dumpObjects; 52 } 53 54 return $dumper->dump($input, $inline, 0, $flags); 55 } 56 57 return $dumper->dump($input, $inline, 0, false, $dumpObjects); 58 } 59 60 public function dump($value, $inline = 0, $dumpObjects = false) 61 { 62 if (\is_resource($value)) { 63 return '%Resource%'; 64 } 65 66 if (\is_array($value) || \is_object($value)) { 67 return '%'.\gettype($value).'% '.$this->encode($value, $inline, $dumpObjects); 68 } 69 70 return $this->encode($value, $inline, $dumpObjects); 71 } 72 73 /** 74 * {@inheritdoc} 75 */ 76 public function getName() 77 { 78 return 'yaml'; 79 } 80 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Mon Nov 25 19:05:08 2024 | Cross-referenced by PHPXref 0.7.1 |