/** * @param string $destination */ private function cleanDestinationWithCaution($destination) { if (!$this->fileSystem->isDirEmpty($destination)) { if ($this->io->ask('Destination is not empty. Do you want to erase it?', TRUE)) { $this->fileSystem->purgeDir($destination); } } }
/** * @param string $destination */ public function copyToDestination($destination) { $resources = $this->configuration->getOption(CO::TEMPLATE)['resources']; foreach ($resources as $resourceSource => $resourceDestination) { // File if (is_file($resourceSource)) { copy($resourceSource, FileSystem::forceDir($destination . '/' . $resourceDestination)); continue; } // Dir /** @var RecursiveDirectoryIterator $iterator */ $iterator = Finder::findFiles('*')->from($resourceSource)->getIterator(); foreach ($iterator as $item) { /** @var SplFileInfo $item */ copy($item->getPathName(), FileSystem::forceDir($destination . '/' . $resourceDestination . '/' . $iterator->getSubPathName())); } } }
/** * @param string $fileName * @param string $directory * @return string */ private function getFileNameWithoutSourcePath($fileName, $directory) { $directory = rtrim($directory, '/'); $fileName = substr($fileName, strlen($directory) + 1); return FileSystem::normalizePath($fileName); }
private function setNormalizers() { $this->resolver->setNormalizers([CO::ANNOTATION_GROUPS => function (Options $options, $value) { $value = (array) $value; if ($options[CO::DEPRECATED]) { $value[] = CO::DEPRECATED; } if ($options[CO::TODO]) { $value[] = CO::TODO; } return array_unique($value); }, CO::DESTINATION => function (Options $options, $value) { return FileSystem::getAbsolutePath($value); }, CO::BASE_URL => function (Options $options, $value) { return rtrim($value, '/'); }, CO::SKIP_DOC_PATH => function (Options $options, $value) { $value = (array) $value; foreach ($value as $key => $source) { $value[$key] = FileSystem::getAbsolutePath($source); } return $value; }, CO::SOURCE => function (Options $options, $value) { if (!is_array($value)) { $value = [$value]; } foreach ($value as $key => $source) { $value[$key] = FileSystem::getAbsolutePath($source); } return $value; }, CO::SOURCE_CODE => function (Options $options) { return !$options[CO::NO_SOURCE_CODE]; }, CO::TEMPLATE_CONFIG => function (Options $options, $value) { return FileSystem::getAbsolutePath($value); }]); }