modify
This commit is contained in:
@@ -203,13 +203,4 @@ class Annotation extends Component
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $filename
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getFilename(string $filename): mixed
|
|
||||||
{
|
|
||||||
return $this->_loader->getClassByFilepath($filename);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,6 @@ class Loader extends BaseObject
|
|||||||
private array $_classes = [];
|
private array $_classes = [];
|
||||||
|
|
||||||
|
|
||||||
private array $_fileMap = [];
|
|
||||||
|
|
||||||
|
|
||||||
private array $_directory = [];
|
private array $_directory = [];
|
||||||
|
|
||||||
|
|
||||||
@@ -178,8 +175,6 @@ class Loader extends BaseObject
|
|||||||
$_array = $this->_methods($replace, $_array);
|
$_array = $this->_methods($replace, $_array);
|
||||||
$_array = $this->_properties($replace, $_array);
|
$_array = $this->_properties($replace, $_array);
|
||||||
|
|
||||||
$this->_fileMap[$replace->getFileName()] = $replace->getName();
|
|
||||||
|
|
||||||
$this->_classes[$replace->getName()] = $_array;
|
$this->_classes[$replace->getName()] = $_array;
|
||||||
} catch (Throwable $throwable) {
|
} catch (Throwable $throwable) {
|
||||||
$this->addError($throwable, 'throwable');
|
$this->addError($throwable, 'throwable');
|
||||||
@@ -320,19 +315,6 @@ class Loader extends BaseObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $filename
|
|
||||||
* @return mixed
|
|
||||||
*/
|
|
||||||
public function getClassByFilepath(string $filename): mixed
|
|
||||||
{
|
|
||||||
if (!isset($this->_fileMap[$filename])) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return $this->_classes[$this->_fileMap[$filename]];
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param array $classes
|
* @param array $classes
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -115,56 +115,6 @@ if (!function_exists('swoole')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!function_exists('recursive_directory')) {
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param DirectoryIterator $file
|
|
||||||
* @throws Exception
|
|
||||||
*/
|
|
||||||
function recursive_callback(DirectoryIterator $file)
|
|
||||||
{
|
|
||||||
$attributes = Snowflake::getAnnotation();
|
|
||||||
|
|
||||||
$annotations = $attributes->getFilename($file->getRealPath());
|
|
||||||
if (empty($annotations)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** @var Attribute $value */
|
|
||||||
foreach ($annotations['methods'] as $name => $attribute) {
|
|
||||||
foreach ($attribute as $value) {
|
|
||||||
if (!($value instanceof Attribute)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$value->execute([$annotations['handler'], $name]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $path
|
|
||||||
*/
|
|
||||||
function recursive_directory(string $path)
|
|
||||||
{
|
|
||||||
$directoryIterators = new \DirectoryIterator($path);
|
|
||||||
foreach ($directoryIterators as $directoryIterator) {
|
|
||||||
if ($directoryIterator->getFilename() === '.' || $directoryIterator->getFilename() === '..') {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($directoryIterator->isDir()) {
|
|
||||||
Recursive_directory($directoryIterator->getRealPath());
|
|
||||||
} else {
|
|
||||||
call_user_func('recursive_callback', $directoryIterator);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
unset($directoryIterators);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (!function_exists('directory')) {
|
if (!function_exists('directory')) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user