GithubHelp home page GithubHelp logo

default_suffix about mezzio HOT 3 CLOSED

mezzio avatar mezzio commented on June 15, 2024
default_suffix

from mezzio.

Comments (3)

arueckauer avatar arueckauer commented on June 15, 2024 1

Is this feature completed with zendframework/zend-expressive-zendviewrenderer#64 and zendframework/zend-expressive-zendviewrenderer#67?

from mezzio.

weierophinney avatar weierophinney commented on June 15, 2024

There currently isn't a way.

You can make it happen, though. To do so, you will need to create a delegator factory that uses reflection to fetch the NamespacedPathStackResolver attached to the renderer, and then set the suffix on that.

As an example:

use Psr\Container\ContainerInterface;
use ReflectionProperty;
use Zend\Expressive\ZendView\NamespacedPathStackResolver;
use Zend\Expressive\ZendView\ZendViewRenderer;

class TemplatePathSuffixDelegator
{
    public function __invoke(ContainerInterface $container, string $name, callable $callback) : ZendViewRenderer
    {
        $renderer = $callback();
        $r = new ReflectionProperty($renderer, 'resolver');
        $r->setAccessible(true);
        $resolver = $r->getValue($renderer);
        $resolver->setDefaultSuffix('php');
        return $renderer;
    }
}

You would then register this via your dependency configuration:

// In config/autoload/dependencies.global.php:
use Zend\Expressive\ZendView\ZendViewRenderer;

return [
    'dependencies' => [
        'delegators' => [
            ZendViewRenderer::class => [ TemplatePathSuffixDelegator::class ],
        ],
    ],
];

In the meantime, I'm marking this as a feature request, as this is a configuration option we should support.


Originally posted by @weierophinney at zendframework/zend-expressive#641 (comment)

from mezzio.

weierophinney avatar weierophinney commented on June 15, 2024

It working!
Thank you very much!
I believe, that in future will be more easily way


Originally posted by @Auramel at zendframework/zend-expressive#641 (comment)

from mezzio.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.