-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implemented new provider with correct implementation of the interface…
… to avoid BC break
- Loading branch information
Showing
2 changed files
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
src/lib/Content/Form/Provider/NonLocalizedGroupedContentFormFieldsProvider.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
/** | ||
* @copyright Copyright (C) Ibexa AS. All rights reserved. | ||
* @license For full copyright and license information view LICENSE file distributed with this source code. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Ibexa\ContentForms\Content\Form\Provider; | ||
|
||
use Ibexa\Contracts\ContentForms\Content\Form\Provider\GroupedContentFormFieldsProviderInterface; | ||
use Ibexa\Core\Helper\FieldsGroups\FieldsGroupsList; | ||
use JMS\TranslationBundle\Model\Message; | ||
use JMS\TranslationBundle\Translation\TranslationContainerInterface; | ||
|
||
class NonLocalizedGroupedContentFormFieldsProvider implements GroupedContentFormFieldsProviderInterface, TranslationContainerInterface | ||
{ | ||
/** @var \Ibexa\Core\Helper\FieldsGroups\FieldsGroupsList */ | ||
private $fieldsGroupsList; | ||
|
||
public function __construct(FieldsGroupsList $fieldsGroupsList) | ||
{ | ||
$this->fieldsGroupsList = $fieldsGroupsList; | ||
} | ||
|
||
public function getGroupedFields(array $fieldsDataForm): array | ||
{ | ||
$groupedFields = []; | ||
|
||
foreach ($fieldsDataForm as $fieldForm) { | ||
/** @var \Ibexa\Contracts\ContentForms\Data\Content\FieldData $fieldData */ | ||
$fieldData = $fieldForm->getViewData(); | ||
$fieldGroupIdentifier = $this->fieldsGroupsList->getFieldGroup($fieldData->fieldDefinition); | ||
$groupedFields[$fieldGroupIdentifier][] = $fieldForm->getName(); | ||
} | ||
|
||
return $groupedFields; | ||
} | ||
|
||
public static function getTranslationMessages(): array | ||
{ | ||
return [ | ||
Message::create('content', 'ibexa_fields_groups')->setDesc('Content'), | ||
Message::create('metadata', 'ibexa_fields_groups')->setDesc('Metadata'), | ||
]; | ||
} | ||
} |