Skip to content

Commit

Permalink
support 8.2+
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Surkov committed Apr 12, 2023
1 parent f966b95 commit 94b4edf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "symbiotic/full",
"description": "Complete assembly of the SymbioticPHP framework with a cached container and optimized core services",
"license": ["BSD-3-Clause"],
"version": "1.4.1.4",
"version": "1.4.2",
"homepage": "https://symbioticphp.com",
"authors": [
{
Expand Down
6 changes: 5 additions & 1 deletion src/Container/CachedContainerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Closure;

interface CachedContainerInterface extends DIContainerInterface, \Serializable
interface CachedContainerInterface extends DIContainerInterface
{
/**
* Allows caching of the service in the container
Expand All @@ -31,4 +31,8 @@ public function cached(string $abstract, Closure|string $concrete = null, string
* @return void
*/
public function markAsCached(string $abstract): void;

public function __serialize(): array;

public function __unserialize(array $data): void;
}
10 changes: 5 additions & 5 deletions src/Container/CachedContainerTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ protected function getSerializeData(): array
*
* @see \Serializable::serialize()
*/
public function serialize(): string
public function __serialize(): array
{
return \serialize($this->getSerializeData());
return $this->getSerializeData();
}

/**
Expand All @@ -121,9 +121,9 @@ public function serialize(): string
*
* @see \Serializable::unserialize()
*/
public function unserialize($serialized): void
public function __unserialize(array $data): void
{
$data = \unserialize($serialized, ['allowed_classes' => true]);

$this->cache = $data['cache'];
$this->key = $data['key'];
foreach ($data['instances'] as $k => $instance) {
Expand All @@ -149,7 +149,7 @@ public function __destruct()
*/
if ($this->cache) {
if (!$this->cache->has($this->key) && !$this->has('cache_cleaned')) {
$this->cache->set($this->key, $this, 60 * 60);
$this->cache->set($this->key, \serialize($this), 60 * 60);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/Core/ContainerBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public function buildCore(array $config, string $key = null)
if ($core === $time) {
$core = new CachedCore($config);
$core->setCache($this->cache, $key);
} else {
$core = \unserialize($core, ['allowed_classes' => true]);
}
} else {
$core = new Core($config);
Expand Down

0 comments on commit 94b4edf

Please sign in to comment.