Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds shop aware services for modules
- Loading branch information
Showing
32 changed files
with
1,621 additions
and
18 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
19 changes: 19 additions & 0 deletions
19
source/Internal/Application/Events/AbstractShopAwareEventSubscriber.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,19 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\EshopCommunity\Internal\Application\Events; | ||
|
||
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
|
||
/** | ||
* Class ShopAwareEventSubscriber | ||
*/ | ||
abstract class AbstractShopAwareEventSubscriber implements EventSubscriberInterface, ShopAwareInterface | ||
{ | ||
use ShopAwareServiceTrait; | ||
} |
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
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,77 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\EshopCommunity\Internal\ProjectDIConfig\Dao; | ||
|
||
use OxidEsales\EshopCommunity\Internal\ProjectDIConfig\DataObject\DIConfigWrapper; | ||
use OxidEsales\EshopCommunity\Internal\Utility\ContextInterface; | ||
use Symfony\Component\Yaml\Yaml; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class ProjectYamlDao implements ProjectYamlDaoInterface | ||
{ | ||
/** | ||
* @var ContextInterface $context | ||
*/ | ||
private $context; | ||
|
||
/** | ||
* ProjectYamlDao constructor. | ||
* | ||
* @param ContextInterface $context | ||
*/ | ||
public function __construct(ContextInterface $context) | ||
{ | ||
$this->context = $context; | ||
} | ||
|
||
/** | ||
* @return DIConfigWrapper | ||
*/ | ||
public function loadProjectConfigFile(): DIConfigWrapper | ||
{ | ||
return $this->loadDIConfigFile($this->getProjectFileName()); | ||
} | ||
|
||
/** | ||
* @param DIConfigWrapper $config | ||
*/ | ||
public function saveProjectConfigFile(DIConfigWrapper $config) | ||
{ | ||
file_put_contents($this->getProjectFileName(), Yaml::dump($config->getConfigAsArray(), 3, 2)); | ||
if (file_exists($this->context->getContainerCacheFile())) { | ||
unlink($this->context->getContainerCacheFile()); | ||
} | ||
} | ||
|
||
/** | ||
* @param string $path | ||
* | ||
* @return array | ||
*/ | ||
public function loadDIConfigFile(string $path): DIConfigWrapper | ||
{ | ||
$yamlArray = null; | ||
if (file_exists($path)) { | ||
$yamlArray = Yaml::parse(file_get_contents($path)); | ||
} | ||
if (is_null($yamlArray)) { | ||
$yamlArray = []; | ||
} | ||
return new DIConfigWrapper($yamlArray); | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
private function getProjectFileName(): string | ||
{ | ||
return $this->context->getShopDir() . DIRECTORY_SEPARATOR . ProjectYamlDaoInterface::PROJECT_FILE_NAME; | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
source/Internal/ProjectDIConfig/Dao/ProjectYamlDaoInterface.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,36 @@ | ||
<?php declare(strict_types=1); | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\EshopCommunity\Internal\ProjectDIConfig\Dao; | ||
|
||
use OxidEsales\EshopCommunity\Internal\ProjectDIConfig\DataObject\DIConfigWrapper; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
interface ProjectYamlDaoInterface | ||
{ | ||
|
||
const PROJECT_FILE_NAME = 'project.yaml'; | ||
|
||
/** | ||
* @param string $path | ||
* | ||
* @return DIConfigWrapper | ||
*/ | ||
public function loadDIConfigFile(string $path): DIConfigWrapper; | ||
|
||
/** | ||
* @return DIConfigWrapper | ||
*/ | ||
public function loadProjectConfigFile(): DIConfigWrapper; | ||
|
||
/** | ||
* @param DIConfigWrapper $config | ||
*/ | ||
public function saveProjectConfigFile(DIConfigWrapper $config); | ||
} |
78 changes: 78 additions & 0 deletions
78
source/Internal/ProjectDIConfig/DataObject/DICallWrapper.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,78 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
namespace OxidEsales\EshopCommunity\Internal\ProjectDIConfig\DataObject; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
class DICallWrapper | ||
{ | ||
|
||
const METHOD_KEY = 'method'; | ||
const PARAMETER_KEY = 'arguments'; | ||
|
||
private $callArray; | ||
|
||
/** | ||
* DICallWrapper constructor. | ||
* | ||
* @param array $callArray | ||
*/ | ||
public function __construct(array $callArray = []) | ||
{ | ||
if (! $callArray) { | ||
$this->callArray = ['method' => '', 'arguments' => []]; | ||
} else { | ||
$this->callArray = $callArray; | ||
} | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getMethodName(): string | ||
{ | ||
return $this->callArray[$this::METHOD_KEY]; | ||
} | ||
|
||
/** | ||
* @param string $methodName | ||
*/ | ||
public function setMethodName(string $methodName) | ||
{ | ||
$this->callArray[$this::METHOD_KEY] = $methodName; | ||
} | ||
|
||
/** | ||
* @param int $index | ||
* @param mixed $parameter | ||
*/ | ||
public function setParameter(int $index, $parameter) | ||
{ | ||
$this->callArray[$this::PARAMETER_KEY][$index] = $parameter; | ||
} | ||
|
||
/** | ||
* @param int $index | ||
* | ||
* @return mixed | ||
*/ | ||
public function getParameter(int $index) | ||
{ | ||
return $this->callArray[$this::PARAMETER_KEY][$index]; | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getCallAsArray(): array | ||
{ | ||
return $this->callArray; | ||
} | ||
} |
Oops, something went wrong.