Skip to content

Commit

Permalink
=
Browse files Browse the repository at this point in the history
  • Loading branch information
Arikaim committed May 17, 2024
1 parent a376071 commit 03b6aa6
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions Extension/Modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,19 @@

use Arikaim\Core\Utils\Factory;
use Arikaim\Core\Db\Model;
use Arikaim\Core\Interfaces\CacheInterface;
use Arikaim\Core\Interfaces\ModuleInterface;

/**
* Modules service locator
*/
class Modules
{
/**
* Cache
*
* @var CacheInterface
*/
private $cache;

/**
* Constructor
*
* @param CacheInterface $cache
*/
public function __construct(CacheInterface $cache)
public function __construct()
{
$this->cache = $cache;
}

/**
Expand All @@ -44,11 +34,13 @@ public function __construct(CacheInterface $cache)
*/
public function create(string $name)
{
$module = $this->cache->fetch('module.' . $name);
global $arikaim;

$module = $arikaim->get('cache')->fetch('module.' . $name);
if ($module === false) {
$module = Model::Modules()->getPackage($name);
if ($module !== false) {
$this->cache->save('module.' . $name,$module,5);
$arikaim->get('cache')->save('module.' . $name,$module,5);
}
}

Expand All @@ -73,7 +65,9 @@ public function create(string $name)
*/
public function hasModule(string $name): bool
{
$module = $this->cache->fetch('module.' . $name);
global $arikaim;

$module = $arikaim->get('cache')->fetch('module.' . $name);
if ($module === false) {
$module = Model::Modules()->getPackage($name);
}
Expand Down

0 comments on commit 03b6aa6

Please sign in to comment.