Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat/magento-app-mappings #97

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 0 additions & 80 deletions config/template/akeneo/README.md

This file was deleted.

12 changes: 0 additions & 12 deletions config/template/akeneo/csv/pull_akeneo-entities.yaml

This file was deleted.

15 changes: 0 additions & 15 deletions config/template/akeneo/csv/pull_akeneo-identifiers.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions config/template/akeneo/csv/pull_akeneo-reference-entities.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions config/template/akeneo/csv/push_akeneo-entities.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions config/template/akeneo/csv/push_akeneo-reference-entities.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions config/template/akeneo/json/pull_akeneo-entities.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions config/template/akeneo/json/pull_akeneo-reference-entities.yaml

This file was deleted.

14 changes: 0 additions & 14 deletions config/template/akeneo/json/push_akeneo-entities.yaml

This file was deleted.

16 changes: 0 additions & 16 deletions config/template/akeneo/json/push_akeneo-reference-entities.yaml

This file was deleted.

10 changes: 10 additions & 0 deletions src/Component/Action/ActionItemInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace Misery\Component\Action;

use Misery\Model\DataStructure\ItemInterface;

interface ActionItemInterface
{
public function applyAsItem(ItemInterface $item): ItemInterface;
}
6 changes: 3 additions & 3 deletions src/Component/Action/ConcatAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function apply(array $item): array
return $item;
}

// don't check if array_key_exist here, concat should always work, if the field doesn't exist
// somewhat the point to form a new field from concatination
$item[$field] = ValueFormatter::format($this->getOption('format'), $item);
if (array_key_exists($field, $item)) {
$item[$field] = ValueFormatter::format($this->getOption('format'), $item);
}

return $item;
}
Expand Down
10 changes: 10 additions & 0 deletions src/Component/Action/CopyAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use Misery\Component\Common\Options\OptionsInterface;
use Misery\Component\Common\Options\OptionsTrait;
use Misery\Component\Converter\Matcher;
use Misery\Model\DataStructure\ItemInterface;

class CopyAction implements ActionInterface, OptionsInterface
{
Expand All @@ -18,6 +19,15 @@ class CopyAction implements ActionInterface, OptionsInterface
'to' => null,
];

public function applyAsItem(ItemInterface $item): ItemInterface
{
$from = $this->getOption('from');
$to = $this->getOption('to');
$item->copyItem($from, $to);

return $item;
}

public function apply(array $item): array
{
$to = $this->getOption('to');
Expand Down
28 changes: 10 additions & 18 deletions src/Component/Action/DebugAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,27 @@

namespace Misery\Component\Action;

use JetBrains\PhpStorm\NoReturn;
use Misery\Component\Common\Options\OptionsInterface;
use Misery\Component\Common\Options\OptionsTrait;
use Misery\Model\DataStructure\ItemInterface;

class DebugAction implements OptionsInterface, ActionInterface
class DebugAction implements OptionsInterface, ActionInterface, ActionItemInterface
{
use OptionsTrait;

public const NAME = 'debug';

/** @var array */
private $options = [
'field' => null,
'until_field' => null,
];
private $options = [];

public function apply(array $item): array
#[NoReturn] public function applyAsItem(ItemInterface $item): ItemInterface
{
$untilField = $this->getOption('until_field');
if ($untilField && isset($item[$untilField])) {
dd($item[$untilField]);
}
$field = $this->getOption('field');
if ($field) {
dd($item[$field]);
}
if (null === $field && null === $untilField) {
dd($item);
}
dd($item);
}

return $item;
public function apply(array $item): array
{
dd($item);
}
}
17 changes: 16 additions & 1 deletion src/Component/Action/ExpandAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

use Misery\Component\Common\Options\OptionsInterface;
use Misery\Component\Common\Options\OptionsTrait;
use Misery\Model\DataStructure\ItemInterface;

class ExpandAction implements OptionsInterface
class ExpandAction implements OptionsInterface, ActionItemInterface
{
use OptionsTrait;

Expand All @@ -17,6 +18,20 @@ class ExpandAction implements OptionsInterface
'list' => null,
];

public function applyAsItem(ItemInterface $item): ItemInterface
{
$list = $this->getOption('set', $this->getOption('list', []));
if (empty($list)) {
return $item;
}

foreach ($list as $itemCode => $itemValue) {
$item->addItem($itemCode, $itemValue);
}

return $item;
}

public function apply(array $item): array
{
return array_replace_recursive($this->getOption('set', $this->getOption('list', [])), $item);
Expand Down
18 changes: 17 additions & 1 deletion src/Component/Action/ExtensionAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@
use Misery\Component\Configurator\ConfigurationTrait;
use Misery\Component\Configurator\ReadOnlyConfiguration;
use Misery\Component\Extension\ExtensionInterface;
use Misery\Model\DataStructure\ItemInterface;

class ExtensionAction implements OptionsInterface, ConfigurationAwareInterface
class ExtensionAction implements OptionsInterface, ConfigurationAwareInterface, ActionItemInterface
{
use OptionsTrait;
use ConfigurationTrait;
Expand All @@ -22,6 +23,21 @@ class ExtensionAction implements OptionsInterface, ConfigurationAwareInterface
'extension' => null,
];

public function applyAsItem(ItemInterface $item): ItemInterface
{
$extension = $this->getOption('extension');
if (null === $extension) {
return $item;
}
// loadExtension
if (null === $this->extension) {
$extensionFile = $this->configuration->getExtensions()[$extension.'.php'] ?? null;
$this->extension = $this->loadExtension($extensionFile, 'Extensions\\'.$extension);
}

return $this->extension->applyAsItem($item);
}

public function apply($item): array
{
$extension = $this->getOption('extension');
Expand Down
Loading
Loading