-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Codappix\ResponsiveImages\Domain\Factory; | ||
|
||
/* | ||
* Copyright (C) 2024 Daniel Gohlke <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
use Codappix\ResponsiveImages\Configuration\ConfigurationManager; | ||
use Codappix\ResponsiveImages\Domain\Model\BackendLayout; | ||
use Codappix\ResponsiveImages\Domain\Model\RootlineElementInterface; | ||
|
||
class BackendLayoutFactory | ||
{ | ||
public function __construct( | ||
private ConfigurationManager $configurationManager, | ||
private readonly ScalingFactory $scalingFactory | ||
) { | ||
} | ||
|
||
public function create(string $configurationPath): RootlineElementInterface | ||
{ | ||
$scaling = $this->scalingFactory->getByConfigurationPath($configurationPath); | ||
|
||
$columns = $this->determineColumns($configurationPath . '.columns'); | ||
|
||
return new BackendLayout($scaling, $columns); | ||
} | ||
|
||
|
||
private function determineColumns(string $configurationPath): array | ||
{ | ||
$columns = $this->configurationManager->getByPath($configurationPath); | ||
assert(is_array($columns)); | ||
return array_map(static fn ($column): int => (int) $column, array_keys($columns)); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,9 +2,10 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace Codappix\ResponsiveImages\Sizes; | ||
namespace Codappix\ResponsiveImages\Domain\Factory; | ||
|
||
/* | ||
* Copyright (C) 2024 Justus Moroni <[email protected]> | ||
* Copyright (C) 2024 Daniel Gohlke <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
|
@@ -23,17 +24,30 @@ | |
* 02110-1301, USA. | ||
*/ | ||
|
||
final class Container extends AbstractContentElement | ||
use Codappix\ResponsiveImages\Configuration\ConfigurationManager; | ||
use Codappix\ResponsiveImages\Domain\Model\Container; | ||
|
||
class ContainerFactory | ||
{ | ||
public function __construct(array $data) | ||
public function __construct( | ||
private readonly ConfigurationManager $configurationManager | ||
Check failure on line 33 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.1, ^12.4)
Check failure on line 33 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.2, ^12.4)
|
||
) { | ||
} | ||
|
||
public function createFromData(array $data): Container | ||
{ | ||
parent::__construct($data); | ||
$this->contentType = $data['CType']; | ||
Check failure on line 39 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.1, ^12.4)
Check failure on line 39 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.2, ^12.4)
|
||
$this->colPos = $data['colPos']; | ||
Check failure on line 40 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.1, ^12.4)
Check failure on line 40 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.2, ^12.4)
|
||
|
||
$this->scalingConfiguration = $this->readConfigurationByPath( | ||
$scalingConfiguration = $this->readConfigurationByPath( | ||
Check failure on line 42 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.1, ^12.4)
Check failure on line 42 in Classes/Domain/Factory/ContainerFactory.php GitHub Actions / code-quality (8.2, ^12.4)
|
||
implode('.', [ | ||
'container', | ||
$this->contentType, | ||
]) | ||
); | ||
|
||
return new Container( | ||
$scalingConfiguration | ||
); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace Codappix\ResponsiveImages\Sizes; | ||
namespace Codappix\ResponsiveImages\Domain\Factory; | ||
|
||
/* | ||
* Copyright (C) 2024 Daniel Gohlke <[email protected]> | ||
|
@@ -23,21 +23,20 @@ | |
* 02110-1301, USA. | ||
*/ | ||
|
||
class ContainerColumn extends AbstractContentElement | ||
use Codappix\ResponsiveImages\Domain\Model\RootlineElement; | ||
use Codappix\ResponsiveImages\Domain\Model\RootlineElementInterface; | ||
|
||
class RootlineElementFactory | ||
{ | ||
public function __construct( | ||
array $data, | ||
int $colPos | ||
private readonly ScalingFactory $scalingFactory | ||
) { | ||
parent::__construct($data); | ||
} | ||
|
||
public function create(array $data, string $configurationPath): RootlineElementInterface | ||
{ | ||
$scaling = $this->scalingFactory->getByConfigurationPath($configurationPath); | ||
|
||
$this->scalingConfiguration = $this->readConfigurationByPath( | ||
implode('.', [ | ||
'container', | ||
$this->contentType, | ||
'columns', | ||
(string) $colPos, | ||
]) | ||
); | ||
return new RootlineElement($scaling, $data); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,10 +2,11 @@ | |
|
||
declare(strict_types=1); | ||
|
||
namespace Codappix\ResponsiveImages\Sizes; | ||
namespace Codappix\ResponsiveImages\Domain\Factory; | ||
|
||
/* | ||
* Copyright (C) 2020 Justus Moroni <[email protected]> | ||
* Copyright (C) 2024 Justus Moroni <[email protected]> | ||
* Copyright (C) 2024 Daniel Gohlke <[email protected]> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
|
@@ -23,26 +24,23 @@ | |
* 02110-1301, USA. | ||
*/ | ||
|
||
final class BackendLayoutColumn extends AbstractRootlineElement implements RootlineElementInterface | ||
use Codappix\ResponsiveImages\Configuration\ConfigurationManager; | ||
use Codappix\ResponsiveImages\Domain\Model\Scaling; | ||
|
||
final class ScalingFactory | ||
{ | ||
public function __construct( | ||
protected string $identifier, | ||
protected int $column | ||
private ConfigurationManager $configurationManager | ||
) { | ||
parent::__construct(); | ||
|
||
$this->scalingConfiguration = $this->readConfigurationByPath( | ||
implode('.', [ | ||
'backendlayouts', | ||
$this->identifier, | ||
'columns', | ||
(string) $this->column, | ||
]) | ||
); | ||
} | ||
|
||
public function getColumn(): int | ||
public function getByConfigurationPath(string $configurationPath): Scaling | ||
{ | ||
return $this->column; | ||
$configuration = $this->configurationManager->getByPath($configurationPath); | ||
|
||
$multiplier = $configuration['multiplier'] ?? []; | ||
Check failure on line 41 in Classes/Domain/Factory/ScalingFactory.php GitHub Actions / code-quality (8.1, ^12.4)
Check failure on line 41 in Classes/Domain/Factory/ScalingFactory.php GitHub Actions / code-quality (8.2, ^12.4)
|
||
$sizes = $configuration['sizes'] ?? []; | ||
|
||
return new Scaling($multiplier, $sizes); | ||
} | ||
} |