setName('dependencies:add-text') ->setDescription('Adds a static text dependency to the specification of a class.') ->addArgument('coid-target', InputArgument::REQUIRED, 'The COID of the target class.') ->addArgument('key', InputArgument::REQUIRED, 'The key for dependency injection.') ->addArgument('value', InputArgument::REQUIRED, 'The text value.'); parent::configure(); } protected function execute(InputInterface $input, OutputInterface $output) { $this->requireCloudObjectsCLI(); $this->parse($input->getArgument('coid-target')); $this->assertRDF(); $this->dependencyPrecheck(); // Add dependency $this->addDependency( $input->getArgument('key'), 'coid://phpmae.dev/StaticTextDependency', [ 'coid://phpmae.dev/hasValue' => [ [ 'type' => 'literal', 'value' => $input->getArgument('value') ] ] ], $input, $output ); // Print documentation $key = $input->getArgument('key'); $output->writeln(""); $output->writeln("Use your static text dependency:"); $output->writeln(""); $output->writeln("1) Make sure you have access to the dependency injection container by adding the container to your class constructor."); $output->writeln("2) Request the value string from the container using the key \"".$key."\"."); $output->writeln(""); $output->writeln(" private \$".$key.";"); $output->writeln(""); $output->writeln(" public function __construct(\Psr\Container\ContainerInterface \$container) {"); $output->writeln(" \$this->".$key." = \$container->get('".$key."');"); $output->writeln(" }"); $output->writeln(""); $output->writeln("3) Use \$this->".$key." wherever required."); $output->writeln(""); } }