Skip to content
Snippets Groups Projects
Commit 88ae5711 authored by Ulf Tietze's avatar Ulf Tietze
Browse files

Introduce Export Definition to Dump Entries

parent 0502e99f
No related branches found
No related tags found
1 merge request!24Introduce Export Definition to Dump Entries
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api;
use Firegento\ContentProvisioning\Api\Data\EntryInterface;
interface ExportInterface
{
/**
* @param StrategyInterface $strategy
* @param EntryInterface $entry
* @return void
*/
public function execute(StrategyInterface $strategy, EntryInterface $entry): void;
}
\ No newline at end of file
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api;
interface StrategyInterface
{
/**
* @return string
*/
public function getTargetPath(): string;
}
\ No newline at end of file
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Api;
use Magento\Framework\Exception\NotFoundException;
interface StrategyProviderInterface
{
/**
* @param string $strategyCode
* @return StrategyInterface
*
* @throws NotFoundException
*/
public function get(string $strategyCode): StrategyInterface;
}
\ No newline at end of file
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Model\Strategy;
use Firegento\ContentProvisioning\Api\StrategyInterface;
class ExportToModule implements StrategyInterface
{
/**
* @return string
*/
public function getTargetPath(): string
{
// TODO: Implement getTargetPath() method.
}
}
\ No newline at end of file
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Model\Strategy;
use Firegento\ContentProvisioning\Api\StrategyInterface;
class ExportToVar implements StrategyInterface
{
/**
* @return string
*/
public function getTargetPath(): string
{
// TODO: Implement getTargetPath() method.
}
}
\ No newline at end of file
<?php
declare(strict_types=1);
namespace Firegento\ContentProvisioning\Model\Strategy;
use Firegento\ContentProvisioning\Api\StrategyInterface;
use Firegento\ContentProvisioning\Api\StrategyProviderInterface;
use Magento\Framework\Exception\NotFoundException;
class Provider implements StrategyProviderInterface
{
/**
* @var array|StrategyInterface[]
*/
private $strategies;
/**
* Provider constructor.
* @param StrategyInterface[] $strategies
*/
public function __construct(array $strategies)
{
$this->strategies = $strategies;
}
/**
* @param string $strategyCode
* @return StrategyInterface
*
* @throws NotFoundException
*/
public function get(string $strategyCode): StrategyInterface
{
$strategy = $this->strategies[$strategyCode] ?? null;
if (!$strategy) {
throw new NotFoundException(__('Strategy %s not found.', $strategyCode));
}
return $strategy;
}
}
\ No newline at end of file
......@@ -105,4 +105,24 @@
</argument>
</arguments>
</type>
<preference
for="Firegento\ContentProvisioning\Api\StrategyProviderInterface"
type="Firegento\ContentProvisioning\Model\Strategy\Provider"
/>
<preference
for="Firegento\ContentProvisioning\Api\ExportInterface"
type="Firegento\ContentProvisioning\Model\Command\ExportEntry"
/>
<type name="Firegento\ContentProvisioning\Model\Strategy\Provider">
<arguments>
<argument name="strategies" xsi:type="array">
<item name="export_to_module" xsi:type="object">Firegento\ContentProvisioning\Model\Strategy\ExportToModule</item>
<item name="export_to_var" xsi:type="object">Firegento\ContentProvisioning\Model\Strategy\ExportToVar</item>
</argument>
</arguments>
</type>
</config>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment