11<?php
2- /**
3- * @copyright Copyright (C) eZ Systems AS. All rights reserved.
4- * @license For full copyright and license information view LICENSE file distributed with this source code.
5- */
62namespace BD \EzPlatformGraphQLBundle \Command ;
73
84use BD \EzPlatformGraphQLBundle \Schema \SchemaGenerator ;
95use eZ \Publish \API \Repository \Repository ;
10- use Symfony \Component \Console \Command \Command ;
116use Symfony \Component \Console \Input \InputInterface ;
12- use Symfony \Component \Console \Input \InputOption ;
137use Symfony \Component \Console \Output \OutputInterface ;
14- use Symfony \Component \Filesystem \Filesystem ;
15- use Symfony \Component \Yaml \Yaml ;
168
17- class GeneratePlatformDomainTypesCommand extends Command
9+ /**
10+ * @deprecated replaced by ezplatform:graphql:generate-schema
11+ */
12+ class GeneratePlatformDomainTypesCommand extends GeneratePlatformSchemaCommand
1813{
19- /**
20- * @var \eZ\Publish\API\Repository\Repository
21- */
22- private $ repository ;
23-
24- /**
25- * @var \BD\EzPlatformGraphQLBundle\Schema\SchemaGenerator
26- */
27- private $ generator ;
28-
29- const TYPES_DIRECTORY = "src/AppBundle/Resources/config/graphql " ;
30-
3114 public function __construct (Repository $ repository , SchemaGenerator $ generator )
3215 {
33- parent ::__construct ();
34- $ this ->repository = $ repository ;
35- $ this ->generator = $ generator ;
16+ parent ::__construct ($ repository , $ generator );
3617 }
3718
3819 protected function configure ()
3920 {
40- $ this
41- ->setName ('bd:platform-graphql:generate-domain-schema ' )
42- ->addOption ('dry-run ' , null , InputOption::VALUE_OPTIONAL , '' , false )
43- ->addOption ('include ' , null , InputOption::VALUE_REQUIRED |InputOption::VALUE_IS_ARRAY , '' , []);
21+ parent ::configure ();
22+
23+ $ this ->setName ('bd:platform-graphql:generate-domain-schema ' );
4424 }
4525
4626 protected function execute (InputInterface $ input , OutputInterface $ output )
4727 {
48- $ schema = $ this -> generator -> generate ();
49-
50- $ include = $ input -> getOption ( ' include ' );
51- $ doWrite = $ input -> getOption ( ' dry-run ' ) === false ;
28+ @ trigger_error (
29+ " The command name bd:platform-graphql:generate-domain-schema is deprecated. Use ezplatform:graphql:generate-schema instead. " ,
30+ E_USER_DEPRECATED
31+ ) ;
5232
53- $ fs = new Filesystem ();
54- foreach ($ schema as $ type => $ definition ) {
55- if (count ($ include ) && !in_array ($ type , $ include )) {
56- continue ;
57- }
58- $ typeFilePath = self ::TYPES_DIRECTORY . "/ $ type.types.yml " ;
33+ parent ::execute ($ input , $ output );
5934
60- $ yaml = Yaml::dump ([$ type => $ definition ], 6 );
61- if ($ doWrite ) {
62- $ fs ->dumpFile ($ typeFilePath , $ yaml );
63- $ output ->writeln ("Written $ typeFilePath " );
64- } else {
65- $ output ->writeln ("\n# $ type \n$ yaml \n" );
66- }
67- }
35+ $ output ->writeln (
36+ '<error>The command name bd:platform-graphql:generate-domain-schema is deprecated. Use ezplatform:graphql:generate-schema instead.</error> '
37+ );
6838 }
69- }
39+ }
0 commit comments