Skip to content

Commit

Permalink
Remove lefover debug/test code
Browse files Browse the repository at this point in the history
  • Loading branch information
robaimes committed Oct 31, 2024
1 parent dc4a174 commit dd5f076
Showing 1 changed file with 8 additions and 23 deletions.
31 changes: 8 additions & 23 deletions Ui/DataProvider/Product/Form/Modifier/SelectToUiSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,29 +42,25 @@ public function __construct(
*/
public function modifyMeta(array $meta): array
{
$componentConfigPaths = $this->arrayManager->findPaths(
'config',
$meta,
);
$componentConfigPaths = $this->arrayManager->findPaths('config', $meta);

foreach ($componentConfigPaths as $componentConfigPath) {
$attributeCode = null;
$componentConfig = $this->arrayManager->get($componentConfigPath, $meta);

if (!$componentConfig || !$this->shouldProcessComponent($componentConfig, $componentConfigPath)) {
if (!$componentConfig || !$this->shouldProcessComponent($componentConfig)) {
continue;
}

$isMultiple = $componentConfig['formElement'] === MultiSelect::NAME;

if ($isMultiple) {
$attributeCode = $this->recordMultiSelectAttribute($componentConfigPath);
$this->recordMultiSelectAttribute($componentConfigPath);
}

$meta = $this->arrayManager->merge(
$componentConfigPath,
$meta,
$this->getUiSelectConfig($isMultiple, $attributeCode)
$this->getUiSelectConfig($isMultiple)
);
}

Expand Down Expand Up @@ -119,11 +115,8 @@ private function shouldProcessComponent(array $componentConfig): bool {
/**
* @return array[]
*/
private function getUiSelectConfig(
bool $isMultiple,
?string $attributeCode = null
): array {
$uiSelectComponent = [
private function getUiSelectConfig(bool $isMultiple): array {
return [
'component' => 'Aimes_ImprovedAdminUi/js/form/element/ui-select',
'componentType' => Field::NAME,
'dataType' => 'text',
Expand All @@ -135,26 +128,18 @@ private function getUiSelectConfig(
'levelsVisibility' => '1',
'elementTmpl' => 'ui/grid/filters/elements/ui-select',
];

if ($attributeCode) {
$uiSelectComponent['dataScope'] = $attributeCode;
}

return $uiSelectComponent;
}

/**
* @param string $componentConfigPath
* @return string
* @return void
*/
private function recordMultiSelectAttribute(string $componentConfigPath): string
private function recordMultiSelectAttribute(string $componentConfigPath): void
{
$componentPath = $this->arrayManager->slicePath($componentConfigPath, 0, -3);
$finalDelimiterPosition = strrpos($componentPath, '/');
$attributeCode = substr($componentPath, $finalDelimiterPosition + 1);

$this->multiSelectAttributes[] = $attributeCode;

return $attributeCode;
}
}

0 comments on commit dd5f076

Please sign in to comment.