コード例 #1
0
 /**
  * @param ContainerInterface $container
  * @return Plates
  */
 public function __invoke(ContainerInterface $container)
 {
     $config = $container->has('config') ? $container->get('config') : [];
     $config = isset($config['templates']) ? $config['templates'] : [];
     // Create the engine instance:
     $engine = new PlatesEngine();
     // Set file extension
     if (isset($config['extension'])) {
         $engine->setFileExtension($config['extension']);
     }
     // Inject engine
     $plates = new Plates($engine);
     // Add template paths
     $allPaths = isset($config['paths']) && is_array($config['paths']) ? $config['paths'] : [];
     foreach ($allPaths as $namespace => $paths) {
         $namespace = is_numeric($namespace) ? null : $namespace;
         foreach ((array) $paths as $path) {
             $plates->addPath($path, $namespace);
         }
     }
     return $plates;
 }
コード例 #2
0
 /**
  * @dataProvider objectParameterValues
  */
 public function testCanRenderWithParameterObjects($params, $search)
 {
     $template = new PlatesTemplate();
     $template->addPath(__DIR__ . '/TestAsset');
     $result = $template->render('plates', $params);
     $this->assertContains($search, $result);
     $content = file_get_contents(__DIR__ . '/TestAsset/plates.php');
     $content = str_replace('<?=$this->e($name)?>', $search, $content);
     $this->assertEquals($content, $result);
 }
コード例 #3
0
 /**
  * @depends testCallingFactoryWithNoConfigReturnsPlatesInstance
  */
 public function testUnconfiguredPlatesInstanceContainsNoPaths(Plates $plates)
 {
     $paths = $plates->getPaths();
     $this->assertInternalType('array', $paths);
     $this->assertEmpty($paths);
 }
コード例 #4
0
ファイル: PlatesTest.php プロジェクト: flipecristian/apiZend
 /**
  * @group namespacing
  */
 public function testProperlyResolvesNamespacedTemplate()
 {
     $template = new PlatesTemplate();
     $template->addPath(__DIR__ . '/TestAsset/test', 'test');
     $expected = file_get_contents(__DIR__ . '/TestAsset/test/test.php');
     $test = $template->render('test::test');
     $this->assertSame($expected, $test);
 }