mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-12 10:26:32 +00:00
5dd37d8a5a057f80ce5e7adcd220984ae94e6395
getLastModified() to extensions (GromNaN)
This PR was merged into the 3.x branch.
Discussion
----------
Add `getLastModified()` to extensions
Give to extensions the ability to set a last modification date for cache invalidation.
### Runtime
Currently, the cache is not invalidated when the signature of a runtime method is modified. This is an issue for templates that use named arguments, as argument names have an impact on the generated class.
With this change, extensions using runtime classes can compute a modification date by including the files on which they depend.
By default, the `AbstractExtension` checks if there is a file for the runtime class with the same name of the
This is the convention applied in [Symfony](https://github.com/symfony/symfony/tree/7.3/src/Symfony/Bridge/Twig/Extension) and Twig Extra: `MarkdownExtension` has `MarkdownRuntime`.
### Attribute
Contributing to https://github.com/twigphp/Twig/pull/3916.
The extension class that will get the configuration from attributes will be able to track the classes having attributes to find the last modification date of all this classes.
### ~BC break~
~In Twig 4.0, the method `getLastModified` will be added to `ExtensionInterface`. It is extremely rare to implement this interface without extending `AbstractExtension`. So adding this method to the interface shouldn't be a problem as the base class has an implementation.~
Commits
-------
d8fe3bd1ec Add `LastModifiedExtensionInterface` and implementation in `AbstractExtension` to track modification of runtime classes
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP.
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://docs.blackfire.io/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
<img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
</a>
More Information
----------------
Read the `documentation`_ for more information.
.. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%