- Removing annotations replaced by attributes
This commit is contained in:
parent
66a9345e06
commit
1337e778ed
|
@ -6,7 +6,7 @@
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
"name": "Dave Mc Nicoll",
|
"name": "Dave Mc Nicoll",
|
||||||
"email": "mcndave@gmail.com"
|
"email": "info@mcnd.ca"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
|
|
|
@ -6,8 +6,7 @@ use Taxus\Taxus;
|
||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
|
||||||
use Notes\ObjectReflection,
|
use Notes\ObjectResolver;
|
||||||
Notes\ObjectResolver;
|
|
||||||
|
|
||||||
class SecurityHandler {
|
class SecurityHandler {
|
||||||
|
|
||||||
|
@ -26,7 +25,7 @@ class SecurityHandler {
|
||||||
public function verify(string $className, string $methodName) : ? ResponseInterface
|
public function verify(string $className, string $methodName) : ? ResponseInterface
|
||||||
{
|
{
|
||||||
# Should generate an equivalent of Ulmus's object reflection here !
|
# Should generate an equivalent of Ulmus's object reflection here !
|
||||||
if ( $security = $this->getClassAnnotations(Annotation\Security::class, $className, $methodName) ) {
|
if ( $security = $this->getClassAttributes(Attribute\Security::class, $className, $methodName) ) {
|
||||||
return array_pop($security)->locked ? $this->redirectResponse : null;
|
return array_pop($security)->locked ? $this->redirectResponse : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +34,7 @@ class SecurityHandler {
|
||||||
|
|
||||||
public function taxus(string $className, string $methodName, object $user = null) : ? ResponseInterface
|
public function taxus(string $className, string $methodName, object $user = null) : ? ResponseInterface
|
||||||
{
|
{
|
||||||
if ($taxus = $this->getClassAnnotations(Annotation\Taxus::class, $className, $methodName)) {
|
if ($taxus = $this->getClassAttributes(Attribute\Taxus::class, $className, $methodName)) {
|
||||||
if ($this->unauthorizeResponse) {
|
if ($this->unauthorizeResponse) {
|
||||||
foreach ($taxus as $item) {
|
foreach ($taxus as $item) {
|
||||||
if (!isset($item->privilege) || $this->taxus->granted($item->privilege, $user, $item)) {
|
if (!isset($item->privilege) || $this->taxus->granted($item->privilege, $user, $item)) {
|
||||||
|
@ -53,12 +52,12 @@ class SecurityHandler {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getClassAnnotations(string $annotationClass, string $className, string $methodName)/* : \Notes\Annotation|array */
|
protected function getClassAttributes(string $annotationClass, string $className, string $methodName)/* : \Notes\Annotation|array */
|
||||||
{
|
{
|
||||||
$objectResolver = new ObjectResolver($className, true, true, false, true);
|
$objectResolver = new ObjectResolver($className, true, true, false, true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$method = $objectResolver->getAnnotationListFromClassname( $annotationClass, false );
|
$method = $objectResolver->getAttributeListFromClassname( $annotationClass, false );
|
||||||
}
|
}
|
||||||
catch(\Exception $e) { }
|
catch(\Exception $e) { }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue