Skip to content

Commit

Permalink
feat!: release 2.0
Browse files Browse the repository at this point in the history
- replace hellonico/twig-dump-extension with  symfony/twig-bridge
- use wecodemore/wordpress-early-hook to ensure hook is added event if autoloaded early
  • Loading branch information
nlemoine committed Mar 8, 2024
1 parent 4e5c22b commit f3fd31e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,3 @@ composer require hellonico/timber-dump-extension
```

Note that this extension will only be enabled if `WP_DEBUG` is set to `true`.

## Extra

You may be interested in https://github.com/nlemoine/var-dumper-configurator which provide a simple to configure dumper options.
17 changes: 10 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,28 @@
{
"name": "hellonico/timber-dump-extension",
"description": "Provides Symfony VarDumper component for Timber",
"type": "library",
"homepage": "https://github.com/nlemoine/timber-dump-extension",
"keywords": ["timber", "twig", "symfony", "vardumper", "wordpress"],
"license": "GPL-3.0+",
"type": "library",
"authors": [
{
"name": "Nicolas Lemoine",
"email": "[email protected]",
"homepage": "https://github.com/nlemoine"
"email": "[email protected]",
"homepage": "https://n5s.dev/"
}
],
"homepage": "https://github.com/nlemoine/timber-dump-extension",
"require": {
"symfony/twig-bridge": "^6 || ^7",
"symfony/var-dumper": "^6 || ^7",
"wecodemore/wordpress-early-hook": "^1.2"
},
"autoload": {
"psr-4": {
"HelloNico\\Timber\\": "src/"
},
"files": [
"functions.php"
]
},
"require": {
"hellonico/twig-dump-extension": "^1.0"
}
}
14 changes: 8 additions & 6 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,16 @@

namespace HelloNico\Timber;

use HelloNico\Twig\DumpExtension;
use Symfony\Bridge\Twig\Extension\DumpExtension;
use Symfony\Component\VarDumper\Cloner\VarCloner;

use function WeCodeMore\earlyAddFilter;

function add_dump_extension($twig)
{
$twig->addExtension(new DumpExtension());
if (defined('WP_DEBUG') && WP_DEBUG) {
$twig->addExtension(new DumpExtension(new VarCloner()));
}
return $twig;
}

if (defined('WP_DEBUG') && WP_DEBUG && function_exists('add_filter')) {
add_filter('timber/loader/twig', sprintf('%s\\add_dump_extension', __NAMESPACE__));
}
earlyAddFilter('timber/loader/twig', sprintf('%s\\add_dump_extension', __NAMESPACE__));

0 comments on commit f3fd31e

Please sign in to comment.