24 lines
780 B
PHP
24 lines
780 B
PHP
<?php
|
|
namespace Core\annotationhandlers;
|
|
|
|
use Core\annotations\Bean;
|
|
use Core\annotations\Value;
|
|
|
|
return [
|
|
Bean::class => function ($instance, $container, $self) {
|
|
$vars = get_object_vars($self);
|
|
if (isset($vars['name']) && !empty($vars['name'])){
|
|
$beanName = $vars['name'];
|
|
}else{
|
|
$arrs = explode('\\',get_class($instance));
|
|
$beanName = end($arrs);
|
|
}
|
|
$container->set($beanName,$instance);
|
|
},
|
|
Value::class => function (\ReflectionProperty $property, $instance, $self) {
|
|
$env = parse_ini_file(ROOT_PATH.'/.env');
|
|
if (!isset($env[$self->name]) || empty($self->name)) return $instance;
|
|
$property->setValue($instance,$env[$self->name]);
|
|
return $instance;
|
|
}
|
|
]; |