1
|
|
|
<?php |
2
|
|
|
/******************************************************************************* |
3
|
|
|
* This file is part of the GraphQL Bundle package. |
4
|
|
|
* |
5
|
|
|
* (c) YnloUltratech <[email protected]> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
******************************************************************************/ |
10
|
|
|
|
11
|
|
|
namespace Ynlo\GraphQLBundle\Definition\Extension; |
12
|
|
|
|
13
|
|
|
use Doctrine\Common\Util\Inflector; |
14
|
|
|
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
15
|
|
|
use Ynlo\GraphQLBundle\Definition\DefinitionInterface; |
16
|
|
|
use Ynlo\GraphQLBundle\Definition\Registry\Endpoint; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* AbstractDefinitionExtension |
20
|
|
|
*/ |
21
|
|
|
abstract class AbstractDefinitionExtension implements DefinitionExtensionInterface |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* {@inheritDoc} |
25
|
|
|
*/ |
26
|
|
|
public function getName(): string |
27
|
|
|
{ |
28
|
|
|
$name = get_class($this); |
29
|
|
|
preg_match('/(\w+)$/', $name, $matches); |
30
|
|
|
$name = preg_replace('/Extension$/', null, $matches[1]); |
31
|
|
|
$name = preg_replace('/Definition$/', null, $name); |
32
|
|
|
|
33
|
|
|
return Inflector::tableize($name); |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* {@inheritDoc} |
38
|
|
|
*/ |
39
|
|
|
public function buildConfig(ArrayNodeDefinition $root) |
40
|
|
|
{ |
41
|
|
|
|
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* {@inheritDoc} |
46
|
|
|
*/ |
47
|
|
|
public function normalizeConfig(DefinitionInterface $definition, $config): array |
48
|
|
|
{ |
49
|
|
|
if (is_bool($config)) { |
50
|
|
|
$config = ['enabled' => $config]; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
return $config; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritDoc} |
58
|
|
|
*/ |
59
|
|
|
public function configure(DefinitionInterface $definition, Endpoint $endpoint, array $config) |
60
|
|
|
{ |
61
|
|
|
// TODO: Implement configure() method. |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* {@inheritDoc} |
66
|
|
|
*/ |
67
|
|
|
public function configureEndpoint(Endpoint $endpoint) |
68
|
|
|
{ |
69
|
|
|
// TODO: Implement configureEndpoint() method. |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|