Skip to content

Commit b528141

Browse files
authored
Merge pull request #405 from daniser/fix/extension-last-modified
Fix twig runtime extension last modification time detection
2 parents 328bb43 + 556baf0 commit b528141

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Knp/Menu/Twig/MenuExtension.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,14 @@ public function getTests(): array
5757
];
5858
}
5959

60+
public function getLastModified(): int
61+
{
62+
return max(
63+
(int) filemtime(__FILE__),
64+
(int) filemtime(__DIR__.'/MenuRuntimeExtension.php'),
65+
);
66+
}
67+
6068
/**
6169
* @param array<int, string> $path
6270
* @param array<string, mixed> $options

tests/Knp/Menu/Tests/Twig/MenuExtensionTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,14 @@ public function testGetCurrentItem(): void
163163
$this->assertEquals('current', $this->getTemplate('{{ knp_menu_get_current_item("default") is knp_menu_current ? "current" : "not current" }}', $helper, $matcher)->render([]));
164164
}
165165

166+
public function testLastModified(): void
167+
{
168+
$this->assertSame(max(
169+
filemtime((new \ReflectionClass(MenuExtension::class))->getFileName()),
170+
filemtime((new \ReflectionClass(MenuRuntimeExtension::class))->getFileName()),
171+
), (new MenuExtension())->getLastModified());
172+
}
173+
166174
/**
167175
* @param array<string> $methods
168176
*/

0 commit comments

Comments
 (0)