File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -285,7 +285,7 @@ public function __toString(): string
285285 $ html .= "<meta property= \"og:description \" content= \"{$ this ->ogDescription }\"> \n" ;
286286 }
287287
288- if ($ this ->ogImage && ($ mediaAssetUrl = inspirecms_asset ()->findByKey ($ this ->ogImage )?->getUrl())) {
288+ if ($ this ->ogImage && ($ mediaAssetUrl = inspirecms_asset ()->findByKeys ($ this ->ogImage )-> first ( )?->getUrl())) {
289289 $ html .= "<meta property= \"og:image \" content= \"{$ mediaAssetUrl }\"> \n" ;
290290 }
291291
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public function __construct(AssetService $assetService)
1616
1717 public function __invoke ($ key )
1818 {
19- $ asset = $ this ->assetService ->findByKey ($ key );
19+ $ asset = $ this ->assetService ->findByKeys ($ key)-> first ( );
2020
2121 $ media = $ asset ?->getFirstMedia();
2222
Original file line number Diff line number Diff line change 99class AssetService implements AssetServiceInterface
1010{
1111 /** {@inheritDoc} */
12- public function findByKey ( string | int $ key )
12+ public function findByKeys ( $ keys )
1313 {
14- return $ this ->getQuery ()->with ('media ' )->find ($ key );
15- }
16-
17- /** {@inheritDoc} */
18- public function findByKeys (...$ keys )
19- {
20- $ keys = array_filter (Arr::flatten ($ keys ));
14+ $ keys = array_filter (is_string ($ keys ) ? [$ keys ] : Arr::flatten ($ keys ));
2115
2216 if (count ($ keys ) === 0 ) {
2317 return collect ();
Original file line number Diff line number Diff line change 1010interface AssetServiceInterface
1111{
1212 /**
13- * @return ?TResult
14- */
15- public function findByKey (string | int $ key );
16-
17- /**
18- * @param string|int ...$keys
13+ * @param string|string[] $keys
1914 * @return Collection<TResult>
2015 */
21- public function findByKeys (... $ keys );
16+ public function findByKeys ($ keys );
2217}
You can’t perform that action at this time.
0 commit comments