1212namespace Sulu \Bundle \FormBundle \Metadata ;
1313
1414use Sulu \Bundle \AdminBundle \FormMetadata \FormMetadataMapper ;
15- use Sulu \Bundle \AdminBundle \FormMetadata \FormXmlLoader ;
15+ use Sulu \Bundle \AdminBundle \Metadata \ FormMetadata \ Loader \FormXmlLoader ;
1616use Sulu \Bundle \AdminBundle \Metadata \FormMetadata \FieldMetadata ;
1717use Sulu \Bundle \AdminBundle \Metadata \FormMetadata \FormMetadata ;
1818use Sulu \Bundle \AdminBundle \Metadata \FormMetadata \FormMetadataLoaderInterface ;
@@ -45,6 +45,8 @@ class DynamicFormMetadataLoader implements FormMetadataLoaderInterface, CacheWar
4545
4646 /**
4747 * @var FormMetadataMapper
48+ *
49+ * TODO REMOVE
4850 */
4951 private $ formMetadataMapper ;
5052
@@ -90,7 +92,7 @@ public function warmUp($cacheDir, ?string $buildDir = null): array
9092 $ formMetadataCollection = $ this ->formXmlLoader ->load ($ resource );
9193 foreach ($ formMetadataCollection ->getItems () as $ locale => $ formMetadata ) {
9294 $ section = new SectionMetadata ('formFields ' );
93- $ section ->setLabel ($ this ->translator ->trans ('sulu_form.form_fields ' , [], 'admin ' , $ locale ));
95+ $ section ->setLabel ($ this ->translator ->trans ('sulu_form.form_fields ' , [], 'admin ' , $ locale ), $ locale );
9496 $ fields = new FieldMetadata ('fields ' );
9597 $ fields ->setType ('block ' );
9698
@@ -101,8 +103,8 @@ public function warmUp($cacheDir, ?string $buildDir = null): array
101103 $ fieldTypeMetaDataCollection [] = $ this ->loadFieldTypeMetadata ($ typeKey , $ type , $ locale );
102104 }
103105
104- \usort ($ fieldTypeMetaDataCollection , static function (FormMetadata $ a , FormMetadata $ b ): int {
105- return \strcmp ($ a ->getTitle (), $ b ->getTitle ());
106+ \usort ($ fieldTypeMetaDataCollection , static function (FormMetadata $ a , FormMetadata $ b )use ( $ locale ) : int {
107+ return \strcmp ($ a ->getTitle ($ locale ), $ b ->getTitle ($ locale ));
106108 });
107109
108110 foreach ($ fieldTypeMetaDataCollection as $ fieldTypeMetaData ) {
@@ -111,11 +113,13 @@ public function warmUp($cacheDir, ?string $buildDir = null): array
111113
112114 $ fields ->setDefaultType (\current ($ fields ->getTypes ())->getName ());
113115 $ section ->addItem ($ fields );
116+ /* TODO HOW?
114117 $formItems = $formMetadata->getItems();
115118 $this->arrayInsertAtPosition($formItems, 1, [$section->getName() => $section]);
116119 $formMetadata->setItems($formItems);
117120 $configCache = $this->getConfigCache($formMetadata->getKey(), $locale);
118121 $configCache->write(\serialize($formMetadata), [new FileResource($resource)]);
122+ */
119123 }
120124
121125 return [];
@@ -151,11 +155,12 @@ private function loadFieldTypeMetadata(string $typeKey, FormFieldTypeInterface $
151155 {
152156 $ form = new FormMetadata ();
153157 $ configuration = $ type ->getConfiguration ();
158+
154159 $ properties = $ this ->propertiesXmlLoader ->load ($ configuration ->getXmlPath ());
155160
156- $ form ->setItems ($ this -> formMetadataMapper -> mapChildren ( $ properties-> getProperties (), $ locale ) );
157- $ form ->setName ($ typeKey );
158- $ form ->setTitle ($ this ->translator ->trans ($ configuration ->getTitle (), [], 'admin ' , $ locale ));
161+ $ form ->setItems ($ properties );
162+ $ form ->setKey ($ typeKey );
163+ $ form ->setTitle ($ this ->translator ->trans ($ configuration ->getTitle (), [], 'admin ' , $ locale ), $ locale );
159164
160165 return $ form ;
161166 }
0 commit comments