43 lines
1.0 KiB
PHP
43 lines
1.0 KiB
PHP
<?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) {
|
||
|
|
$instance = $this->getModule($module);
|
||
|
|
$rfxn = new ReflectionClass($instance);
|
||
|
|
if ($rfxn->isAnonymous()) {
|
||
|
|
unset($this[$module]);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|