33/**
44 * This file is part of MetaModels/attribute_translatedfile.
55 *
6- * (c) 2012-2017 The MetaModels team.
6+ * (c) 2012-2024 The MetaModels team.
77 *
88 * For the full copyright and license information, please view the LICENSE
99 * file that was distributed with this source code.
1313 * @package MetaModels
1414 * @subpackage AttributeTranslatedFile
1515 * @author Sven Baumann <[email protected] > 16- * @copyright 2012-2017 The MetaModels team.
16+ * @author Ingolf Steinhardt <[email protected] > 17+ * @copyright 2012-2024 The MetaModels team.
1718 * @license https://github.com/MetaModels/attribute_file/blob/master/LICENSE LGPL-3.0
1819 * @filesource
1920 */
@@ -41,7 +42,6 @@ class BuildAttributeListener
4142 public function buildAttribute (BuildAttributeEvent $ event )
4243 {
4344 $ attribute = $ event ->getAttribute ();
44-
4545 if (
4646 !($ attribute instanceof TranslatedFile)
4747 || !$ attribute ->get ('file_multiple ' )
@@ -52,17 +52,16 @@ public function buildAttribute(BuildAttributeEvent $event)
5252 $ container = $ event ->getContainer ();
5353 $ properties = $ container ->getPropertiesDefinition ();
5454 $ name = $ attribute ->getColName ();
55+ $ nameSort = \sprintf ('%s__sort ' , $ name );
5556
56- if ($ properties ->hasProperty ($ name . '__sort ' )) {
57- $ this ->addAttributeToDefinition ($ container , $ name );
58-
59- $ properties ->getProperty ($ name . '__sort ' )->setWidgetType ('fileTreeOrder ' );
60-
61- return ;
57+ if (!$ properties ->hasProperty ($ nameSort )) {
58+ $ properties ->addProperty (new DefaultProperty ($ nameSort ));
6259 }
6360
64- $ properties ->addProperty ($ property = new DefaultProperty ($ name . '__sort ' ));
65- $ property ->setWidgetType ('fileTreeOrder ' );
61+ $ properties ->getProperty ($ nameSort )
62+ ->setWidgetType ('fileTreeOrder ' )
63+ ->setLabel ($ nameSort )
64+ ->setExtra (['tl_class ' => 'hidden ' ]);
6665
6766 $ this ->addAttributeToDefinition ($ container , $ name );
6867 }
@@ -75,7 +74,7 @@ public function buildAttribute(BuildAttributeEvent $event)
7574 *
7675 * @return void
7776 */
78- protected function addAttributeToDefinition (ContainerInterface $ container , $ name )
77+ private function addAttributeToDefinition (ContainerInterface $ container , string $ name ): void
7978 {
8079 if (!$ container ->hasDefinition ('metamodels.translatedfile-attributes ' )) {
8180 $ container ->setDefinition ('metamodels.translatedfile-attributes ' , new AttributeTranslatedFileDefinition ());
0 commit comments