private function prepareWorkingDirectory() { $this->currentDirectory = getcwd(); // create a tmp directory $tmpFile = tempnam(sys_get_temp_dir(), ''); $fs = new Filesystem(); if ($fs->exists($tmpFile)) { $fs->remove($tmpFile); } $fs->mkdir($tmpFile); chdir($tmpFile); $this->tmpDirectory = $tmpFile; $fs->mkdir('dir'); $fs->dumpFile('file', 'This is a test file'); $fs->dumpFile('dir/file', 'This is a test file in a directory'); $commandLine = <<<'EOF' git init; git config user.email "*****@*****.**" git config user.name "Your Name" git add file; git commit -m "adds file"; git tag 0.1.0 -m "Adds file"; git checkout -b branch1 master; git add dir/file; git commit -m "adds dir/file"; git tag 0.2.0 -m "Adds file"; git branch branch2 EOF; (new Process($commandLine))->mustRun(); }
protected function execute(InputInterface $input, OutputInterface $output) { $this->downloadConfiguration(); $library = new GLibc(); try { $this->download()->extract(); $library->setEnv($this->env)->setProjectDir($this->baseDir)->initialize()->boot($input, $output); $configure = $this->projectDir . '/' . $library->configure(); $this->projectDir = dirname($this->projectDir) . '/glibc-build'; $this->fs->mkdir($this->projectDir); $this->output->write(' Building : '); $process = new Process($configure, $this->projectDir, $this->env->toArray()); $process->setTimeout(0); $process->run(); if ($process->isSuccessful()) { $process->setCommandLine('make -j4 && make -j4 install'); $process->run(); } if ($process->isSuccessful()) { $message = '<info>✔</info>'; } else { $message = '<error>✕</error>'; } $this->output->writeln($message); } catch (\Exception $e) { $this->cleanUp(); throw $e; } $this->createConfiguration(); $this->output->writeln(sprintf(" <info>%s</info> Droidphp Installer <info>successfully configured</info> Now you can:\n" . " * Run :\n" . " 1. Execute the <comment>%s build:components</comment> command.\n" . " To Build the project\n\n", defined('PHP_WINDOWS_VERSION_BUILD') ? 'OK' : '✔', basename($_SERVER['PHP_SELF']))); }
/** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { $verbose = $input->getOption('verbose'); foreach ($this->importerIterator as $importer) { if (null === $input->getArgument('source') || $input->getArgument('source') === $importer->getSource()) { $this->filesystem->mkdir($importerDir = sprintf('%s/%s', $this->path, $importer->getSource())); foreach ($importer->getLanguages() as $language) { if (null === $input->getArgument('language') || $input->getArgument('language') === $language) { $this->filesystem->mkdir($exporterDir = sprintf('%s/%s', $importerDir, $language)); $countries = $importer->getCountries($language); foreach ($this->exporterIterator as $exporter) { if (null === $input->getArgument('format') || $input->getArgument('format') === $exporter->getFormat()) { $file = sprintf('%s/country.%s', $exporterDir, $exporter->getFormat()); $this->filesystem->touch($file); file_put_contents($file, $exporter->export($countries)); if ($verbose) { $output->write(sprintf('<info>[file+]</info> %s%s', $file, PHP_EOL)); } } } } } } } }
public static function postInstallUpdate() { $filesystem = new Filesystem(); $baseDir = realpath(__DIR__ . '/../../../../../../../'); $packageDir = realpath(__DIR__ . '/../../../../'); echo "...\n"; if (!$filesystem->exists($baseDir . '/web')) { echo "Creating web folder\n"; $filesystem->mkdir($baseDir . '/web'); $filesystem->mirror($packageDir . '/web', $baseDir . '/web'); } echo "Creating config folder with example config.\n"; $filesystem->mkdir($baseDir . '/config'); $filesystem->copy($packageDir . '/config/config.example.yml', $baseDir . '/config/config.example.yml'); $filesystem->copy($packageDir . '/config/modules.example.php', $baseDir . '/config/modules.example.php'); $filesystem->copy($packageDir . '/config/repositories.example.php', $baseDir . '/config/repositories.example.php'); echo "Creating cache folder, deleting eventually current cache files.\n"; $filesystem->remove($baseDir . '/twig-cache'); $filesystem->mkdir($baseDir . '/twig-cache'); $filesystem->remove($baseDir . '/doctrine-cache'); $filesystem->mkdir($baseDir . '/doctrine-cache'); echo "Installing console.\n"; $filesystem->mkdir($baseDir . '/console'); $filesystem->copy($packageDir . '/console/console', $baseDir . '/console/console'); echo "...\n"; echo "Done.\n"; }
/** * @param string $path the working directory for filesystem operations * * @throws \InvalidArgumentException * @throws IOException */ public function setWorkingDirectory($path) { $directory = preg_replace('#/+#', '/', $path); // remove multiple slashes try { $directory = $this->locator->locate($directory); if (false === is_string($directory)) { $directory = strval(reset($directory)); $this->logger->alert(sprintf('Ambiguous filename %s, choosing %s', $path, $directory)); } } catch (\InvalidArgumentException $exception) { // continue to check if dir exists even if locator doesn't locate } $exists = $this->filesystem->exists($directory); if (!$exists) { try { $this->filesystem->mkdir($directory); $this->logger->notice("Working directory created at " . $directory); } catch (IOException $exception) { $this->logger->error("An error occurred while creating directory at " . $exception->getPath(), $exception->getTrace()); throw $exception; } } $this->directory = $directory; }
protected function setUp() { $this->directory = sys_get_temp_dir() . '/AbstractBundleReaderTest/' . rand(1000, 9999); $this->filesystem = new Filesystem(); $this->reader = $this->getMockForAbstractClass('Symfony\\Component\\Intl\\ResourceBundle\\Reader\\AbstractBundleReader'); $this->filesystem->mkdir($this->directory); }
private function setWorkingDirectory() { $this->workingDirectory = tempnam(sys_get_temp_dir(), 'phpzone-test'); $this->filesystem->remove($this->workingDirectory); $this->filesystem->mkdir($this->workingDirectory); chdir($this->workingDirectory); }
function let(ColumnSorterInterface $columnSorter) { $this->directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'spec' . DIRECTORY_SEPARATOR; $this->filesystem = new Filesystem(); $this->filesystem->mkdir($this->directory); $this->beConstructedWith($columnSorter); }
/** * @param string $langPackDir language pack dir in temp folder * @param string $projectNamespace e.g. Oro, OroCRM, etc * @param string $outputFormat xml, yml, etc * @param string $locale en, en_US, fr, etc */ public function dump($langPackDir, $projectNamespace, $outputFormat, $locale) { $this->preloadExistingTranslations($locale); foreach ($this->bundles as $bundle) { // skip bundles from other projects if ($projectNamespace != $this->getBundlePrefix($bundle->getNamespace())) { continue; } $this->logger->log(LogLevel::INFO, ''); $this->logger->log(LogLevel::INFO, sprintf('Writing files for <info>%s</info>', $bundle->getName())); /** @var MessageCatalogue $currentCatalogue */ $currentCatalogue = $this->getCurrentCatalog($locale, $bundle->getName()); $extractedCatalogue = $this->extractViewTranslationKeys($locale, $bundle->getPath()); $operation = new MergeOperation($currentCatalogue, $extractedCatalogue); $messageCatalogue = $operation->getResult(); $isEmptyCatalogue = $this->validateAndFilter($messageCatalogue); if (!$isEmptyCatalogue) { $translationsDir = $langPackDir . DIRECTORY_SEPARATOR . $bundle->getName() . DIRECTORY_SEPARATOR . 'translations'; $this->filesystem->mkdir($translationsDir); $this->writer->writeTranslations($messageCatalogue, $outputFormat, ['path' => $translationsDir]); } else { $this->logger->log(LogLevel::INFO, ' - no files generated'); } } }
public static function setUpBeforeClass() { $fs = new Filesystem(); $fs->mkdir(InterfaceTest::PATH); if (!is_writable(InterfaceTest::PATH)) { $this->markTestSkipped('There are no write permissions in order to create test repositories.'); } $options['path'] = getenv('GIT_CLIENT') ?: '/usr/bin/git'; $options['hidden'] = array(InterfaceTest::PATH . '/hiddenrepo'); $git = new Client($options); // GitTest repository fixture $git->createRepository(InterfaceTest::PATH . 'GitTest'); $repository = $git->getRepository(InterfaceTest::PATH . 'GitTest'); file_put_contents(InterfaceTest::PATH . 'GitTest/README.md', "## GitTest\nGitTest is a *test* repository!"); file_put_contents(InterfaceTest::PATH . 'GitTest/test.php', "<?php\necho 'Hello World'; // This is a test"); $repository->setConfig('user.name', 'Luke Skywalker'); $repository->setConfig('user.email', '*****@*****.**'); $repository->addAll(); $repository->commit("Initial commit"); $repository->createBranch('issue12'); $repository->createBranch('issue42'); // foobar repository fixture $git->createRepository(InterfaceTest::PATH . 'foobar'); $repository = $git->getRepository(InterfaceTest::PATH . '/foobar'); file_put_contents(InterfaceTest::PATH . 'foobar/bar.json', "{\n\"name\": \"foobar\"\n}"); file_put_contents(InterfaceTest::PATH . 'foobar/.git/description', 'This is a test repo!'); $fs->mkdir(InterfaceTest::PATH . 'foobar/myfolder'); $fs->mkdir(InterfaceTest::PATH . 'foobar/testfolder'); file_put_contents(InterfaceTest::PATH . 'foobar/myfolder/mytest.php', "<?php\necho 'Hello World'; // This is my test"); file_put_contents(InterfaceTest::PATH . 'foobar/testfolder/test.php', "<?php\necho 'Hello World'; // This is a test"); $repository->setConfig('user.name', 'Luke Skywalker'); $repository->setConfig('user.email', '*****@*****.**'); $repository->addAll(); $repository->commit("First commit"); }
/** * create directory. * * @param $path * * @throws \Exception * * @return bool */ public function createDirectory($path) { if (!$this->exists(realpath($path))) { $res = $this->fs->mkdir($path); } return true; }
/** * @param $path * @throws \Exception */ public function generate($path) { if ($this->filesystem->exists($path)) { throw new \Exception("Error module already exists"); } $this->filesystem->mkdir($path, 0700); }
public function execute() { $ns = $this->extractNS($this->configuration['class']); $class = $this->extractLocal($this->configuration['class']); $doc = RootNode::create($ns); $ns = $doc->getNamespace($ns); Token::newline()->insertBefore($ns); Token::newline()->appendTo($ns); $class = ClassNode::create($class); if ($parent = $this->configuration['parent']) { Parser::parseSnippet('use ' . ltrim($parent, '\\') . ';')->appendTo($ns)->after(Token::newline()); $class->setExtends($this->extractLocal($parent)); } $interfaces = (array) $this->configuration['interfaces']; foreach ($interfaces as $interface) { Parser::parseSnippet('use ' . ltrim($interface, '\\') . ';')->appendTo($ns)->after(Token::newline()); } $class->setImplements(array_map([$this, 'extractLocal'], $interfaces)); if (isset($this->configuration['doc'])) { $class->setDocComment(DocCommentNode::create($this->configuration['doc'])); } $class->appendTo($ns)->before(Token::newline()); $destination = $this->getUnaliasedPath($this->configuration['destination']); $dir = subStr($destination, 0, strrPos($destination, '/')); $this->fs->mkdir($dir); file_put_contents($destination, $doc->getText()); // Need to store the class' local name as its index identifier because // \Pharborist\Filter::isClass() doesn't support lookup by qualified path. $this->target->getIndexer('class')->addFile($destination); }
public function setUp() { $this->cache_dir = THELIA_CACHE_DIR . 'test_cache'; $fs = new Filesystem(); $fs->mkdir($this->cache_dir); $fs->mkdir(THELIA_WEB_DIR . "/assets"); }
public function initRunFolder() { clearstatcache(); if (!File::exists($this->tmpRunFolder) && !is_dir($this->tmpRunFolder)) { $this->filesystem->mkdir($this->tmpRunFolder); } }
public function setUp() { $this->numberOfPayloads = 5; $this->tempDirectory = sys_get_temp_dir() . '/orphanage'; $this->realDirectory = sys_get_temp_dir() . '/storage'; $this->payloads = array(); $filesystem = new Filesystem(); $filesystem->mkdir($this->tempDirectory); $filesystem->mkdir($this->realDirectory); for ($i = 0; $i < $this->numberOfPayloads; $i++) { // create temporary file $file = tempnam(sys_get_temp_dir(), 'uploader'); $pointer = fopen($file, 'w+'); fwrite($pointer, str_repeat('A', 1024), 1024); fclose($pointer); $this->payloads[] = new FilesystemFile(new UploadedFile($file, $i . 'grumpycat.jpeg', null, null, null, true)); } // create underlying storage $this->storage = new FilesystemStorage($this->realDirectory); // is ignored anyways $chunkStorage = new FilesystemChunkStorage('/tmp/'); // create orphanage $session = new Session(new MockArraySessionStorage()); $session->start(); $config = array('directory' => $this->tempDirectory); $this->orphanage = new FilesystemOrphanageStorage($this->storage, $session, $chunkStorage, $config, 'cat'); }
public function scaffold() { $this->registerVariables(); $fs = new Filesystem(); $config = $this->getItems($this->configurationPath); $actionParser = new ActionParser($config); foreach ($actionParser->getItems() as $item) { $path = $this->outputPath . $item->path; if (strpos($item->path, '%') !== false) { foreach ($this->config->getItems() as $name => $value) { if (!is_array($value)) { $path = str_replace('%' . $name . '%', $value, $path); } } } if (strpos($item->path, '@custom') !== false) { list(, , $code) = explode('/', $item->path); $this->custom[$code] = $this->renderTemplate($item->template); continue; } if ($item->isFile) { $fs->mkdir(dirname($path)); $this->renderTemplate($item->template); file_put_contents($path, $this->renderTemplate($item->template)); } else { $fs->mkdir($path); } } }
/** * {@inheritdoc} */ public function save($tempPath, $fileName, $version, $storageOption = null) { $this->storageOption = new stdClass(); if ($storageOption) { $oldStorageOption = json_decode($storageOption); $segment = $oldStorageOption->segment; } else { $segment = sprintf('%0' . strlen($this->segments) . 'd', rand(1, $this->segments)); } $segmentPath = $this->uploadPath . '/' . $segment; $fileName = $this->getUniqueFileName($segmentPath, $fileName); $filePath = $this->getPathByFolderAndFileName($segmentPath, $fileName); $this->logger->debug('Check FilePath: ' . $filePath); if (!$this->filesystem->exists($segmentPath)) { $this->logger->debug('Try Create Folder: ' . $segmentPath); $this->filesystem->mkdir($segmentPath, 0777); } $this->logger->debug('Try to copy File "' . $tempPath . '" to "' . $filePath . '"'); if ($this->filesystem->exists($filePath)) { throw new FilenameAlreadyExistsException($filePath); } $this->filesystem->copy($tempPath, $filePath); $this->addStorageOption('segment', $segment); $this->addStorageOption('fileName', $fileName); return json_encode($this->storageOption); }
/** * @beforeScenario */ public function prepWorkingDirectory() { $this->workingDirectory = tempnam(sys_get_temp_dir(), 'phpspec-behat'); $this->filesystem->remove($this->workingDirectory); $this->filesystem->mkdir($this->workingDirectory); chdir($this->workingDirectory); }
/** * @param SiteEvent $event */ public function onSettingUpSite(SiteEvent $event) { $drupal = $event->getDrupal(); $this->eventDispatcher->dispatch(WritingSiteSettingsFile::NAME, $settings = new WritingSiteSettingsFile($drupal)); $this->filesystem->mkdir($drupal->getSitePath()); file_put_contents($drupal->getSitePath() . '/settings.php', '<?php ' . $settings->getSettings()); }
/** * @return void */ public static function prepareSharedFolders(array $paths = array()) { if (empty($paths)) { return false; } $fs = new Filesystem(); $releaseRoot = dirname(dirname(dirname(dirname(__FILE__)))) . '/'; // Current version root $root = dirname(dirname($releaseRoot)); $sharedDirectory = $root . '/shared/'; // Create the shared directory first (if it does not exists) if (!$fs->exists($sharedDirectory)) { $fs->mkdir($sharedDirectory, 0777); } foreach ($paths as $path) { $pathDirectory = $releaseRoot . $path; $sharedPathDirectory = $sharedDirectory . $path; if (!$fs->exists($sharedPathDirectory)) { $fs->mkdir($sharedPathDirectory, 0777); } $pathDirectoryTmp = $pathDirectory . '_tmp'; // Symlink it per hand exec("ln -f -s {$sharedPathDirectory} {$pathDirectoryTmp}"); exec("rm -rf {$pathDirectory}"); exec("mv -Tf {$pathDirectoryTmp} {$pathDirectory}"); // $fs->symlink($pathDirectory, $sharedPathDirectory, true); } }
/** * @param string $repository * @param PriorityHandlerInterface $priorityHandler * @param Filesystem $fs * @param Finder $finder * @param LockHandlerFactoryInterface $lockHandlerFactory */ public function __construct($repository, PriorityHandlerInterface $priorityHandler = null, Filesystem $fs = null, Finder $finder = null, LockHandlerFactoryInterface $lockHandlerFactory = null) { if (empty($repository)) { throw new InvalidArgumentException('Argument repository empty or not defined.'); } if (null === $fs) { $fs = new Filesystem(); } if (null === $finder) { $finder = new Finder(); } if (null === $lockHandlerFactory) { $lockHandlerFactory = new LockHandlerFactory(); } if (null === $priorityHandler) { $priorityHandler = new StandardPriorityHandler(); } $this->fs = $fs; if (!$this->fs->exists($repository)) { try { $this->fs->mkdir($repository); } catch (IOExceptionInterface $e) { throw new InvalidArgumentException('An error occurred while creating your directory at ' . $e->getPath()); } } $this->priorityHandler = $priorityHandler; $this->repository = $repository; $this->finder = $finder; $this->finder->files()->in($repository); $this->lockHandlerFactory = $lockHandlerFactory; return $this; }
protected function setUp() { $this->writer = new PhpBundleWriter(); $this->directory = sys_get_temp_dir() . '/PhpBundleWriterTest/' . rand(1000, 9999); $this->filesystem = new Filesystem(); $this->filesystem->mkdir($this->directory); }
public static function createRequiredFiles(Event $event) { $fs = new Filesystem(); $root = static::getDrupalRoot(getcwd()); $dirs = ['modules', 'profiles', 'themes']; // Required for unit testing foreach ($dirs as $dir) { if (!$fs->exists($root . '/' . $dir)) { $fs->mkdir($root . '/' . $dir); $fs->touch($root . '/' . $dir . '/.gitkeep'); } } // Prepare the settings file for installation if (!$fs->exists($root . '/sites/default/settings.php')) { $fs->copy($root . '/sites/default/default.settings.php', $root . '/sites/default/settings.php'); $fs->chmod($root . '/sites/default/settings.php', 0666); $event->getIO()->write("Create a sites/default/settings.php file with chmod 0666"); } // Prepare the services file for installation if (!$fs->exists($root . '/sites/default/services.yml')) { $fs->copy($root . '/sites/default/default.services.yml', $root . '/sites/default/services.yml'); $fs->chmod($root . '/sites/default/services.yml', 0666); $event->getIO()->write("Create a sites/default/services.yml file with chmod 0666"); } // Create the files directory with chmod 0777 if (!$fs->exists($root . '/sites/default/files')) { $oldmask = umask(0); $fs->mkdir($root . '/sites/default/files', 0777); umask($oldmask); $event->getIO()->write("Create a sites/default/files directory with chmod 0777"); } }
/** * @param \Symfony\Component\HttpKernel\Bundle\BundleInterface $bundle * @param string $document * @param array $fields * @param Boolean $withRepository * @throws \RuntimeException */ public function generate(BundleInterface $bundle, $document, array $fields, $withRepository) { $config = $this->documentManager->getConfiguration(); $config->addDocumentNamespace($bundle->getName(), $bundle->getNamespace() . '\\Document'); $documentClass = $config->getDocumentNamespace($bundle->getName()) . '\\' . $document; $documentPath = $bundle->getPath() . '/Document/' . str_replace('\\', '/', $document) . '.php'; if (file_exists($documentPath)) { throw new \RuntimeException(sprintf('Document "%s" already exists.', $documentClass)); } $class = new ClassMetadataInfo($documentClass); if ($withRepository) { $class->setCustomRepositoryClass($documentClass . 'Repository'); } $class->mapField(array('fieldName' => 'id', 'type' => 'integer', 'id' => true)); $class->setIdGeneratorType(ClassMetadataInfo::GENERATOR_TYPE_AUTO); foreach ($fields as $field) { $class->mapField($field); } $documentGenerator = $this->getDocumentGenerator(); $documentCode = $documentGenerator->generateDocumentClass($class); $this->filesystem->mkdir(dirname($documentPath)); file_put_contents($documentPath, rtrim($documentCode) . PHP_EOL, LOCK_EX); if ($withRepository) { $path = $bundle->getPath() . str_repeat('/..', substr_count(get_class($bundle), '\\')); $this->getRepositoryGenerator()->writeDocumentRepositoryClass($class->customRepositoryClassName, $path); } }
/** * Constructor. * * @param string $savePath Path of directory to save session files. * Default null will leave setting as defined by system temp directory. * @param LoggerInterface $logger * @param Filesystem $filesystem */ public function __construct($savePath = null, LoggerInterface $logger = null, Filesystem $filesystem = null) { $this->fs = $filesystem ?: new Filesystem(); $this->logger = $logger ?: new NullLogger(); // @see http://php.net/manual/en/session.configuration.php#ini.session.save-path $depth = 1; $mode = 0600; $savePath = $savePath ?: sys_get_temp_dir(); // Handle 'N;/path' and 'N;octal-mode;/path` values. We don't currently support depth handling. if ($count = substr_count($savePath, ';')) { if ($count > 2) { throw new \InvalidArgumentException(sprintf('Invalid argument $savePath \'%s\'', $savePath)); } $path = explode(';', $savePath); if ($count === 1) { $depth = $path[0]; $savePath = $path[1]; } else { $depth = $path[0]; $mode = intval($path[1], 8); $savePath = $path[2]; } } if (!is_dir($savePath)) { $this->fs->mkdir($savePath, 0777); } $this->depth = $depth; $this->mode = $mode; $this->savePath = $savePath; }
protected function setUp() { $this->filesystem = new Filesystem(); $this->linksDirectory = sys_get_temp_dir() . '/' . uniqid() . '/links/'; $this->filesystem->mkdir($this->linksDirectory); $this->importer = new DocumentationRootImporter($this->linksDirectory, $this->filesystem); }
public function convert($cacheDir) { $fs = new Filesystem(); $targetDir = $cacheDir . '/js_entities'; $webDir = $this->kernel->getRootDir() . '/../web/js'; $fs->mkdir($targetDir); $fs->mkdir($webDir); $namespaces = []; $metas = $this->entityManager->getMetadataFactory()->getAllMetadata(); foreach ($metas as $metadata) { $meta = $this->convertMetadata($metadata); $directory = $targetDir . '/' . $meta->namespace; $fs->mkdir($directory); $meta->filename = $directory . '/' . $meta->functionName . '.js'; $this->generator->generateEntity($meta); if (!isset($namespaces[$meta->namespace])) { $namespaces[$meta->namespace] = array(); } $namespaces[$meta->namespace][] = $meta; } foreach ($namespaces as $namespace => $metas) { $targetFile = $targetDir . '/' . $namespace . '.js'; $webFile = $webDir . '/' . $namespace . '.js'; $this->generator->generateNamespace($namespace, $metas, $targetFile); $fs->copy($targetFile, $webFile); } }
/** * {@inheritdoc} * * @see \Symfony\Component\Console\Command\Command::execute() */ protected function execute(InputInterface $input, OutputInterface $output) { $assets = $this->getContainer()->getParameter('asf_layout.assets'); $this->tinymce_config = $assets['tinymce']; $dest_dir = $input->getArgument('target_dir') ? $input->getArgument('target_dir') : null; if (is_null($dest_dir) && isset($this->tinymce_config['customize']['dest_dir'])) { $dest_dir = $this->tinymce_config['customize']['dest_dir']; } $exclude_files = $input->getOption('exclude_files') ? $input->getOption('exclude_files') : $this->tinymce_config['customize']['exclude_files']; $src_dir = sprintf('%s', $this->tinymce_config['tinymce_dir']); $fs = new Filesystem(); try { if (!$fs->exists($dest_dir)) { $fs->mkdir($dest_dir); } } catch (IOException $e) { $output->writeln(sprintf('<error>Could not create directory %s.</error>', $dest_dir)); return; } if (false === file_exists($src_dir)) { $output->writeln(sprintf('<error>Source directory "%s" does not exist. Did you install TinyMCE ? ' . 'Don\'t forget to specify the path to TinyMCE folder in ' . '"asf_layout.assets.tinymce.tinymce_dir".</error>', $src_dir)); return; } foreach ($iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($src_dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::SELF_FIRST) as $item) { if ($item->isDir() && !in_array($item->getBasename(), $exclude_files)) { $fs->mkdir($dest_dir . '/' . $iterator->getSubPathName()); } elseif (!in_array($item->getBasename(), $exclude_files)) { $fs->copy($item, $dest_dir . '/' . $iterator->getSubPathName()); } } $output->writeln(sprintf('[OK] TinyMCE files was successfully copied in "%s".', $dest_dir)); }
/** * @param InputInterface $input * @param OutputInterface $output * * @return int|void */ public function execute(InputInterface $input, OutputInterface $output) { $this->input = $input; $gitHooksPath = $this->paths()->getGitHooksDir(); $resourceHooksPath = $this->paths()->getGitHookTemplatesDir() . $this->grumPHP->getHooksPreset(); $resourceHooksPath = $this->paths()->getPathWithTrailingSlash($resourceHooksPath); $customHooksPath = $this->paths()->getPathWithTrailingSlash($this->grumPHP->getHooksDir()); // Some git clients to not automatically create a git hooks folder. if (!$this->filesystem->exists($gitHooksPath)) { $this->filesystem->mkdir($gitHooksPath); $output->writeln(sprintf('<fg=yellow>Created git hooks folder at: %s</fg=yellow>', $gitHooksPath)); } foreach (self::$hooks as $hook) { $gitHook = $gitHooksPath . $hook; $hookTemplate = $resourceHooksPath . $hook; if ($customHooksPath && $this->filesystem->exists($customHooksPath . $hook)) { $hookTemplate = $customHooksPath . $hook; } if (!$this->filesystem->exists($hookTemplate)) { throw new \RuntimeException(sprintf('Could not find hook template for %s at %s.', $hook, $hookTemplate)); } $content = $this->parseHookBody($hook, $hookTemplate); file_put_contents($gitHook, $content); $this->filesystem->chmod($gitHook, 0775); } $output->writeln('<fg=yellow>Watch out! GrumPHP is sniffing your commits!<fg=yellow>'); }