| 1 | <?php |
||
| 5 | abstract class Base |
||
| 6 | { |
||
| 7 | private static $instances = array(); |
||
| 8 | |||
| 9 | private $manager; |
||
| 10 | |||
| 11 | 8 | protected function __construct() |
|
| 14 | |||
| 15 | protected function __clone() |
||
| 18 | |||
| 19 | /** |
||
| 20 | * {@inheritdoc} |
||
| 21 | */ |
||
| 22 | 20 | public static function getInstance() |
|
| 23 | { |
||
| 24 | 20 | $class = static::class; |
|
| 25 | 20 | if (!isset(self::$instances[$class])) { |
|
| 26 | 8 | self::$instances[$class] = new static(); |
|
| 27 | 8 | } |
|
| 28 | 20 | return self::$instances[$class]; |
|
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @return \Iris\Manager |
||
| 33 | */ |
||
| 34 | 1 | public function getManager() |
|
| 35 | { |
||
| 36 | 1 | $this->manager || $this->setManager(\Iris\Manager::getInstance()); |
|
| 37 | 1 | return $this->manager; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * @param \Iris\Manager $manager |
||
| 42 | * @return Base |
||
| 43 | */ |
||
| 44 | 4 | public function setManager(\Iris\Manager $manager) |
|
| 45 | { |
||
| 46 | 4 | $this->manager = $manager; |
|
| 47 | 4 | return $this; |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Converts an array of infrastructure to a business object. |
||
| 52 | * Here IRIS receives external shop data and converts it to its custom Transfer Object |
||
| 53 | * |
||
| 54 | * @param array $externalData |
||
| 55 | * @return \Iris\Transfer\Catalog\ConfigCollection |
||
| 56 | */ |
||
| 57 | abstract public function assign(array $externalData); |
||
| 58 | |||
| 59 | /** |
||
| 60 | * Converts a business object to an array. |
||
| 61 | * Here IRIS prepares data for external shop from its custom Transfer objects |
||
| 62 | * |
||
| 63 | * @param $internalData Transfer object |
||
| 64 | * @return array |
||
| 65 | */ |
||
| 66 | abstract public function map($internalData); |
||
| 67 | } |
||
| 68 |