3232use Pimcore \Model \Asset \Image ;
3333use Pimcore \Model \DataObject \AbstractObject ;
3434use Pimcore \Model \DataObject \ClassDefinition \Data ;
35- use Pimcore \Model \DataObject \ClassDefinition \Data \Block ;
3635use Pimcore \Model \DataObject \ClassDefinition \Data \Hotspotimage as HotspotImageData ;
3736use Pimcore \Model \DataObject \Concrete ;
3837use Pimcore \Model \DataObject \Data \Hotspotimage ;
3938use Pimcore \Model \Document ;
4039use Pimcore \Model \Element \Data \MarkerHotspotItem ;
4140use Pimcore \Model \UserInterface ;
4241use Symfony \Component \DependencyInjection \Attribute \AutoconfigureTag ;
42+ use function get_class ;
4343use function in_array ;
4444use function is_array ;
4545
4646/**
4747 * @internal
4848 */
4949#[AutoconfigureTag(DataAdapterLoaderInterface::ADAPTER_TAG )]
50- final readonly class HotspotImageAdapter implements SetterDataInterface,
50+ final readonly class HotspotImageAdapter implements
51+ SetterDataInterface,
5152 SearchPreviewDataInterface,
5253 DataNormalizerInterface
5354{
@@ -112,25 +113,25 @@ public function normalizeImageData(MarkerHotspotItem $hotspotItem): array
112113
113114 public function normalize (mixed $ value , Data $ fieldDefinition ): mixed
114115 {
115- if (!($ fieldDefinition instanceof HotspotImageData)) {
116+ if (!($ fieldDefinition instanceof HotspotImageData)) {
116117 throw new InvalidDataTypeException (HotspotImageData::class, get_class ($ fieldDefinition ));
117118 }
118119
119120 $ value = $ fieldDefinition ->normalize ($ value );
120- if (!is_array ($ value )) {
121+ if (!is_array ($ value )) {
121122 return null ;
122123 }
123124
124125 $ id = $ value ['image ' ]['id ' ] ?? null ;
125126 $ type = $ value ['image ' ]['type ' ] ?? null ;
126127
127- if ($ id === null || $ type === null ) {
128+ if ($ id === null || $ type === null ) {
128129 return $ value ;
129130 }
130131
131132 $ value ['image ' ] = [
132133 ... $ value ['image ' ],
133- ...$ this ->normalizeElementData ($ id , $ type )
134+ ...$ this ->normalizeElementData ($ id , $ type ),
134135 ];
135136 $ value ['hotspots ' ] = $ this ->normalizeHotSpotData ($ value ['hotspots ' ]);
136137
@@ -140,7 +141,7 @@ public function normalize(mixed $value, Data $fieldDefinition): mixed
140141 private function normalizeElementData (int $ id , string $ type ): array
141142 {
142143 $ element = $ this ->getElementData ($ id , $ type );
143- if ($ element instanceof AbstractObject || $ element instanceof Document) {
144+ if ($ element instanceof AbstractObject || $ element instanceof Document) {
144145 $ elementData ['published ' ] = $ element ->isPublished ();
145146 }
146147 $ elementData ['subtype ' ] = $ element ->getType ();
@@ -156,13 +157,13 @@ private function normalizeHotSpotData(array $hotSpotData): array
156157 if (!is_array ($ data )) {
157158 continue ;
158159 }
159- foreach ($ data as $ item ) {
160- if ($ item instanceof MarkerHotspotItem &&
160+ foreach ($ data as $ item ) {
161+ if ($ item instanceof MarkerHotspotItem &&
161162 $ this ->isValidItem ($ item )
162163 ) {
163164 $ hotSpot ['data ' ] = [
164165 ... $ this ->normalizeImageData ($ item ),
165- ... $ this ->normalizeElementData ($ item ->getValue (), $ item ->getType ())
166+ ... $ this ->normalizeElementData ($ item ->getValue (), $ item ->getType ()),
166167 ];
167168 }
168169 }
@@ -177,6 +178,7 @@ private function getElementData(int $id, string $type): Asset|Document|AbstractO
177178 if ($ element === null ) {
178179 throw new NotFoundException ($ type , $ id );
179180 }
181+
180182 return $ element ;
181183 }
182184
0 commit comments