2017 © Pedro Peláez
 

library twig

image

xervice/twig

  • Wednesday, August 1, 2018
  • by mibexx
  • Repository
  • 1 Watchers
  • 0 Stars
  • 79 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Scrutinizer Code Quality Code Coverage, (*1)

Twig template engine implementation for xervice., (*2)

Installation

composer require xervice/twig

Configuration

To define twig paths, where to search for templates, you can share a PathProvider:, (*3)

<?php

namespace App\Application\Communication\Plugin\Twig;

use Xervice\Twig\Business\Model\Loader\XerviceLoaderInterface;
use Xervice\Twig\Business\Dependency\Path\PathProviderInterface;

class PathLoader implements PathProviderInterface
{
    /**
     * @param \Xervice\Twig\Business\Loader\XerviceLoaderInterface $loader
     *
     * @throws \Twig_Error_Loader
     */
    public function privideTwigPaths(XerviceLoaderInterface $loader): void
    {
        $loader->addPath('path/to/my/twig-templates', 'Application');
    }
}

You can register your PathLoader in the TwigDependencyProvider:, (*4)

<?php

namespace App\Twig;

use App\Application\Communication\Plugin\Twig\PathLoader;
use Xervice\Twig\TwigDependencyProvider as XerviceTwigDependencyProvider;

class TwigDependencyProvider extends XerviceTwigDependencyProvider
{
    /**
     * @return \Xervice\Twig\Business\Dependency\Path\PathProviderInterface[]
     */
    protected function getPathProviderList(): array
    {
        return [
            new PathLoader()
        ];
    }
}

Usage

You can render templates by using the TwigFacade:, (*5)

$params = [];
$twigFacade->render('mytemplate.twig', $params);

Also you can provide the TwigService to your Kernel stack and use them in your controller. The service provide the same register-method., (*6)

The Versions

01/08 2018
18/07 2018

1.0.0

1.0.0.0

  Sources   Download

MIT

The Requires

 

The Development Requires

by Mike Bertram