Skip to content
Snippets Groups Projects
Commit 958e54c1 authored by Harald Deiser's avatar Harald Deiser
Browse files

Merge branch 'develop' of github.com:magento-hackathon/m2-content-provisioning...

Merge branch 'develop' of github.com:magento-hackathon/m2-content-provisioning into 7-added_add_by_key_command
parents a54dddde c3f9816f
No related branches found
No related tags found
1 merge request!26Added command to add blocks and pages by key to resolve #7
<?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;
}
<?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;
}
<?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.
}
}
<?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.
}
}
<?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;
}
}
......@@ -107,4 +107,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