eee
This commit is contained in:
+18
-6
@@ -9,6 +9,7 @@ use Kiri\Di\Inject\Container;
|
|||||||
use Kiri\Abstracts\Component;
|
use Kiri\Abstracts\Component;
|
||||||
use Kiri\Di\Inject\Skip;
|
use Kiri\Di\Inject\Skip;
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
use ReflectionClass;
|
||||||
use ReflectionMethod;
|
use ReflectionMethod;
|
||||||
|
|
||||||
class Scanner extends Component
|
class Scanner extends Component
|
||||||
@@ -92,12 +93,8 @@ class Scanner extends Component
|
|||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
$reflect = $this->container->getReflectionClass($class);
|
$reflect = $this->container->getReflectionClass($class);
|
||||||
if ($reflect->isInstantiable()) {
|
if ($reflect->isInstantiable()) {
|
||||||
$data = $reflect->getAttributes(Skip::class);
|
$attributes = $this->skipNames($reflect);
|
||||||
if (count($data) > 0) {
|
if (in_array(Skip::class, $attributes) || in_array(\Attribute::class, $attributes)) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
$data = $reflect->getAttributes(\Attribute::class);
|
|
||||||
if (count($data) > 0) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$object = $this->container->parse($class);
|
$object = $this->container->parse($class);
|
||||||
@@ -117,4 +114,19 @@ class Scanner extends Component
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param ReflectionClass $reflect
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
protected function skipNames(ReflectionClass $reflect): array
|
||||||
|
{
|
||||||
|
$attributes = $reflect->getAttributes();
|
||||||
|
$names = [];
|
||||||
|
foreach ($attributes as $attribute) {
|
||||||
|
$names[] = $attribute->getName();
|
||||||
|
}
|
||||||
|
return $names;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user