setName('sharing:add-share-source') ->setDescription('Add a new source to a share.') ->addArgument('id', InputArgument::REQUIRED, 'Share ID') ->addArgument('class', InputArgument::REQUIRED, 'Source class') ->addArgument('value', InputArgument::REQUIRED, 'Source value'); } #[\Override] public function execute(InputInterface $input, OutputInterface $output): int { /** @var string $id */ $id = $input->getArgument('id'); /** @var class-string $class */ $class = $input->getArgument('class'); /** @var non-empty-string $value */ $value = $input->getArgument('value'); return $this->wrapExecution($output, function () use ($id, $class, $value): Share { $share = $this->manager->getShare($this->accessContext, $id); return $this->manager->addShareSource($this->accessContext, $share, new ShareSource($class, $value)); }); } }