Drupal investigation

PhpAdapter.php 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Finder\Adapter;
  11. @trigger_error('The '.__NAMESPACE__.'\PhpAdapter class is deprecated since version 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
  12. use Symfony\Component\Finder\Iterator;
  13. /**
  14. * PHP finder engine implementation.
  15. *
  16. * @author Jean-François Simon <contact@jfsimon.fr>
  17. *
  18. * @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
  19. */
  20. class PhpAdapter extends AbstractAdapter
  21. {
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function searchInDirectory($dir)
  26. {
  27. $flags = \RecursiveDirectoryIterator::SKIP_DOTS;
  28. if ($this->followLinks) {
  29. $flags |= \RecursiveDirectoryIterator::FOLLOW_SYMLINKS;
  30. }
  31. $iterator = new Iterator\RecursiveDirectoryIterator($dir, $flags, $this->ignoreUnreadableDirs);
  32. if ($this->exclude) {
  33. $iterator = new Iterator\ExcludeDirectoryFilterIterator($iterator, $this->exclude);
  34. }
  35. $iterator = new \RecursiveIteratorIterator($iterator, \RecursiveIteratorIterator::SELF_FIRST);
  36. if ($this->minDepth > 0 || $this->maxDepth < PHP_INT_MAX) {
  37. $iterator = new Iterator\DepthRangeFilterIterator($iterator, $this->minDepth, $this->maxDepth);
  38. }
  39. if ($this->mode) {
  40. $iterator = new Iterator\FileTypeFilterIterator($iterator, $this->mode);
  41. }
  42. if ($this->names || $this->notNames) {
  43. $iterator = new Iterator\FilenameFilterIterator($iterator, $this->names, $this->notNames);
  44. }
  45. if ($this->contains || $this->notContains) {
  46. $iterator = new Iterator\FilecontentFilterIterator($iterator, $this->contains, $this->notContains);
  47. }
  48. if ($this->sizes) {
  49. $iterator = new Iterator\SizeRangeFilterIterator($iterator, $this->sizes);
  50. }
  51. if ($this->dates) {
  52. $iterator = new Iterator\DateRangeFilterIterator($iterator, $this->dates);
  53. }
  54. if ($this->filters) {
  55. $iterator = new Iterator\CustomFilterIterator($iterator, $this->filters);
  56. }
  57. if ($this->paths || $this->notPaths) {
  58. $iterator = new Iterator\PathFilterIterator($iterator, $this->paths, $this->notPaths);
  59. }
  60. if ($this->sort) {
  61. $iteratorAggregate = new Iterator\SortableIterator($iterator, $this->sort);
  62. $iterator = $iteratorAggregate->getIterator();
  63. }
  64. return $iterator;
  65. }
  66. /**
  67. * {@inheritdoc}
  68. */
  69. public function getName()
  70. {
  71. return 'php';
  72. }
  73. /**
  74. * {@inheritdoc}
  75. */
  76. protected function canBeUsed()
  77. {
  78. return true;
  79. }
  80. }