create() public static méthode

Creates a new Finder.
public static create ( ) : Finder
Résultat Finder A new Finder instance
 /**
  * Scan themes directory.
  */
 public function scan()
 {
     $files = $this->finder->create()->in($this->getBasePath())->name('theme.json');
     foreach ($files as $file) {
         $this->register($file);
     }
 }
 /**
  * Compiles psysh into a single phar file.
  *
  * @param string $pharFile The full path to the file to create
  */
 public function compile($pharFile = 'psysh.phar')
 {
     if (file_exists($pharFile)) {
         unlink($pharFile);
     }
     $this->version = Shell::VERSION;
     $phar = new \Phar($pharFile, 0, 'psysh.phar');
     $phar->setSignatureAlgorithm(\Phar::SHA1);
     $phar->startBuffering();
     $finder = Finder::create()->files()->ignoreVCS(true)->name('*.php')->notName('Compiler.php')->notName('Autoloader.php')->in(__DIR__ . '/..');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $finder = Finder::create()->files()->ignoreVCS(true)->name('*.php')->exclude('Tests')->in(__DIR__ . '/../../vendor/dnoegel/php-xdg-base-dir/src')->in(__DIR__ . '/../../vendor/jakub-onderka/php-console-color')->in(__DIR__ . '/../../vendor/jakub-onderka/php-console-highlighter')->in(__DIR__ . '/../../vendor/nikic/php-parser/lib')->in(__DIR__ . '/../../vendor/symfony/console')->in(__DIR__ . '/../../vendor/symfony/var-dumper')->in(__DIR__ . '/../../vendor/symfony/yaml');
     foreach ($finder as $file) {
         $this->addFile($phar, $file);
     }
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/autoload.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/include_paths.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_files.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_psr4.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_real.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_namespaces.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/autoload_classmap.php'));
     $this->addFile($phar, new \SplFileInfo(__DIR__ . '/../../vendor/composer/ClassLoader.php'));
     // Stubs
     $phar->setStub($this->getStub());
     $phar->stopBuffering();
     // $this->addFile($phar, new \SplFileInfo(__DIR__.'/../../LICENSE'), false);
     unset($phar);
 }
 /**
  * {@inheritDoc}
  */
 public function gc($lifetime)
 {
     $files = Finder::create()->in($this->path)->files()->ignoreDotFiles(true)->date('<= now - ' . $lifetime . ' seconds');
     foreach ($files as $file) {
         $this->files->delete($file->getRealPath());
     }
 }
Exemple #4
0
 /**
  * Sync the media. Oh sync the media.
  *
  * @param string|null $path
  * @param SyncMedia   $syncCommand The SyncMedia command object, to log to console if executed by artisan.
  */
 public function sync($path = null, SyncMedia $syncCommand = null)
 {
     set_time_limit(env('APP_MAX_SCAN_TIME', 600));
     $path = $path ?: Setting::get('media_path');
     $results = ['good' => [], 'bad' => [], 'ugly' => []];
     // For now we only care about mp3 and ogg files.
     // Support for other formats (AAC?) may be added in the future.
     $files = Finder::create()->files()->name('/\\.(mp3|ogg)$/')->in($path);
     foreach ($files as $file) {
         $song = $this->syncFile($file);
         if ($song === true) {
             $results['ugly'][] = $file;
         } elseif ($song === false) {
             $results['bad'][] = $file;
         } else {
             $results['good'][] = $file;
         }
         if ($syncCommand) {
             $syncCommand->logToConsole($file->getPathname(), $song);
         }
     }
     // Delete non-existing songs.
     $hashes = array_map(function ($f) {
         return $this->getHash($f->getPathname());
     }, array_merge($results['ugly'], $results['good']));
     Song::whereNotIn('id', $hashes)->delete();
     // Empty albums and artists should be gone as well.
     $inUseAlbums = Song::select('album_id')->groupBy('album_id')->get()->lists('album_id');
     $inUseAlbums[] = Album::UNKNOWN_ID;
     Album::whereNotIn('id', $inUseAlbums)->delete();
     $inUseArtists = Album::select('artist_id')->groupBy('artist_id')->get()->lists('artist_id');
     $inUseArtists[] = Artist::UNKNOWN_ID;
     Artist::whereNotIn('id', $inUseArtists)->delete();
 }
 public function handle()
 {
     $dirs = iterator_to_array(Finder::create()->in($this->repo->releasePath())->depth(0)->sortByChangedTime());
     foreach (array_slice(array_reverse($dirs), 3) as $dir) {
         $this->fs()->deleteDirectory($dir);
     }
 }
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $targetArg = rtrim($input->getArgument('target'), '/');
     if (!is_dir($targetArg)) {
         throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
     }
     if (!function_exists('symlink') && $input->getOption('symlink')) {
         throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
     }
     $filesystem = $this->getContainer()->get('filesystem');
     // Create the bundles directory otherwise symlink will fail.
     $bundlesDir = $targetArg . '/bundles/';
     $filesystem->mkdir($bundlesDir, 0777);
     $output->writeln(sprintf('Installing assets using the <comment>%s</comment> option', $input->getOption('symlink') ? 'symlink' : 'hard copy'));
     foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
         if (is_dir($originDir = $bundle->getPath() . '/Resources/public')) {
             $targetDir = $bundlesDir . preg_replace('/bundle$/', '', strtolower($bundle->getName()));
             $output->writeln(sprintf('Installing assets for <comment>%s</comment> into <comment>%s</comment>', $bundle->getNamespace(), $targetDir));
             $filesystem->remove($targetDir);
             if ($input->getOption('symlink')) {
                 if ($input->getOption('relative')) {
                     $relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($bundlesDir));
                 } else {
                     $relativeOriginDir = $originDir;
                 }
                 $filesystem->symlink($relativeOriginDir, $targetDir);
             } else {
                 $filesystem->mkdir($targetDir, 0777);
                 // We use a custom iterator to ignore VCS files
                 $filesystem->mirror($originDir, $targetDir, Finder::create()->ignoreDotFiles(false)->in($originDir));
             }
         }
     }
 }
Exemple #7
0
 public function testCopyDir()
 {
     $source = static::$cwd . '/tests/fixtures/filesystem';
     Filesystem::create()->mkdir($target = getcwd());
     Filesystem::create()->copyDir($source, $target, Finder::create());
     $this->assertFileExists($target . '/foo/test.txt');
 }
 /**
  * @return void
  */
 public function execute()
 {
     try {
         $installationFolder = $this->config->getString('installationFolder');
         $varFolder = $installationFolder . '/var';
         if (!is_dir($varFolder)) {
             @mkdir($varFolder);
         }
         @chmod($varFolder, 0777);
         $varCacheFolder = $installationFolder . '/var/cache';
         if (!is_dir($varCacheFolder)) {
             @mkdir($varCacheFolder);
         }
         @chmod($varCacheFolder, 0777);
         $mediaFolder = $installationFolder . '/pub/media';
         if (!is_dir($mediaFolder)) {
             @mkdir($mediaFolder);
         }
         @chmod($mediaFolder, 0777);
         $finder = Finder::create();
         $finder->directories()->ignoreUnreadableDirs(true)->in(array($varFolder, $mediaFolder));
         foreach ($finder as $dir) {
             @chmod($dir->getRealpath(), 0777);
         }
     } catch (\Exception $e) {
         $this->output->writeln('<error>' . $e->getMessage() . '</error>');
     }
 }
 /**
  * {@inheritdoc}
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $info = $this->container->info()->get();
     $path = $this->container->path();
     $vers = $info['version'];
     $filter = '/' . implode('|', $this->excludes) . '/i';
     $this->line(sprintf('Starting: webpack'));
     exec('webpack -p');
     $finder = Finder::create()->files()->in($path)->ignoreVCS(true)->filter(function ($file) use($filter) {
         return !preg_match($filter, $file->getRelativePathname());
     });
     $zip = new \ZipArchive();
     if (!$zip->open($zipFile = "{$path}/pagekit-" . $vers . ".zip", \ZipArchive::OVERWRITE)) {
         $this->abort("Can't open ZIP extension in '{$zipFile}'");
     }
     foreach ($finder as $file) {
         $zip->addFile($file->getPathname(), $file->getRelativePathname());
     }
     $zip->addFile("{$path}/.bowerrc", '.bowerrc');
     $zip->addFile("{$path}/.htaccess", '.htaccess');
     $zip->addEmptyDir('tmp/');
     $zip->addEmptyDir('tmp/cache');
     $zip->addEmptyDir('tmp/temp');
     $zip->addEmptyDir('tmp/logs');
     $zip->addEmptyDir('tmp/sessions');
     $zip->addEmptyDir('tmp/packages');
     $zip->addEmptyDir('app/database');
     $zip->close();
     $name = basename($zipFile);
     $size = filesize($zipFile) / 1024 / 1024;
     $this->line(sprintf('Building: %s (%.2f MB)', $name, $size));
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $twig = $this->getContainer()->get('twig');
     $template = null;
     $filename = $input->getArgument('filename');
     if (!$filename) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException("Please provide a filename or pipe template content to stdin.");
         }
         while (!feof(STDIN)) {
             $template .= fread(STDIN, 1024);
         }
         return $twig->parse($twig->tokenize($template));
     }
     if (0 !== strpos($filename, '@') && !is_readable($filename)) {
         throw new \RuntimeException("File or directory '%s' is not readable");
     }
     $files = array();
     if (is_file($filename)) {
         $files = array($filename);
     } elseif (is_dir($filename)) {
         $files = Finder::create()->files()->in($filename)->name('*.twig');
     } else {
         $dir = $this->getApplication()->getKernel()->locateResource($filename);
         $files = Finder::create()->files()->in($dir)->name('*.twig');
     }
     foreach ($files as $file) {
         $twig->parse($twig->tokenize(file_get_contents($file), (string) $file));
     }
     $output->writeln('<info>No syntax error detected.</info>');
 }
Exemple #11
0
 public function load(ObjectManager $manager)
 {
     $gallery = $this->getGalleryManager()->create();
     $manager = $this->getMediaManager();
     $faker = $this->getFaker();
     $files = Finder::create()->name('*.jpeg')->in(__DIR__ . '/../data/files');
     $i = 0;
     foreach ($files as $pos => $file) {
         $media = $manager->create();
         $media->setBinaryContent($file);
         $media->setEnabled(true);
         $media->setDescription($faker->sentence(15));
         $this->addReference('sonata-media-' . $i++, $media);
         $manager->save($media, 'default', 'sonata.media.provider.image');
         $this->addMedia($gallery, $media);
     }
     $videos = array('ythUVU31Y18' => 'sonata.media.provider.youtube');
     foreach ($videos as $video => $provider) {
         $media = $manager->create();
         $media->setBinaryContent($video);
         $media->setEnabled(true);
         $manager->save($media, 'default', $provider);
         $this->addMedia($gallery, $media);
     }
     $gallery->setEnabled(true);
     $gallery->setName($faker->sentence(4));
     $gallery->setDefaultFormat('small');
     $gallery->setContext('default');
     $this->getGalleryManager()->update($gallery);
     $this->addReference('media-gallery', $gallery);
 }
 public function execute(InputInterface $input, OutputInterface $output)
 {
     $foundLinkTarget = '';
     $targetFolder = $input->getArgument('target-folder');
     if (!is_dir($targetFolder)) {
         throw new \LogicException('Folder ' . $targetFolder . ' does not exist.');
     }
     $finder = Finder::create()->directories()->name('PhpStorm')->depth(0)->in($targetFolder);
     foreach ($finder as $dir) {
         /* @var $dir \Symfony\Component\Finder\SplFileInfo */
         $foundLinkTarget = $dir->getLinkTarget();
         $output->writeln('<info>Found Symlink to current version </info><comment>' . $foundLinkTarget . '</comment>');
         break;
     }
     if (empty($foundLinkTarget)) {
         $output->writeln('<info>Please run download before any clean operation</info>');
         return 1;
     }
     $finder = Finder::create()->directories()->name('PhpStorm-*')->notName($foundLinkTarget)->in($targetFolder)->depth(0);
     $filesystem = new Filesystem();
     foreach ($finder as $dir) {
         $output->writeln('<info>Remove directory</info> <comment>' . $dir->getRelativePathname() . '</comment>');
         $filesystem->remove(array($dir));
     }
 }
 /**
  * {@inheritdoc}
  */
 public function process(ContainerBuilder $container)
 {
     $dirs = $this->findTranslationsDirs($container);
     if (empty($dirs)) {
         return;
     }
     $translator = $container->findDefinition('translator.default');
     // Register translation resources
     foreach ($dirs as $dir) {
         $container->addResource(new DirectoryResource($dir));
     }
     $files = [];
     $finder = Finder::create()->files()->filter(function (SplFileInfo $file) {
         return 2 === substr_count($file->getBasename(), '.') && preg_match('/\\.\\w+$/', $file->getBasename());
     })->in($dirs);
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         $locale = explode('.', $file->getBasename(), 3)[1];
         if (!isset($files[$locale])) {
             $files[$locale] = [];
         }
         $files[$locale][] = (string) $file;
     }
     $options = array_merge_recursive($translator->getArgument(3), ['resource_files' => $files]);
     $translator->replaceArgument(3, $options);
 }
Exemple #14
0
 /**
  * Set the namespace on the files in the app directory.
  *
  * @return void
  */
 protected function setAppDirectoryNamespace()
 {
     $files = Finder::create()->in($this->laravel['path'])->name('*.php');
     foreach ($files as $file) {
         $this->replaceNamespace($file->getRealPath());
     }
 }
Exemple #15
0
 public function registerBuiltInConfigs()
 {
     foreach (Finder::create()->files()->in(__DIR__ . '/Config') as $file) {
         $class = 'Symfony\\CS\\Config\\' . basename($file, '.php');
         $this->addConfig(new $class());
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $finder = Finder::create()->in($this->cachePath)->notName('.gitkeep');
     $filesystem = new Filesystem();
     $filesystem->remove($finder);
     $output->writeln(sprintf("%s <info>success</info>", 'cache:clear'));
 }
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $targetArg = rtrim($input->getArgument('target'), '/');
     if (!is_dir($targetArg)) {
         throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
     }
     if (!function_exists('symlink') && $input->getOption('symlink')) {
         throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
     }
     $filesystem = $this->getContainer()->get('filesystem');
     $themeBundle = $this->getContainer()->get('kernel')->getBundle($this->getContainer()->getParameter('bigfoot.theme.bundle'));
     $contentBundle = $this->getContainer()->get('kernel')->getBundle('BigfootContentBundle');
     $images = $contentBundle->getPath() . '/Resources/public/images';
     CommonUtil::recurseCopy($images, $targetArg . '/images');
     if (is_dir($originDir = $themeBundle->getPath() . '/Resources/assets')) {
         $targetDir = $targetArg . '/admin';
         $output->writeln(sprintf('Installing bigfoot theme assets from <comment>%s</comment> into <comment>%s</comment>', $themeBundle->getNamespace(), $targetDir));
         $filesystem->remove($targetDir);
         if ($input->getOption('symlink')) {
             if ($input->getOption('relative')) {
                 $relativeOriginDir = $filesystem->makePathRelative($originDir, realpath($targetArg));
             } else {
                 $relativeOriginDir = $originDir;
             }
             $filesystem->symlink($relativeOriginDir, $targetDir);
         } else {
             $filesystem->mkdir($targetDir, 0777);
             // We use a custom iterator to ignore VCS files
             $filesystem->mirror($originDir, $targetDir, Finder::create()->in($originDir));
         }
     }
 }
Exemple #18
0
 /**
  * returns a bundle
  *
  * @return  Bundle
  */
 public function bundle()
 {
     $bundle = new Bundle();
     $iterator = Finder::create()->files()->ignoreVCS(true)->filter($this->package->getBlacklistFilter())->exclude($this->package->getPathVendor())->in($this->package->getDirectory());
     $this->logger->log('    Adding whole project directory "' . $this->package->getDirectory() . '"');
     return $bundle->addDir($iterator);
 }
 /**
  * Create a new event scanner instance.
  *
  * @param  array  $scan
  * @return void
  */
 public function __construct(array $scan)
 {
     $this->scan = $scan;
     foreach (Finder::create()->files()->in(__DIR__ . '/Annotations') as $file) {
         AnnotationRegistry::registerFile($file->getRealPath());
     }
 }
Exemple #20
0
 public function getSpecifications($path)
 {
     $line = null;
     if (preg_match('/^(.*)\\:(\\d+)$/', $path, $matches)) {
         list($_, $path, $line) = $matches;
     }
     $path = str_replace('\\', DIRECTORY_SEPARATOR, $path);
     if ('.' !== dirname($path) && !file_exists($path) && 0 !== strpos($path, 'spec' . DIRECTORY_SEPARATOR)) {
         $path = 'spec' . DIRECTORY_SEPARATOR . $path;
     }
     $specs = array();
     if (is_dir($path)) {
         $files = Finder::create()->files()->name('*.php')->in($path);
         foreach ($files as $file) {
             if ($fromFile = $this->getSpecificationsFromFile($file, $line)) {
                 $specs = array_merge($specs, $fromFile);
             }
         }
     } elseif (is_file($path) || is_file($path = $path . '.php')) {
         $file = new SplFileInfo(realpath($path));
         if ($fromFile = $this->getSpecificationsFromFile($file, $line)) {
             $specs = array_merge($specs, $fromFile);
         }
     }
     return $specs;
 }
 /**
  * @return Finder
  */
 public function getFinder()
 {
     if (null === $this->finder) {
         $this->setFinder(Finder::create());
     }
     return $this->finder;
 }
 protected function getFiles()
 {
     $files = array('LICENSE', 'vendor/autoload.php', 'Goutte/Client.php', 'vendor/guzzle/http/Guzzle/Http/Resources/cacert.pem', 'vendor/guzzle/http/Guzzle/Http/Resources/cacert.pem.md5');
     $dirs = array('vendor/composer', 'vendor/symfony', 'vendor/guzzle');
     $iterator = Finder::create()->files()->name('*.php')->in($dirs);
     return array_merge($files, iterator_to_array($iterator));
 }
Exemple #23
0
 /**
  * Scans a directory provided and includes all PHP files from it.
  * All files will be parsed and aspects will be added.
  *
  * @param $dir
  */
 public function loadPhpFiles($dir)
 {
     $files = Finder::create()->files()->name('*.php')->in($dir);
     foreach ($files as $file) {
         $this->loadFile($file->getRealpath());
     }
 }
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $filename = $input->getArgument('filename');
     if (!$filename) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
         }
         $content = '';
         while (!feof(STDIN)) {
             $content .= fread(STDIN, 1024);
         }
         return $this->display($input, $output, array($this->validate($content)));
     }
     if (0 !== strpos($filename, '@') && !is_readable($filename)) {
         throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
     }
     $files = array();
     if (is_file($filename)) {
         $files = array($filename);
     } elseif (is_dir($filename)) {
         $files = Finder::create()->files()->in($filename)->name('*.yml');
     } else {
         $dir = $this->getApplication()->getKernel()->locateResource($filename);
         $files = Finder::create()->files()->in($dir)->name('*.yml');
     }
     $filesInfo = array();
     foreach ($files as $file) {
         $filesInfo[] = $this->validate(file_get_contents($file), $file);
     }
     return $this->display($input, $output, $filesInfo);
 }
 public function load1A($manager)
 {
     $test_password = '******';
     $factory = $this->container->get('security.encoder_factory');
     $finder = new Finder();
     $finder = Finder::create()->name('liste_1a_2015-2016.csv')->in(__DIR__ . '/../data/files');
     $rows = $this->parseCSV($finder);
     foreach ($rows as $key => $student) {
         /** @var $user \Application\Sonata\UserBundle\Entity\User */
         $user = new Student();
         $user->setSchoolClass($this->getReference('schoolClass.1A_' . mb_strtoupper($student[4])));
         $user->setUsername($student[1] . '.' . $student[2]);
         $user->setPlainPassword($test_password);
         $user->setEmail($student[5]);
         $user->setFirstname($student[1]);
         $user->setLastname($student[2]);
         // $user->setRoles(array('ROLE_USER'));
         $user->addGroup($this->getReference('schoolClass.1A_' . mb_strtoupper($student[4])));
         $user->setEnabled(true);
         $encoder = $factory->getEncoder($user);
         $password = $encoder->encodePassword($user->getPlainPassword(), $user->getSalt());
         $user->setPassword($password);
         $manager->updateUser($user);
     }
 }
 /**
  * Iterate over all files in the given directory searching for classes
  *
  * @param \Iterator|string $path      The path to search in or an iterator
  * @param string           $blacklist Regex that matches against the file path that exclude from the classmap.
  * @param IOInterface      $io        IO object
  * @param string           $namespace Optional namespace prefix to filter by
  *
  * @throws \RuntimeException When the path is neither an existing file nor directory
  * @return array             A class map array
  */
 public static function createMap($path, $blacklist = null, IOInterface $io = null, $namespace = null)
 {
     if (is_string($path)) {
         if (is_file($path)) {
             $path = array(new \SplFileInfo($path));
         } elseif (is_dir($path)) {
             $path = Finder::create()->files()->followLinks()->name('/\\.(php|inc|hh)$/')->in($path);
         } else {
             throw new \RuntimeException('Could not scan for classes inside "' . $path . '" which does not appear to be a file nor a folder');
         }
     }
     $map = array();
     foreach ($path as $file) {
         $filePath = $file->getRealPath();
         if (!in_array(pathinfo($filePath, PATHINFO_EXTENSION), array('php', 'inc', 'hh'))) {
             continue;
         }
         if ($blacklist && preg_match($blacklist, strtr($filePath, '\\', '/'))) {
             continue;
         }
         $classes = self::findClasses($filePath);
         foreach ($classes as $class) {
             // skip classes not within the given namespace prefix
             if (null !== $namespace && 0 !== strpos($class, $namespace)) {
                 continue;
             }
             if (!isset($map[$class])) {
                 $map[$class] = $filePath;
             } elseif ($io && $map[$class] !== $filePath && !preg_match('{/(test|fixture|example|stub)s?/}i', strtr($map[$class] . ' ' . $filePath, '\\', '/'))) {
                 $io->writeError('<warning>Warning: Ambiguous class resolution, "' . $class . '"' . ' was found in both "' . $map[$class] . '" and "' . $filePath . '", the first will be used.</warning>');
             }
         }
     }
     return $map;
 }
Exemple #27
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     if (false !== strpos($input->getFirstArgument(), ':l')) {
         $output->writeln('<comment>The use of "yaml:lint" command is deprecated since version 2.7 and will be removed in 3.0. Use the "lint:yaml" instead.</comment>');
     }
     $filename = $input->getArgument('filename');
     if (!$filename) {
         if (0 !== ftell(STDIN)) {
             throw new \RuntimeException('Please provide a filename or pipe file content to STDIN.');
         }
         $content = '';
         while (!feof(STDIN)) {
             $content .= fread(STDIN, 1024);
         }
         return $this->display($input, $output, array($this->validate($content)));
     }
     if (0 !== strpos($filename, '@') && !is_readable($filename)) {
         throw new \RuntimeException(sprintf('File or directory "%s" is not readable', $filename));
     }
     $files = array();
     if (is_file($filename)) {
         $files = array($filename);
     } elseif (is_dir($filename)) {
         $files = Finder::create()->files()->in($filename)->name('*.yml');
     } else {
         $dir = $this->getApplication()->getKernel()->locateResource($filename);
         $files = Finder::create()->files()->in($dir)->name('*.yml');
     }
     $filesInfo = array();
     foreach ($files as $file) {
         $filesInfo[] = $this->validate(file_get_contents($file), $file);
     }
     return $this->display($input, $output, $filesInfo);
 }
 private function registerAllProjectTestsClasses()
 {
     $finder = Finder::create()->files()->name('*.php')->in(__DIR__ . '/..')->exclude(array('Fixtures'));
     foreach ($finder as $file) {
         include_once $file;
     }
 }
Exemple #29
0
 /**
  * Build the Dropdock phar package
  */
 public function pharBuild()
 {
     $yaml = new Parser();
     $packer = $this->taskPackPhar('dropdock.phar');
     // $packer->compress(TRUE);
     $this->taskComposerInstall()->noDev()->printed(false)->run();
     // Add php sources.
     $files = Finder::create()->ignoreVCS(true)->files()->name('*.php')->path('php-src')->path('vendor')->notPath('data')->notPath('tmp')->in(__DIR__);
     foreach ($files as $file) {
         $packer->addFile($file->getRelativePathname(), $file->getRealPath());
     }
     // Add binaries yaml config.
     $files = Finder::create()->ignoreVCS(true)->files()->name('binaries.yml')->in(__DIR__);
     foreach ($files as $file) {
         $packer->addFile($file->getRelativePathname(), $file->getRealPath());
     }
     // Add dropdock binary and make it as executable.
     $packer->addFile('DropdockRoboFile.php', 'DropdockRoboFile.php');
     // Add docker-compose.yml.
     $packer->addFile('docker-compose.yml.dist', 'docker-compose.yml.dist');
     // Add boot2local.sh script.
     $packer->addFile('src/scripts/boot2local.sh', 'src/scripts/boot2local.sh');
     $packer->addFile('dropdock', 'dropdock')->executable('dropdock')->run();
     $this->taskComposerInstall()->printed(false)->run();
 }