-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[!!!][FEATURE] Parent/child relationships with data inheritance by pr…
…oduct type (#247) * [WIP] Testing concepts * [WIP] Testing concepts * [TASK] Switch from sub product to parent/child * [FEATURE] Increased speed for relations display in BE Moved from using select (where all potential records were loaded in the form) to group (where you have to search to add a relation). * [TASK] Implement parent/child getters and setters * [TASK] Select inherited fields in ProductType * [TASK] Remove showRecordFieldList from TCA The interface->showRecordFieldList property is no longer used. * [TASK] Set inherited fields to readOnly=true * [TASK] Insert field parent data and inheritance info * [FEATURE] Field data is inherited when saving a record * [CLEANUP] Code style fixes * [CLEANUP] Code style fixes * [CLEANUP] Code style fixes * [TASK] Rename AttributesValuesUpdate to UpdateAttributeValuesProcessDatamap * [TASK] Refactored Hooks directory * [TASK] Implemented attribute inheritance * [TASK] ParentValueFieldWizard supports inherited attributes * [TASK] Relation inheritance also for inline relations * [CLEANUP] CS fixes * [CLEANUP] CS fixes * [WIP] Testing concepts * [WIP] Testing concepts * [TASK] Switch from sub product to parent/child * [FEATURE] Increased speed for relations display in BE Moved from using select (where all potential records were loaded in the form) to group (where you have to search to add a relation). * [TASK] Implement parent/child getters and setters * [TASK] Select inherited fields in ProductType * [TASK] Remove showRecordFieldList from TCA The interface->showRecordFieldList property is no longer used. * [TASK] Set inherited fields to readOnly=true * [TASK] Insert field parent data and inheritance info * [FEATURE] Field data is inherited when saving a record * [CLEANUP] Code style fixes * [CLEANUP] Code style fixes * [CLEANUP] Code style fixes * [TASK] Rename AttributesValuesUpdate to UpdateAttributeValuesProcessDatamap * [TASK] Refactored Hooks directory * [TASK] Implemented attribute inheritance * [TASK] ParentValueFieldWizard supports inherited attributes * [TASK] Relation inheritance also for inline relations * [CLEANUP] CS fixes * [CLEANUP] CS fixes * [BUGFIX] Correct spelling in label * [TASK] Move from simulated attribute fields to real ones * [TASK] Attribute fields look like other fields. * [TASK] Move adding of CSS into method * [TASK] Add attribute value's type as hidden field Only on new, non-persisted fields * [TASK] Skip duplicate attributes Only on new, non-persisted fields * [TASK] Revert previous commit * [TASK] Reduced cyclomatic complexity * [TASK] Fixed missing attributeId on image/fal attribute values * [WIP] Fixing attribute inheritance * [TASK] Working file relations in inline grandchild * [CLEANUP] Remove unused code and comments * [CLEANUP] CS fixes * [TASK] Bring back AttributeIdentifierControl Accidentally deleted. * [BUGFIX] Childrens' children were not properly deleted * [TASK] Show inheritance info on attribute fields * [TASK] Show inheritance info also on inline fields * [TASK] Show inheritance info also on inherited inline fields. * [CLEANUP] CS fixes * [CLEANUP] CS fixes * [TASK] Remove tests for removed class * [TASK] Fix ConfigurationProviderFactoryTest * [TASK] Fix AbstractProviderTest * [CLEANUP] CS Fixes * [WIP] update selectboxprovider * [WIP] fix getChildren, fix null * [CLEANUP] CS Fixes * [CLEANUP] Reduced cyclomatic complexity * [CLEANUP] Disable cyclomatic complexity check for method * [CLEANUP] Ignore CS issue for both phpcs and php-cs-fixer * [BUGFIX] map to attribute array type value Co-authored-by: Mats Svensson <[email protected]>
- Loading branch information
1 parent
9e9c831
commit e541d69
Showing
46 changed files
with
2,151 additions
and
787 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
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
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
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
125 changes: 125 additions & 0 deletions
125
Classes/Backend/FormDataProvider/AttributeValueFormDataProvider.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,125 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Pixelant\PxaProductManager\Backend\FormDataProvider; | ||
|
||
use Pixelant\PxaProductManager\Domain\Collection\CanCreateCollection; | ||
use Pixelant\PxaProductManager\Domain\Repository\AttributeValueRepository; | ||
use Pixelant\PxaProductManager\Domain\Repository\ProductRepository; | ||
use Pixelant\PxaProductManager\FlashMessage\BackendFlashMessage; | ||
use Pixelant\PxaProductManager\Translate\CanTranslateInBackend; | ||
use Pixelant\PxaProductManager\Utility\DataInheritanceUtility; | ||
use TYPO3\CMS\Backend\Form\FormDataProviderInterface; | ||
use TYPO3\CMS\Backend\Utility\BackendUtility; | ||
use TYPO3\CMS\Core\Page\PageRenderer; | ||
use TYPO3\CMS\Core\Utility\GeneralUtility; | ||
use TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper; | ||
|
||
/** | ||
* Form data provider hook, add TCA on a fly. | ||
*/ | ||
class AttributeValueFormDataProvider implements FormDataProviderInterface | ||
{ | ||
use CanTranslateInBackend; | ||
use CanCreateCollection; | ||
|
||
/** | ||
* @var DataMapper | ||
*/ | ||
protected DataMapper $dataMapper; | ||
|
||
/** | ||
* @var BackendFlashMessage | ||
*/ | ||
protected BackendFlashMessage $flashMessage; | ||
|
||
/** | ||
* @param BackendFlashMessage $flashMessage | ||
*/ | ||
public function __construct(BackendFlashMessage $flashMessage = null) | ||
{ | ||
$this->flashMessage = $flashMessage ?? GeneralUtility::makeInstance(BackendFlashMessage::class); | ||
} | ||
|
||
/** | ||
* @param array $result | ||
* @return array | ||
*/ | ||
public function addData(array $result): array | ||
{ | ||
if ($result['tableName'] !== AttributeValueRepository::TABLE_NAME) { | ||
return $result; | ||
} | ||
|
||
$this->addCss(); | ||
|
||
$result = $this->handleInheritedFields($result); | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Disable inherited fields. | ||
* | ||
* @param array $result | ||
* @return array | ||
*/ | ||
protected function handleInheritedFields(array $result) | ||
{ | ||
$attributeValue = $result['databaseRow']; | ||
|
||
$product = BackendUtility::getRecord( | ||
ProductRepository::TABLE_NAME, | ||
$attributeValue['product'] | ||
); | ||
|
||
if (!$product['product_type'] || !$product['parent']) { | ||
return $result; | ||
} | ||
|
||
$configuration = &$result['processedTca']['columns']['value']; | ||
|
||
if ( | ||
in_array( | ||
'attribute.' . $attributeValue['attribute'][0], | ||
DataInheritanceUtility::getInheritedFieldsForProductType((int)$product['product_type']), | ||
true | ||
) | ||
) { | ||
$configuration['config']['readOnly'] = true; | ||
|
||
if ($configuration['config']['type'] === 'inline') { | ||
// @codingStandardsIgnoreLine | ||
$result['processedTca']['ctrl']['container']['inline']['fieldInformation']['inheritedProductField']['renderType'] | ||
= 'inheritedProductField'; | ||
} else { | ||
$configuration['config']['fieldInformation']['inheritedProductField']['renderType'] | ||
= 'inheritedProductField'; | ||
} | ||
} else { | ||
if ($configuration['config']['type'] === 'inline') { | ||
// @codingStandardsIgnoreLine | ||
$result['processedTca']['ctrl']['container']['inline']['fieldWizard']['productParentValue']['renderType'] | ||
= 'productParentValue'; | ||
} else { | ||
$configuration['config']['fieldWizard']['productParentValue']['renderType'] | ||
= 'productParentValue'; | ||
} | ||
} | ||
|
||
return $result; | ||
} | ||
|
||
/** | ||
* Add CSS to the page renderer. Ensures attributes are styles like other fields. | ||
*/ | ||
protected function addCss(): void | ||
{ | ||
/** @var PageRenderer $pageRenderer */ | ||
$pageRenderer = GeneralUtility::makeInstance(PageRenderer::class); | ||
$pageRenderer->addCssFile( | ||
'EXT:pxa_product_manager/Resources/Public/Css/Backend/formEngine.css' | ||
); | ||
} | ||
} |
Oops, something went wrong.