本文整理汇总了PHP中Symfony\Component\Finder\Finder::ignoreVCS方法的典型用法代码示例。如果您正苦于以下问题:PHP Finder::ignoreVCS方法的具体用法?PHP Finder::ignoreVCS怎么用?PHP Finder::ignoreVCS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Finder\Finder
的用法示例。
在下文中一共展示了Finder::ignoreVCS方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ensureProjectRoot
protected function ensureProjectRoot()
{
if (!($this->rootDir = $this->input->getOption('project-root'))) {
$this->rootDir = getcwd();
}
$this->rootDir = realpath($this->rootDir);
$this->fs->mkdir($this->rootDir);
$finder = new Finder();
$finder->in($this->rootDir);
$finder->depth(0);
$finder->ignoreVCS(false);
$rootFiles = [];
/** @var SplFileInfo $splInfo */
foreach ($finder as $splInfo) {
$rootFiles[] = $splInfo->getFilename();
}
$requiredFiles = ['composer.json', 'composer.lock'];
$requiredDirs = ['vendor'];
foreach (array_merge($requiredFiles, $requiredDirs) as $file) {
if (!in_array($file, $rootFiles)) {
// possibly not root
$this->output->writeln("<error>You should either run this script under your project root directory, or provide the '--project-root' option.</error>");
$this->output->writeln("The project root directory should contain at least the following files and directories:");
foreach ($requiredFiles as $requiredFile) {
$this->output->writeln("\t- <comment>{$requiredFile}</comment>");
}
foreach ($requiredDirs as $requiredDir) {
$this->output->writeln("\t- <comment>{$requiredDir}/</comment>");
}
exit(1);
}
}
}
示例2: getHookDestinations
private function getHookDestinations($searchAt)
{
$finder = new Finder();
foreach ($searchAt as $location) {
$finder->in(__DIR__ . '/../../..' . $location);
}
return $finder->ignoreVCS(false)->ignoreDotFiles(false)->exclude('vendor')->path('/\\.git\\/hooks$/');
}
示例3: get_files
/**
* Returns a Finder instance for the files that will be included in the
* backup.
*
* By default we ignore unreadable files and directories as well as, common
* version control folders / files, "Dot" files and anything matching the
* exclude rules.
*
* @uses Finder
* @return Finder The Finder iterator of all files to be included
*/
public function get_files()
{
$finder = new Finder();
$finder->followLinks(true);
$finder->ignoreDotFiles(false);
$finder->ignoreVCS(true);
$finder->ignoreUnreadableDirs(true);
// Skip unreadable files too
$finder->filter(function (\SplFileInfo $file) {
if (!$file->isReadable()) {
return false;
}
});
// Finder expects exclude rules to be in a regex format
$exclude_rules = $this->excludes->get_excludes_for_regex();
// Skips folders/files that match default exclude patterns
foreach ($exclude_rules as $exclude) {
$finder->notPath($exclude);
}
return $finder->in(Path::get_root());
}
示例4: execute
protected function execute(InputInterface $input, OutputInterface $output)
{
/** @var ConsoleApplication $console */
$console = $this->getApplication();
$slimapp = $console->getSlimapp();
$cacheDirs = [$slimapp->getConfigCachePath()];
$httpCacheDirs = $slimapp->getHttpKernel()->getCacheDirectories();
$cacheDirs = array_merge($cacheDirs, $httpCacheDirs);
foreach ($cacheDirs as $dir) {
$output->writeln(sprintf('<comment>removing cache in %s ...</comment>', $dir));
$fs = new Filesystem();
$finder = new Finder();
$finder->in($dir);
$finder->depth(0);
$finder->ignoreVCS(false);
/** @var SplFileInfo $splInfo */
foreach ($finder as $splInfo) {
$output->writeln(sprintf("removing file: %s", $splInfo->getPathname()), OutputInterface::VERBOSITY_VERBOSE);
$fs->remove($splInfo->getPathname());
}
$output->writeln(sprintf('<info>done.</info>', $dir));
}
}
示例5: cleanCustom
/**
* @param OutputInterface $output
* @return void
*/
protected function cleanCustom(OutputInterface $output)
{
if (empty($this->options['custom'])) {
return;
}
foreach ($this->options['custom'] as $options) {
try {
$finder = new Finder();
$finder->ignoreDotFiles(false);
$finder->ignoreVCS(false);
$finder->ignoreUnreadableDirs(true);
$in = [];
if (!is_array($options['in'])) {
$options['in'] = [$options['in']];
}
foreach ($options['in'] as $dir) {
$in[] = $this->baseDir . $dir;
}
$finder->in($in);
if (!empty($options['type'])) {
switch ($options['type']) {
case 'files':
$finder->files();
break;
case 'dirs':
case 'directories':
$finder->directories();
break;
}
}
if (!empty($options['notName'])) {
if (!is_array($options['notName'])) {
$options['notName'] = [$options['notName']];
}
foreach ($options['notName'] as $notName) {
$finder->notName($notName);
}
}
if (!empty($options['name'])) {
if (!is_array($options['name'])) {
$options['name'] = [$options['name']];
}
foreach ($options['name'] as $notName) {
$finder->name($notName);
}
}
if (!empty($options['depth'])) {
$finder->depth($options['depth']);
}
foreach ($finder as $file) {
$this->files[] = $file->getRealPath();
}
} catch (\Exception $e) {
// ignore errors
}
}
}
示例6: testIgnoreVCS
public function testIgnoreVCS()
{
$finder = new Finder();
$this->assertSame($finder, $finder->ignoreVCS(false)->ignoreDotFiles(false));
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
$finder = new Finder();
$finder->ignoreVCS(false)->ignoreVCS(false)->ignoreDotFiles(false);
$this->assertIterator($this->toAbsolute(array('.git', 'foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
$finder = new Finder();
$this->assertSame($finder, $finder->ignoreVCS(true)->ignoreDotFiles(false));
$this->assertIterator($this->toAbsolute(array('foo', 'foo/bar.tmp', 'test.php', 'test.py', 'toto', '.bar', '.foo', '.foo/.bar')), $finder->in(self::$tmpDir)->getIterator());
}
示例7: installThemeFiles
private function installThemeFiles(PackageInterface $package)
{
$theme = $this->findTheme($package);
if (!$theme) {
return;
}
$themeSource = $this->composer->getInstallationManager()->getInstallPath($package);
$themeTarget = $theme['installation-path'];
$this->filesystem->ensureDirectoryExists($themeTarget);
$finder = new Finder();
$files = $finder->ignoreVCS(true)->in($themeSource);
foreach ($files as $file) {
$targetPath = $themeTarget . DIRECTORY_SEPARATOR . $file->getRelativePathname();
if ($file->isDir()) {
$this->filesystem->ensureDirectoryExists($targetPath);
} else {
copy($file->getPathname(), $targetPath);
}
}
}
示例8: getFixturesDirectories
/**
* @return Finder
*/
public function getFixturesDirectories()
{
return $this->finder->ignoreVCS(true)->ignoreDotFiles(true)->depth('<= 5')->directories()->in($this->fixturesParentDirectory)->name('DataFixtures');
}
示例9: extract_package
/**
* Extract style package to demo board.
*
* @return null
*/
public function extract_package()
{
$this->package->ensure_extracted();
$package_root = $this->package->find_directory(array('files' => array('required' => 'style.cfg')));
$style_root = $this->get_style_dir();
$filesystem = new \Symfony\Component\Filesystem\Filesystem();
$filesystem->remove($style_root);
// Only copy necessary files
$finder = new Finder();
$finder->ignoreVCS(false)->ignoreDotFiles(false)->files()->notName('/\\.(svg|png|jpe?g|gif|html|js|css|cfg)$/i')->in($this->package->get_temp_path());
$filesystem->remove($finder);
$filesystem->rename($this->package->get_temp_path() . '/' . $package_root, $style_root);
}
示例10: exportViewNode
protected function exportViewNode($view, $node)
{
$this->node = $node;
$fs = new Filesystem();
$container = $this->get('kernel')->getContainer();
$bundle = $this->get('kernel')->getBundle('EUREKAG6KBundle', true);
$viewdir = $bundle->getPath() . "/Resources/views";
$publicdir = $bundle->getPath() . "/Resources/public";
$nodePath = $this->searchNodePath($viewdir, $publicdir, $view);
$content = array();
if ($nodePath != '') {
$finder = new Finder();
$finder->ignoreVCS(true)->files()->in($nodePath)->sortByName();
foreach ($finder as $file) {
$content[] = array('name' => $file->getRelativePathname(), 'data' => file_get_contents($file->getRealPath()), 'modtime' => $file->getMTime());
}
}
$filename = $node == 1 ? $view . "-templates" : $view . "-assets";
$zipcontent = $this->zip($content);
$response = new Response();
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', 'application/octet-stream');
$response->headers->set('Content-Disposition', sprintf('attachment; filename="%s"', $filename . ".zip"));
$response->headers->set('Content-length', strlen($zipcontent));
$response->sendHeaders();
$response->setContent($zipcontent);
return $response;
}
示例11: ignoreVCS
/**
* @return Finder
*/
public function ignoreVCS($ignoreVCS)
{
return parent::ignoreVCS($ignoreVCS);
}