4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Finder\Adapter;
14 @trigger_error('The '.__NAMESPACE__.'\AbstractAdapter class is deprecated since version 2.8 and will be removed in 3.0. Use directly the Finder class instead.', E_USER_DEPRECATED);
17 * Interface for finder engine implementations.
19 * @author Jean-François Simon <contact@jfsimon.fr>
21 * @deprecated since 2.8, to be removed in 3.0. Use Finder instead.
23 abstract class AbstractAdapter implements AdapterInterface
25 protected $followLinks = false;
27 protected $minDepth = 0;
28 protected $maxDepth = PHP_INT_MAX;
29 protected $exclude = array();
30 protected $names = array();
31 protected $notNames = array();
32 protected $contains = array();
33 protected $notContains = array();
34 protected $sizes = array();
35 protected $dates = array();
36 protected $filters = array();
37 protected $sort = false;
38 protected $paths = array();
39 protected $notPaths = array();
40 protected $ignoreUnreadableDirs = false;
42 private static $areSupported = array();
47 public function isSupported()
49 $name = $this->getName();
51 if (!array_key_exists($name, self::$areSupported)) {
52 self::$areSupported[$name] = $this->canBeUsed();
55 return self::$areSupported[$name];
61 public function setFollowLinks($followLinks)
63 $this->followLinks = $followLinks;
71 public function setMode($mode)
81 public function setDepths(array $depths)
84 $this->maxDepth = PHP_INT_MAX;
86 foreach ($depths as $comparator) {
87 switch ($comparator->getOperator()) {
89 $this->minDepth = $comparator->getTarget() + 1;
92 $this->minDepth = $comparator->getTarget();
95 $this->maxDepth = $comparator->getTarget() - 1;
98 $this->maxDepth = $comparator->getTarget();
101 $this->minDepth = $this->maxDepth = $comparator->getTarget();
111 public function setExclude(array $exclude)
113 $this->exclude = $exclude;
121 public function setNames(array $names)
123 $this->names = $names;
131 public function setNotNames(array $notNames)
133 $this->notNames = $notNames;
141 public function setContains(array $contains)
143 $this->contains = $contains;
151 public function setNotContains(array $notContains)
153 $this->notContains = $notContains;
161 public function setSizes(array $sizes)
163 $this->sizes = $sizes;
171 public function setDates(array $dates)
173 $this->dates = $dates;
181 public function setFilters(array $filters)
183 $this->filters = $filters;
191 public function setSort($sort)
201 public function setPath(array $paths)
203 $this->paths = $paths;
211 public function setNotPath(array $notPaths)
213 $this->notPaths = $notPaths;
221 public function ignoreUnreadableDirs($ignore = true)
223 $this->ignoreUnreadableDirs = (bool) $ignore;
229 * Returns whether the adapter is supported in the current environment.
231 * This method should be implemented in all adapters. Do not implement
232 * isSupported in the adapters as the generic implementation provides a cache
237 * @return bool Whether the adapter is supported
239 abstract protected function canBeUsed();