Skip to content

Commit ede649e

Browse files
authored
Merge pull request #93 from pimcore/add-lib-contracts
Pull up non-internal functions into Contracts
2 parents 31caf3d + b889a3d commit ede649e

33 files changed

+904
-240
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
services:
22
php-static-resolver-bundle:
3-
image: pimcore/pimcore:php8.2-debug-dev
3+
image: pimcore/pimcore:php8.4-debug-v4-dev
44
environment:
55
PHP_IDE_CONFIG: serverName=localhost
66
volumes:
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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\Contract\Lib\Cache;
18+
19+
use Pimcore\Cache\RuntimeCache;
20+
21+
class RuntimeCacheResolverContract implements RuntimeCacheResolverContractInterface
22+
{
23+
public function load(string $id): mixed
24+
{
25+
return RuntimeCache::load($id);
26+
}
27+
28+
public function save(mixed $data, string $id): void
29+
{
30+
RuntimeCache::save($data, $id);
31+
}
32+
33+
public function isRegistered(string $index): bool
34+
{
35+
return RuntimeCache::isRegistered($index);
36+
}
37+
38+
public function clear(array $keepItems = []): void
39+
{
40+
RuntimeCache::clear($keepItems);
41+
}
42+
43+
/**
44+
* @throws \Exception
45+
*/
46+
public function get(string $index): mixed
47+
{
48+
return RuntimeCache::get($index);
49+
}
50+
51+
public function set(string $index, mixed $value): void
52+
{
53+
RuntimeCache::set($index, $value);
54+
}
55+
56+
public function enable(): void
57+
{
58+
RuntimeCache::enable();
59+
}
60+
61+
public function disable(): void
62+
{
63+
RuntimeCache::disable();
64+
}
65+
66+
public function isEnabled(): bool
67+
{
68+
return RuntimeCache::isEnabled();
69+
}
70+
71+
public function getInstance(): RuntimeCache
72+
{
73+
return RuntimeCache::getInstance();
74+
}
75+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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\Contract\Lib\Cache;
18+
19+
use Pimcore\Cache\RuntimeCache;
20+
21+
interface RuntimeCacheResolverContractInterface
22+
{
23+
public function load(string $id): mixed;
24+
25+
public function save(mixed $data, string $id): void;
26+
27+
public function isRegistered(string $index): bool;
28+
29+
public function clear(array $keepItems = []): void;
30+
31+
/**
32+
* @throws \Exception
33+
*/
34+
public function get(string $index): mixed;
35+
36+
public function set(string $index, mixed $value): void;
37+
38+
public function enable(): void;
39+
40+
public function disable(): void;
41+
42+
public function isEnabled(): bool;
43+
44+
public function getInstance(): RuntimeCache;
45+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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\Contract\Lib;
18+
19+
use DateInterval;
20+
use Pimcore\Cache;
21+
22+
class CacheResolverContract implements CacheResolverContractInterface
23+
{
24+
public function load(string $key): mixed
25+
{
26+
return Cache::load($key);
27+
}
28+
29+
public function remove(string $key): bool
30+
{
31+
return Cache::remove($key);
32+
}
33+
34+
public function clearAll(): bool
35+
{
36+
return Cache::clearAll();
37+
}
38+
39+
public function clearTag(string $tag): bool
40+
{
41+
return Cache::clearTag($tag);
42+
}
43+
44+
public function disable(): void
45+
{
46+
Cache::disable();
47+
}
48+
49+
public function save(
50+
mixed $data,
51+
string $key,
52+
array $tags = [],
53+
DateInterval|int|null $lifetime = null,
54+
int $priority = 0,
55+
bool $force = false
56+
): void {
57+
Cache::save($data, $key, $tags, $lifetime, $priority, $force);
58+
}
59+
60+
public function isEnabled(): bool
61+
{
62+
return Cache::isEnabled();
63+
}
64+
65+
public function enable(): void
66+
{
67+
Cache::enable();
68+
}
69+
70+
public function clearTags(array $tag = []): bool
71+
{
72+
return Cache::clearTags($tag);
73+
}
74+
75+
public function addClearTagOnShutdown(string $tag): void
76+
{
77+
Cache::addClearTagOnShutdown($tag);
78+
}
79+
80+
public function addIgnoredTagOnSave(string $tag): void
81+
{
82+
Cache::addIgnoredTagOnSave($tag);
83+
}
84+
85+
public function removeIgnoredTagOnSave(string $tag): void
86+
{
87+
Cache::removeIgnoredTagOnSave($tag);
88+
}
89+
90+
public function addIgnoredTagOnClear(string $tag): void
91+
{
92+
Cache::addIgnoredTagOnClear($tag);
93+
}
94+
95+
public function removeIgnoredTagOnClear(string $tag): void
96+
{
97+
Cache::removeIgnoredTagOnClear($tag);
98+
}
99+
100+
public function setForceImmediateWrite(bool $force): void
101+
{
102+
Cache::setForceImmediateWrite($force);
103+
}
104+
105+
public function getForceImmediateWrite(): bool
106+
{
107+
return Cache::getForceImmediateWrite();
108+
}
109+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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\Contract\Lib;
18+
19+
use DateInterval;
20+
21+
interface CacheResolverContractInterface
22+
{
23+
public function load(string $key): mixed;
24+
25+
public function remove(string $key): bool;
26+
27+
public function clearAll(): bool;
28+
29+
public function clearTag(string $tag): bool;
30+
31+
public function disable(): void;
32+
33+
public function save(
34+
mixed $data,
35+
string $key,
36+
array $tags = [],
37+
DateInterval|int|null $lifetime = null,
38+
int $priority = 0,
39+
bool $force = false
40+
): void;
41+
42+
public function isEnabled(): bool;
43+
44+
public function enable(): void;
45+
46+
public function clearTags(array $tag = []): bool;
47+
48+
public function addClearTagOnShutdown(string $tag): void;
49+
50+
public function addIgnoredTagOnSave(string $tag): void;
51+
52+
public function removeIgnoredTagOnSave(string $tag): void;
53+
54+
public function addIgnoredTagOnClear(string $tag): void;
55+
56+
public function removeIgnoredTagOnClear(string $tag): void;
57+
58+
public function setForceImmediateWrite(bool $force): void;
59+
60+
public function getForceImmediateWrite(): bool;
61+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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\Contract\Lib;
18+
19+
use Pimcore\Config;
20+
21+
class ConfigResolverContract implements ConfigResolverContractInterface
22+
{
23+
public function getWebsiteConfigValue(
24+
?string $key = null,
25+
mixed $default = null,
26+
?string $language = null
27+
): mixed {
28+
return Config::getWebsiteConfigValue($key, $default, $language);
29+
}
30+
31+
public function getWebsiteConfig(?string $language = null): array
32+
{
33+
return Config::getWebsiteConfig($language);
34+
}
35+
36+
public function getEnvironment(): string
37+
{
38+
return Config::getEnvironment();
39+
}
40+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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\Contract\Lib;
18+
19+
interface ConfigResolverContractInterface
20+
{
21+
public function getEnvironment(): string;
22+
23+
public function getWebsiteConfigValue(?string $key = null, mixed $default = null, ?string $language = null): mixed;
24+
25+
public function getWebsiteConfig(?string $language = null): array;
26+
}

0 commit comments

Comments
 (0)