2020-06-03 12:28:52 -04:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
/**
|
|
|
|
|
* Copyright (C) Apis Networks, Inc - All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Unauthorized copying of this file, via any medium, is
|
|
|
|
|
* strictly prohibited without consent. Any dissemination of
|
|
|
|
|
* material herein is prohibited.
|
|
|
|
|
*
|
|
|
|
|
* For licensing inquiries email <licensing@apisnetworks.com>
|
|
|
|
|
*
|
|
|
|
|
* Written by Matt Saladna <matt@apisnetworks.com>, June 2020
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
class ModuleCache extends ArrayObject
|
|
|
|
|
{
|
|
|
|
|
const TYPE_PERMISSION = 'p';
|
|
|
|
|
const TYPE_MINARG = 'm';
|
|
|
|
|
const TYPE_MAXARG = 'q';
|
|
|
|
|
const TYPE_FUNCTIONS = 'f';
|
|
|
|
|
const TYPE_INSTANCE = 'i';
|
|
|
|
|
|
|
|
|
|
public function getModule(string $module): \Module_Skeleton
|
|
|
|
|
{
|
|
|
|
|
return $this[$module][self::TYPE_INSTANCE];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function serialize()
|
|
|
|
|
{
|
|
|
|
|
$this->cleanDynamicCompositions();
|
|
|
|
|
return parent::serialize();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function cleanDynamicCompositions(): void
|
|
|
|
|
{
|
|
|
|
|
foreach ($this->getIterator() as $module => $data) {
|
2020-06-05 12:13:01 -04:00
|
|
|
if (empty($data[self::TYPE_INSTANCE])) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2020-06-03 12:28:52 -04:00
|
|
|
$instance = $this->getModule($module);
|
|
|
|
|
$rfxn = new ReflectionClass($instance);
|
|
|
|
|
if ($rfxn->isAnonymous()) {
|
|
|
|
|
unset($this[$module]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|