setName('class:deploy') ->setDescription('Validates a class for the phpMAE and uploads it into CloudObjects. Updates the configuration if necessary.') ->addArgument('coid', InputArgument::REQUIRED, 'The COID of the object.'); } protected function execute(InputInterface $input, OutputInterface $output): int { $this->requireCloudObjectsCLI(); $this->parse($input->getArgument('coid')); $this->assertRDF(); if (!in_array('coid://phpmae.dev/Class', $this->rdfTypes) && !in_array('coid://phpmae.dev/HTTPInvokableClass', $this->rdfTypes)) throw new \Exception("Object does not have a valid class type."); $this->assertPHPExists(); // Running validator $validator = new ClassValidator; $validator->validate(file_get_contents($this->fullName.'.php'), $this->coid, $this->getAdditionalTypes()); $output->writeln("Validated successfully, calling cloudobjects ..."); passthru("cloudobjects attachment:put ".(string)$this->coid." ".$this->fullName.".php"); // Updates configuration if necessary if ($this->ensureFilenameInConfig($output, false)) $this->createConfigurationJob($output); // Print URL so developer can easily access it $output->writeln(""); $visibility = isset($object['coid://cloudobjects.io/isVisibleTo']) ? $object['coid://cloudobjects.io/isVisibleTo'][0]['value'] : 'coid://cloudobjects.io/Vendor'; $path = $this->coid->getHost().$this->coid->getPath(); switch ($visibility) { case "coid://cloudobjects.io/Private": $output->writeln("Private URL for Class Execution:"); $output->writeln("➡️ http://YOUR_PHPMAE_INSTANCE/".$path); break; case "coid://cloudobjects.io/Public": $output->writeln("Public URL for Class Execution:"); $output->writeln("➡️ https://phpmae.dev/".$path); break; case "coid://cloudobjects.io/Vendor": $output->writeln("Authenticated URL for Class Execution:"); $output->writeln("➡️ https://".$this->coid->getHost().":SECRET@phpmae.dev/".$path); $output->writeln(""); $output->writeln("To get value for SECRET:"); $output->writeln("➡️ cloudobjects domain-providers:secret ".$this->coid->getHost()." phpmae.dev"); break; } $output->writeln(""); return Command::SUCCESS; } }