protected function initialize(InputInterface $input, OutputInterface $output) { $root = $this->fs->toAbsolutePath($input->getOption('root')); if (!$this->fs->exists($root)) { throw new \Exception("Failed to locate root: " . $root); } else { $input->setOption('root', $root); } }
/** * Ensure that $command executes without error when applied to a test directory. * * @param string $testDir * @param string $command * @return string $command if well-formed * @throws \Symfony\Component\Filesystem\Exception, \RuntimeException */ public static function validateDirCommand($testDir, $command) { if (empty($command)) { throw new \RuntimeException("Command is required"); } $fs = new \Amp\Util\Filesystem(); $fs->mkdir($testDir); $permHandler = new \Amp\Permission\External(); $permHandler->setDirCommand('examplePerm', $command); $permHandler->applyDirPermission('examplePerm', $testDir); $fs->remove($testDir); return $command; }
/** * Set the permissions for a directory * * @param string $perm eg PermissionInterface::WEB_WRITE * @param string $dir the directory whose permissions should change */ public function applyDirPermission($perm, $dir) { if (!$this->fs->exists($dir)) { return; } $dirCommand = strtr($this->getDirCommand($perm), array('{DIR}' => escapeshellarg($dir))); if ($dirCommand == '') { return; } $process = new Process($dirCommand); $process->run(); if (!$process->isSuccessful()) { throw new \RuntimeException($process->getErrorOutput()); } print $process->getOutput(); // REMOVE }
/** * @param string $root local path to document root * @param string $url preferred public URL */ public function dropVhost($root, $url) { $this->fs->remove($this->createFilePath($root, $url)); }