Skip to content

Commit

Permalink
make compatible for typo3 12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mcrasser committed Jan 18, 2024
1 parent 61b7e18 commit 591c9b0
Show file tree
Hide file tree
Showing 17 changed files with 65 additions and 42 deletions.
3 changes: 2 additions & 1 deletion Classes/Twig/EnvironmentTwig.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
***************************************************************/

use DMK\T3twig\Twig\RendererTwig as Renderer;
use Twig\Environment;

/**
* Class EnvironmentTwig.
Expand All @@ -38,7 +39,7 @@
*
* @see https://www.dmk-ebusiness.de/
*/
class EnvironmentTwig extends \Twig_Environment
class EnvironmentTwig extends Environment
{
/**
* @var Renderer
Expand Down
2 changes: 1 addition & 1 deletion Classes/Twig/Extension/AbstractExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
*
* @see https://www.dmk-ebusiness.de/
*/
class AbstractExtension extends \Twig_Extension
class AbstractExtension extends \Twig\Extension\AbstractExtension
{
/**
* Initiate the arguments,
Expand Down
5 changes: 3 additions & 2 deletions Classes/Twig/Extension/DBRelationExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
* *************************************************************
*/
use DMK\T3twig\Twig\EnvironmentTwig;
use Twig\TwigFunction;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -39,15 +40,15 @@
*
* @see https://www.dmk-ebusiness.de/
*/
class DBRelationExtension extends \Twig_Extension
class DBRelationExtension extends \Twig\Extension\AbstractExtension
{
/**
* @return array
*/
public function getFunctions()
{
return [
new \Twig_SimpleFunction('t3dbrel', [
new TwigFunction('t3dbrel', [
$this,
'lookupRelation',
], [
Expand Down
3 changes: 2 additions & 1 deletion Classes/Twig/Extension/DateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
***************************************************************/

use DMK\T3twig\Twig\EnvironmentTwig;
use Twig\TwigFilter;
use TYPO3\CMS\Core\Core\Environment;

/**
Expand All @@ -46,7 +47,7 @@ class DateExtension extends AbstractExtension
public function getFilters()
{
return [
new \Twig_SimpleFilter(
new TwigFilter(
't3strftime',
[$this, 'renderStrfTime'],
['needs_environment' => true, 'is_safe' => ['html']]
Expand Down
5 changes: 3 additions & 2 deletions Classes/Twig/Extension/ImageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
***************************************************************/

use DMK\T3twig\Twig\EnvironmentTwig;
use Twig\TwigFunction;

/**
* Class ImageExtension.
Expand Down Expand Up @@ -56,11 +57,11 @@ public function getFilters()
public function getFunctions()
{
return [
new \Twig_SimpleFunction(
new TwigFunction(
't3fetchReferences',
[$this, 'fetchReferences']
),
new \Twig_SimpleFunction(
new TwigFunction(
't3image',
[$this, 'renderImage'],
['needs_environment' => true, 'is_safe' => ['html']]
Expand Down
5 changes: 3 additions & 2 deletions Classes/Twig/Extension/LanguageExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
***************************************************************/

use DMK\T3twig\Twig\EnvironmentTwig;
use Twig\TwigFilter;

/**
* Class LanguageExtension.
Expand All @@ -38,15 +39,15 @@
*
* @see https://www.dmk-ebusiness.de/
*/
class LanguageExtension extends \Twig_Extension
class LanguageExtension extends \Twig\Extension\AbstractExtension
{
/**
* @return array
*/
public function getFilters()
{
return [
new \Twig_SimpleFilter('t3trans', [$this, 'getTranslation'], ['needs_environment' => true]),
new TwigFilter('t3trans', [$this, 'getTranslation'], ['needs_environment' => true]),
];
}

Expand Down
6 changes: 4 additions & 2 deletions Classes/Twig/Extension/LinkExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
***************************************************************/

use DMK\T3twig\Twig\EnvironmentTwig;
use Twig\TwigFilter;
use Twig\TwigFunction;
use TYPO3\CMS\Core\Utility\GeneralUtility;

/**
Expand All @@ -47,7 +49,7 @@ class LinkExtension extends AbstractExtension
public function getFilters()
{
return [
new \Twig_SimpleFilter(
new TwigFilter(
't3link',
[$this, 'renderLink'],
['needs_environment' => true, 'is_safe' => ['html']]
Expand All @@ -58,7 +60,7 @@ public function getFilters()
public function getFunctions()
{
return [
new \Twig_SimpleFunction(
new TwigFunction(
't3url',
[$this, 'renderUrl'],
['needs_environment' => true]
Expand Down
3 changes: 2 additions & 1 deletion Classes/Twig/Extension/RequestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
***************************************************************/

use DMK\T3twig\Twig\EnvironmentTwig;
use Twig\TwigFunction;

/**
* Class TSParserExtension.
Expand All @@ -45,7 +46,7 @@ class RequestExtension extends AbstractExtension
public function getFunctions()
{
return [
new \Twig_SimpleFunction(
new TwigFunction(
't3gp',
[$this, 'renderGetPost'],
['needs_environment' => true]
Expand Down
14 changes: 8 additions & 6 deletions Classes/Twig/Extension/TSParserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
***************************************************************/

use DMK\T3twig\Twig\EnvironmentTwig;
use Twig\TwigFilter;
use Twig\TwigFunction;

/**
* Class TSParserExtension.
Expand All @@ -48,12 +50,12 @@ class TSParserExtension extends AbstractExtension
public function getFilters()
{
return [
new \Twig_SimpleFilter(
new TwigFilter(
't3ts',
[$this, 'applyTs'],
['needs_environment' => true, 'is_safe' => ['html']]
),
new \Twig_SimpleFilter(
new TwigFilter(
't3rte',
[$this, 'applyRte'],
['needs_environment' => true, 'is_safe' => ['html']]
Expand All @@ -69,22 +71,22 @@ public function getFilters()
public function getFunctions()
{
return [
new \Twig_SimpleFunction(
new TwigFunction(
't3cObject',
[$this, 'renderContentObject'],
['needs_environment' => true, 'is_safe' => ['html']]
),
new \Twig_SimpleFunction(
new TwigFunction(
't3stdWrap',
[$this, 'renderStdWrap'],
['needs_environment' => true, 'is_safe' => ['html']]
),
new \Twig_SimpleFunction(
new TwigFunction(
't3tsRaw',
[$this, 'renderTsRaw'],
['needs_environment' => true, 'is_safe' => ['html']]
),
new \Twig_SimpleFunction(
new TwigFunction(
't3parseFunc',
[$this, 'renderParseFunc'],
['needs_environment' => true, 'is_safe' => ['html']]
Expand Down
5 changes: 3 additions & 2 deletions Classes/Twig/Extension/TsFeExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DMK\T3twig\Twig\Extension;

use Twig\Extension\GlobalsInterface;
use Twig\TwigFunction;

/***************************************************************
* Copyright notice
Expand Down Expand Up @@ -37,15 +38,15 @@
*
* @see https://www.dmk-ebusiness.de/
*/
class TsFeExtension extends \Twig_Extension implements GlobalsInterface
class TsFeExtension extends \Twig\Extension\AbstractExtension implements GlobalsInterface
{
/**
* @return array
*/
public function getFunctions()
{
return [
new \Twig_SimpleFunction(
new TwigFunction(
'tsfePagetitle',
[$this, 'setPageTitleTag'],
['is_safe' => ['html']]
Expand Down
3 changes: 2 additions & 1 deletion Classes/Twig/Loader/T3FileSystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace DMK\T3twig\Twig\Loader;

use Twig\Loader\FilesystemLoader;
use TYPO3\CMS\Core\Core\Environment;

/***************************************************************
Expand Down Expand Up @@ -37,7 +38,7 @@
*
* @see https://www.dmk-ebusiness.de/
*/
class T3FileSystem extends \Twig_Loader_Filesystem
class T3FileSystem extends FilesystemLoader
{
private static $sysExtKeys = [
'core',
Expand Down
6 changes: 3 additions & 3 deletions Classes/Twig/RendererTwig.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public function getConfId()
/**
* The template path to search in for macros, includes, tc.
*
* @return string
* @return array
*/
protected function getTemplatePaths()
{
Expand All @@ -149,12 +149,12 @@ protected function getTemplatePaths()
/**
* The extensions to use in twig templates.
*
* @return string
* @return array
*/
protected function getExtensions()
{
// initial use the global paths
$paths = $this->conf['extensions.'] ?: [];
$paths = isset($this->conf['extensions.']) ? $this->conf['extensions.'] : [];

// add the paths for the current render context
$paths = \Sys25\RnBase\Utility\Arrays::mergeRecursiveWithOverrule(
Expand Down
26 changes: 17 additions & 9 deletions Classes/Twig/UtilityTwig.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,10 @@

use DMK\T3twig\Cache\TYPO3Cache;
use DMK\T3twig\Twig\Loader\T3FileSystem;
use Twig\Extension\ExtensionInterface;
use Twig\Loader\FilesystemLoader;
use TYPO3\CMS\Core\Exception;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Object\ObjectManager;

/**
* Class TwigUtil.
Expand All @@ -44,12 +45,19 @@
*/
class UtilityTwig
{
private static $cache;

public function __construct(TYPO3Cache $cache)
{
self::$cache = $cache;
}

/**
* Returns an instance of twig loader filesystem.
*
* @param string $templateDir template directory
*
* @return \Twig_Loader_Filesystem
* @return FilesystemLoader
*/
public static function getTwigLoaderFilesystem($templateDir)
{
Expand All @@ -59,17 +67,17 @@ public static function getTwigLoaderFilesystem($templateDir)
/**
* Returns an instance of twig environment.
*
* @param \Twig_Loader_Filesystem $twigLoaderFilesystem twig loader filesystem
* @param FilesystemLoader $twigLoaderFilesystem twig loader filesystem
* @param bool $debug enable debug
*
* @return EnvironmentTwig
*/
public static function getTwigEnvironment(
\Twig_Loader_Filesystem $twigLoaderFilesystem,
FilesystemLoader $twigLoaderFilesystem,
$debug = true
) {
$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
$cache = $objectManager->get(TYPO3Cache::class);
// $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
// $cache = self::$cache;

/**
* Some ToDos.
Expand All @@ -80,7 +88,7 @@ public static function getTwigEnvironment(
$twigLoaderFilesystem,
[
'debug' => $debug,
'cache' => $cache,
'cache' => self::$cache,
]
);

Expand All @@ -96,7 +104,7 @@ public static function getTwigEnvironment(
* @throws \Twig_Error_Loader
*/
public static function injectTemplatePaths(
\Twig_Loader_Filesystem $twigLoaderFilesystem,
FilesystemLoader $twigLoaderFilesystem,
array $paths
) {
foreach ($paths as $namespace => $path) {
Expand Down Expand Up @@ -128,7 +136,7 @@ public static function injectExtensions(
/*
* Is it a valid twig extension?
*/
if (!$extInstance instanceof \Twig_ExtensionInterface) {
if (!$extInstance instanceof ExtensionInterface) {
throw new Exception(sprintf('Twig extension must be an instance of Twig_ExtensionInterface; "%s" given.', is_object($extInstance) ? get_class($extInstance) : gettype($extInstance)));
}

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
}
],
"require": {
"typo3/cms-core": "^9.5.24 || ^10.4.14",
"digedag/rn-base": "~1.15",
"typo3/cms-core": "^11.5 || ^12.4",
"digedag/rn-base": "~1.18",
"twig/twig": "~1.0"
},
"require-dev": {
Expand Down
6 changes: 3 additions & 3 deletions ext_emconf.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
'title' => 'T3twig',
'description' => 'TYPO3 extension to render page templates with Twig and extend rn_base for using Twig templates instead of marker',
'shy' => 0,
'version' => '10.1.0',
'version' => '12.0.0',
'dependencies' => 'cms',
'conflicts' => '',
'priority' => '',
Expand All @@ -33,8 +33,8 @@
'CGLcompliance_note' => '',
'constraints' => [
'depends' => [
'rn_base' => '1.15.0-',
'typo3' => '9.5.24-10.4.99',
'rn_base' => '1.18.0-',
'typo3' => '11.5.00-12.4.99',
],
'conflicts' => [],
'suggests' => [],
Expand Down
Loading

0 comments on commit 591c9b0

Please sign in to comment.