43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?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;
|
|
}
|
|
}
|