Skip to content

Commit c7da7fa

Browse files
Merge pull request #5 from basilicom/feature/additional-relation-type-support
Added preview rendering for assets
2 parents c2f46b3 + 1d00bbe commit c7da7fa

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/DependencyInjection/BasilicomPathFormatter.php

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ public function __construct(PimcoreAdapter $pimcoreAdapter, bool $enableAssetPre
2323
}
2424

2525
/**
26-
* @param array $result containing the nice path info. Modify it or leave it as it is. Pass it out afterwards!
27-
* @param ElementInterface $source the source object
28-
* @param array $targets list of nodes describing the target elements
29-
* @param array $params optional parameters. may contain additional context information in the future. to be defined.
26+
* @param array $result containing the nice path info. Modify it or leave it as it is. Pass it out afterwards!
27+
* @param ElementInterface $source the source object
28+
* @param array $targets list of nodes describing the target elements
29+
* @param array $params optional parameters. may contain additional context information in the future. to be defined.
3030
*
3131
* @return array list of display names.
3232
*/
@@ -109,9 +109,13 @@ private function getFormattedPath(string $className, string $pattern, ?AbstractE
109109
return '';
110110
}
111111

112+
$formattedPath = $pattern;
113+
if ($targetElement instanceof Asset\Image && $this->enableAssetPreview) {
114+
$formattedPath = '<img src="' . $targetElement->getFullPath() . '" style="height: 18px; margin-right: 5px;" /> ' . $formattedPath;
115+
}
116+
112117
$propertyList = $this->getPropertyListFromPattern($pattern);
113118

114-
$formattedPath = $pattern;
115119
foreach ($propertyList as $property) {
116120
$propertyGetter = 'get' . ucfirst(trim($property));
117121
if (method_exists($targetElement, $propertyGetter)) {
@@ -139,5 +143,4 @@ private function getPropertyListFromPattern(string $pattern): array
139143

140144
return !empty($matches) ? $matches[1] : [];
141145
}
142-
143146
}

0 commit comments

Comments
 (0)