Skip to content

Commit f0a45c7

Browse files
authored
[Task] Add resolver for GroupConfig and DefinitionCache (#72)
* add resolver for config group and cs cache resolver * Apply php-cs-fixer changes * fix: methods are not static --------- Co-authored-by: lukmzig <[email protected]>
1 parent e23076f commit f0a45c7

File tree

4 files changed

+152
-0
lines changed

4 files changed

+152
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Pimcore
6+
*
7+
* This source file is available under two different licenses:
8+
* - GNU General Public License version 3 (GPLv3)
9+
* - Pimcore Commercial License (PCL)
10+
* Full copyright and license information is available in
11+
* LICENSE.md which is distributed with this source code.
12+
*
13+
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
14+
* @license http://www.pimcore.org/license GPLv3 and PCL
15+
*/
16+
17+
namespace Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassificationStore;
18+
19+
use Pimcore\Model\DataObject\Classificationstore\GroupConfig;
20+
use Pimcore\Model\DataObject\Classificationstore\KeyConfig;
21+
22+
interface DefinitionCacheResolverInterface
23+
{
24+
public function get(
25+
int $id,
26+
string $type = 'key'
27+
): ?KeyConfig;
28+
29+
public function put(GroupConfig|KeyConfig $config): void;
30+
31+
public function clear(GroupConfig|KeyConfig|null $config): void;
32+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Pimcore
6+
*
7+
* This source file is available under two different licenses:
8+
* - GNU General Public License version 3 (GPLv3)
9+
* - Pimcore Commercial License (PCL)
10+
* Full copyright and license information is available in
11+
* LICENSE.md which is distributed with this source code.
12+
*
13+
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
14+
* @license http://www.pimcore.org/license GPLv3 and PCL
15+
*/
16+
17+
namespace Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassificationStore;
18+
19+
use Pimcore\Model\DataObject\Classificationstore\DefinitionCache;
20+
use Pimcore\Model\DataObject\Classificationstore\GroupConfig;
21+
use Pimcore\Model\DataObject\Classificationstore\KeyConfig;
22+
23+
/**
24+
* @internal
25+
*/
26+
final class DefinitionCacheResolverResolver implements DefinitionCacheResolverInterface
27+
{
28+
public function get(
29+
int $id,
30+
string $type = 'key'
31+
): ?KeyConfig {
32+
return DefinitionCache::get($id, $type);
33+
}
34+
35+
public function put(GroupConfig|KeyConfig $config): void
36+
{
37+
DefinitionCache::put($config);
38+
}
39+
40+
public function clear(GroupConfig|KeyConfig|null $config): void
41+
{
42+
DefinitionCache::clear($config);
43+
}
44+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Pimcore
6+
*
7+
* This source file is available under two different licenses:
8+
* - GNU General Public License version 3 (GPLv3)
9+
* - Pimcore Commercial License (PCL)
10+
* Full copyright and license information is available in
11+
* LICENSE.md which is distributed with this source code.
12+
*
13+
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
14+
* @license http://www.pimcore.org/license GPLv3 and PCL
15+
*/
16+
17+
namespace Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassificationStore;
18+
19+
use Exception;
20+
use Pimcore\Model\DataObject\Classificationstore\GroupConfig;
21+
22+
/**
23+
* @internal
24+
*/
25+
final class GroupConfigResolver implements GroupConfigResolverInterface
26+
{
27+
public function getById(int $id, ?bool $force = false): ?GroupConfig
28+
{
29+
return GroupConfig::getById($id, $force);
30+
}
31+
32+
/**
33+
* @throws Exception
34+
*/
35+
public function getByName(string $name, int $storeId = 1, ?bool $force = false): ?GroupConfig
36+
{
37+
return GroupConfig::getByName($name, $storeId, $force);
38+
}
39+
40+
public function create(): GroupConfig
41+
{
42+
return GroupConfig::create();
43+
}
44+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?php
2+
declare(strict_types=1);
3+
4+
/**
5+
* Pimcore
6+
*
7+
* This source file is available under two different licenses:
8+
* - GNU General Public License version 3 (GPLv3)
9+
* - Pimcore Commercial License (PCL)
10+
* Full copyright and license information is available in
11+
* LICENSE.md which is distributed with this source code.
12+
*
13+
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org)
14+
* @license http://www.pimcore.org/license GPLv3 and PCL
15+
*/
16+
17+
namespace Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ClassificationStore;
18+
19+
use Exception;
20+
use Pimcore\Model\DataObject\Classificationstore\GroupConfig;
21+
22+
interface GroupConfigResolverInterface
23+
{
24+
public function getById(int $id, ?bool $force = false): ?GroupConfig;
25+
26+
/**
27+
* @throws Exception
28+
*/
29+
public function getByName(string $name, int $storeId = 1, ?bool $force = false): ?GroupConfig;
30+
31+
public function create(): GroupConfig;
32+
}

0 commit comments

Comments
 (0)