Skip to content

Commit 32bb754

Browse files
jfsimonfabpot
authored andcommitted
[2.2] [WIP] [Finder] Adding native finders implementations
1 parent b1618d2 commit 32bb754

30 files changed

+2764
-189
lines changed
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Finder\Adapter;
13+
14+
/**
15+
* Interface for finder engine implementations.
16+
*
17+
* @author Jean-François Simon <contact@jfsimon.fr>
18+
*/
19+
abstract class AbstractAdapter implements AdapterInterface
20+
{
21+
protected $followLinks = false;
22+
protected $mode = 0;
23+
protected $minDepth = 0;
24+
protected $maxDepth = INF;
25+
protected $exclude = array();
26+
protected $names = array();
27+
protected $notNames = array();
28+
protected $contains = array();
29+
protected $notContains = array();
30+
protected $sizes = array();
31+
protected $dates = array();
32+
protected $filters = array();
33+
protected $sort = false;
34+
35+
/**
36+
* {@inheritdoc}
37+
*/
38+
public function setFollowLinks($followLinks)
39+
{
40+
$this->followLinks = $followLinks;
41+
42+
return $this;
43+
}
44+
45+
/**
46+
* {@inheritdoc}
47+
*/
48+
public function setMode($mode)
49+
{
50+
$this->mode = $mode;
51+
52+
return $this;
53+
}
54+
55+
/**
56+
* {@inheritdoc}
57+
*/
58+
public function setDepths(array $depths)
59+
{
60+
$this->minDepth = 0;
61+
$this->maxDepth = INF;
62+
63+
foreach ($depths as $comparator) {
64+
switch ($comparator->getOperator()) {
65+
case '>':
66+
$this->minDepth = $comparator->getTarget() + 1;
67+
break;
68+
case '>=':
69+
$this->minDepth = $comparator->getTarget();
70+
break;
71+
case '<':
72+
$this->maxDepth = $comparator->getTarget() - 1;
73+
break;
74+
case '<=':
75+
$this->maxDepth = $comparator->getTarget();
76+
break;
77+
default:
78+
$this->minDepth = $this->maxDepth = $comparator->getTarget();
79+
}
80+
}
81+
82+
return $this;
83+
}
84+
85+
/**
86+
* {@inheritdoc}
87+
*/
88+
public function setExclude(array $exclude)
89+
{
90+
$this->exclude = $exclude;
91+
92+
return $this;
93+
}
94+
95+
/**
96+
* {@inheritdoc}
97+
*/
98+
public function setNames(array $names)
99+
{
100+
$this->names = $names;
101+
102+
return $this;
103+
}
104+
105+
/**
106+
* {@inheritdoc}
107+
*/
108+
public function setNotNames(array $notNames)
109+
{
110+
$this->notNames = $notNames;
111+
112+
return $this;
113+
}
114+
115+
/**
116+
* {@inheritdoc}
117+
*/
118+
public function setContains(array $contains)
119+
{
120+
$this->contains = $contains;
121+
122+
return $this;
123+
}
124+
125+
/**
126+
* {@inheritdoc}
127+
*/
128+
public function setNotContains(array $notContains)
129+
{
130+
$this->notContains = $notContains;
131+
132+
return $this;
133+
}
134+
135+
/**
136+
* {@inheritdoc}
137+
*/
138+
public function setSizes(array $sizes)
139+
{
140+
$this->sizes = $sizes;
141+
142+
return $this;
143+
}
144+
145+
/**
146+
* {@inheritdoc}
147+
*/
148+
public function setDates(array $dates)
149+
{
150+
$this->dates = $dates;
151+
152+
return $this;
153+
}
154+
155+
/**
156+
* {@inheritdoc}
157+
*/
158+
public function setFilters(array $filters)
159+
{
160+
$this->filters = $filters;
161+
162+
return $this;
163+
}
164+
165+
/**
166+
* {@inheritdoc}
167+
*/
168+
public function setSort($sort)
169+
{
170+
$this->sort = $sort;
171+
172+
return $this;
173+
}
174+
}
Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Finder\Adapter;
13+
14+
/**
15+
* @author Jean-François Simon <contact@jfsimon.fr>
16+
*/
17+
interface AdapterInterface
18+
{
19+
/**
20+
* @param bool $followLinks
21+
*
22+
* @return AdapterInterface Current instance
23+
*/
24+
function setFollowLinks($followLinks);
25+
26+
/**
27+
* @param int $mode
28+
*
29+
* @return AdapterInterface Current instance
30+
*/
31+
function setMode($mode);
32+
33+
/**
34+
* @param array $exclude
35+
*
36+
* @return AdapterInterface Current instance
37+
*/
38+
function setExclude(array $exclude);
39+
40+
/**
41+
* @param array $depths
42+
*
43+
* @return AdapterInterface Current instance
44+
*/
45+
function setDepths(array $depths);
46+
47+
/**
48+
* @param array $names
49+
*
50+
* @return AdapterInterface Current instance
51+
*/
52+
function setNames(array $names);
53+
54+
/**
55+
* @param array $notNames
56+
*
57+
* @return AdapterInterface Current instance
58+
*/
59+
function setNotNames(array $notNames);
60+
61+
/**
62+
* @param array $contains
63+
*
64+
* @return AdapterInterface Current instance
65+
*/
66+
function setContains(array $contains);
67+
68+
/**
69+
* @param array $notContains
70+
*
71+
* @return AdapterInterface Current instance
72+
*/
73+
function setNotContains(array $notContains);
74+
75+
/**
76+
* @param array $sizes
77+
*
78+
* @return AdapterInterface Current instance
79+
*/
80+
function setSizes(array $sizes);
81+
82+
/**
83+
* @param array $dates
84+
*
85+
* @return AdapterInterface Current instance
86+
*/
87+
function setDates(array $dates);
88+
89+
/**
90+
* @param array $filters
91+
*
92+
* @return AdapterInterface Current instance
93+
*/
94+
function setFilters(array $filters);
95+
96+
/**
97+
* @param \Closure|int $sort
98+
*
99+
* @return AdapterInterface Current instance
100+
*/
101+
function setSort($sort);
102+
103+
/**
104+
* @param string $dir
105+
*
106+
* @return \Iterator Result iterator
107+
*/
108+
function searchInDirectory($dir);
109+
110+
/**
111+
* Tests adapter support for current platform.
112+
*
113+
* @return bool
114+
*/
115+
function isSupported();
116+
117+
/**
118+
* Returns adapter name.
119+
*
120+
* @return string
121+
*/
122+
function getName();
123+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy