[ Index ] |
PHP Cross Reference of phpBB-3.2.11-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 array( 32 new TwigFilter('yaml_encode', array($this, 'encode')), 33 new TwigFilter('yaml_dump', array($this, 'dump')), 34 ); 35 } 36 37 public function encode($input, $inline = 0, $dumpObjects = false) 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 return $dumper->dump($input, $inline, 0, \is_bool($dumpObjects) ? Yaml::DUMP_OBJECT : 0); 47 } 48 49 return $dumper->dump($input, $inline, 0, false, $dumpObjects); 50 } 51 52 public function dump($value, $inline = 0, $dumpObjects = false) 53 { 54 if (\is_resource($value)) { 55 return '%Resource%'; 56 } 57 58 if (\is_array($value) || \is_object($value)) { 59 return '%'.\gettype($value).'% '.$this->encode($value, $inline, $dumpObjects); 60 } 61 62 return $this->encode($value, $inline, $dumpObjects); 63 } 64 65 /** 66 * {@inheritdoc} 67 */ 68 public function getName() 69 { 70 return 'yaml'; 71 } 72 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |