1515
1616use Sigwin \YASSG \Asset \AssetFetch ;
1717use Sigwin \YASSG \AssetQueue ;
18+ use Sigwin \YASSG \Metadata ;
1819use Symfony \Component \Asset \Packages ;
1920use Symfony \Component \HttpFoundation \RequestStack ;
2021use Twig \Extension \AbstractExtension ;
@@ -34,21 +35,22 @@ public function getFunctions(): array
3435 if (str_starts_with ($ path , './ ' )) {
3536 if (! isset ($ context ['__path ' ])) {
3637 if (isset ($ options ['self ' ])) {
37- if (! \is_object ($ options ['self ' ]) || ! property_exists ($ options ['self ' ], '__path ' )) {
38+ if (! \is_object ($ options ['self ' ]) || ! property_exists ($ options ['self ' ], '__metadata ' )
39+ || ! \is_object ($ options ['self ' ]->__metadata ) || ! $ options ['self ' ]->__metadata instanceof Metadata) {
3840 throw new \RuntimeException ('Cannot use yassg_thumbnail() with {self: object} as the second argument, pass {self: object} as the second argument ' );
3941 }
40- $ context ['__path ' ] = $ options ['self ' ]->__path ;
42+ $ context ['__path ' ] = $ options ['self ' ]->__metadata -> path ;
4143 } else {
4244 $ candidates = [];
4345 foreach ($ context as $ item ) {
44- if (\is_object ($ item ) && property_exists ($ item , '__path ' ) ) {
45- $ candidates [] = $ item ;
46+ if (\is_object ($ item ) && property_exists ($ item , '__metadata ' ) && $ item -> __metadata instanceof Metadata ) {
47+ $ candidates [] = $ item-> __metadata ;
4648 }
4749 }
4850 if (\count ($ candidates ) !== 1 ) {
4951 throw new \RuntimeException ('Cannot use yassg_thumbnail() without a single Locatable object in context, pass {self: object} as the second argument ' );
5052 }
51- $ context ['__path ' ] = $ candidates [0 ]->__path ;
53+ $ context ['__path ' ] = $ candidates [0 ]->path ;
5254 }
5355 }
5456
0 commit comments