first commit
This commit is contained in:
42
bundles/KupShop/GraphQLBundle/ApiAdmin/Annotation/Module.php
Normal file
42
bundles/KupShop/GraphQLBundle/ApiAdmin/Annotation/Module.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace KupShop\GraphQLBundle\ApiAdmin\Annotation;
|
||||
|
||||
use Attribute;
|
||||
use TheCodingMachine\GraphQLite\Annotations\MiddlewareAnnotationInterface;
|
||||
|
||||
/**
|
||||
* @Annotation
|
||||
* @Target({"CLASS", "PROPERTY", "METHOD"})
|
||||
*
|
||||
* @Attributes({
|
||||
*
|
||||
* @Attribute("name", type = "string"),
|
||||
* @Attribute("submodule", type = "string"),
|
||||
* })
|
||||
*/
|
||||
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
|
||||
class Module implements MiddlewareAnnotationInterface
|
||||
{
|
||||
public string $module;
|
||||
public ?string $submodule;
|
||||
public bool $constants = false;
|
||||
|
||||
public function __construct(string|array $module, ?string $submodule = null)
|
||||
{
|
||||
if (is_array($module)) {
|
||||
$module = $module['value'] ?? $module['module'] ?? '';
|
||||
$submodule = $module['submodule'] ?? $submodule;
|
||||
$this->constants = true;
|
||||
}
|
||||
|
||||
if (empty($module)) {
|
||||
throw new \BadMethodCallException('The @Module annotation must be passed a module attribute!');
|
||||
}
|
||||
|
||||
$this->module = $module;
|
||||
$this->submodule = $submodule;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user