1
<?php
2
/**
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the LGPL. For more information please see
17
 * <http://phing.info>.
18
 */
19

20
/**
21
 * This is an abstract task that should be used by all those tasks that
22
 * require to include or exclude files based on pattern matching.
23
 *
24
 * This is very closely based on the ANT class of the same name.
25
 *
26
 * @author  Hans Lellelid <hans@xmpl.org> (Phing)
27
 * @author  Arnout J. Kuiper <ajkuiper@wxs.nl> (Ant)
28
 * @author  Stefano Mazzocchi  <stefano@apache.org> (Ant)
29
 * @author  Sam Ruby <rubys@us.ibm.com> (Ant)
30
 * @author  Jon S. Stevens <jon@clearink.com> (Ant
31
 * @author  Stefan Bodewig <stefan.bodewig@epost.de> (Ant)
32
 * @author  Bruce Atherton <bruce@callenish.com> (Ant)
33
 * @package phing.tasks.system
34
 */
35
abstract class MatchingTask extends Task implements SelectorContainer
36
{
37

38
    /**
39
     * @var boolean
40
     */
41
    protected $useDefaultExcludes = true;
42

43
    /**
44
     * @var FileSet
45
     */
46
    protected $fileset;
47

48
    /**
49
     * Create instance; set fileset to new FileSet.
50
     */
51 1
    public function __construct()
52
    {
53 1
        parent::__construct();
54 1
        $this->fileset = new FileSet();
55
    }
56

57
    /**
58
     * @see ProjectComponent::setProject()
59
     * @param Project $project
60
     */
61 1
    public function setProject($project)
62
    {
63 1
        parent::setProject($project);
64 1
        $this->fileset->setProject($project);
65
    }
66

67
    /**
68
     * add a name entry on the include list
69
     *
70
     * @return PatternSetNameEntry
71
     */
72 0
    public function createInclude()
73
    {
74 0
        return $this->fileset->createInclude();
75
    }
76

77
    /**
78
     * add a name entry on the include files list
79
     *
80
     * @return PatternSetNameEntry
81
     */
82 0
    public function createIncludesFile()
83
    {
84 0
        return $this->fileset->createIncludesFile();
85
    }
86

87
    /**
88
     * add a name entry on the exclude list
89
     *
90
     * @return PatternSetNameEntry
91
     */
92 0
    public function createExclude()
93
    {
94 0
        return $this->fileset->createExclude();
95
    }
96

97
    /**
98
     * add a name entry on the include files list
99
     *
100
     * @return PatternSetNameEntry
101
     */
102 0
    public function createExcludesFile()
103
    {
104 0
        return $this->fileset->createExcludesFile();
105
    }
106

107
    /**
108
     * add a set of patterns
109
     *
110
     * @return PatternSet
111
     */
112 0
    public function createPatternSet()
113
    {
114 0
        return $this->fileset->createPatternSet();
115
    }
116

117
    /**
118
     * Sets the set of include patterns. Patterns may be separated by a comma
119
     * or a space.
120
     *
121
     * @param  string $includes the string containing the include patterns
122
     * @return void
123
     */
124 0
    public function setIncludes($includes)
125
    {
126 0
        $this->fileset->setIncludes($includes);
127
    }
128

129
    /**
130
     * Sets the set of exclude patterns. Patterns may be separated by a comma
131
     * or a space.
132
     *
133
     * @param string $excludes the string containing the exclude patterns
134
     */
135 0
    public function setExcludes($excludes)
136
    {
137 0
        $this->fileset->setExcludes($excludes);
138
    }
139

140
    /**
141
     * Sets whether default exclusions should be used or not.
142
     *
143
     * @param boolean $useDefaultExcludes "true"|"on"|"yes" when default exclusions
144
     *                                    should be used, "false"|"off"|"no" when they
145
     *                                    shouldn't be used.
146
     */
147 0
    public function setDefaultexcludes(bool $useDefaultExcludes)
148
    {
149 0
        $this->useDefaultExcludes = $useDefaultExcludes;
150
    }
151

152
    /**
153
     * Returns the directory scanner needed to access the files to process.
154
     *
155
     * @param  PhingFile $baseDir
156
     * @throws BuildException
157
     * @return DirectoryScanner
158
     */
159 0
    protected function getDirectoryScanner(PhingFile $baseDir)
160
    {
161 0
        $this->fileset->setDir($baseDir);
162 0
        $this->fileset->setDefaultexcludes($this->useDefaultExcludes);
163

164 0
        return $this->fileset->getDirectoryScanner($this->project);
165
    }
166

167
    /**
168
     * Sets the name of the file containing the includes patterns.
169
     *
170
     * @param  PhingFile $includesfile A string containing the filename to fetch
171
     *                                 the include patterns from.
172
     * @return void
173
     */
174 0
    public function setIncludesfile(PhingFile $includesfile)
175
    {
176 0
        $this->fileset->setIncludesfile($includesfile);
177
    }
178

179
    /**
180
     * Sets the name of the file containing the includes patterns.
181
     *
182
     * @param  PhingFile $excludesfile A string containing the filename to fetch
183
     *                                 the include patterns from.
184
     * @return void
185
     */
186 0
    public function setExcludesfile(PhingFile $excludesfile)
187
    {
188 0
        $this->fileset->setExcludesfile($excludesfile);
189
    }
190

191
    /**
192
     * Sets case sensitivity of the file system
193
     *
194
     * @param  boolean $isCaseSensitive "true"|"on"|"yes" if file system is case
195
     *                                  sensitive, "false"|"off"|"no" when not.
196
     * @return void
197
     */
198 0
    public function setCaseSensitive($isCaseSensitive)
199
    {
200 0
        $this->fileset->setCaseSensitive($isCaseSensitive);
201
    }
202

203
    /**
204
     * Sets whether or not symbolic links should be followed.
205
     *
206
     * @param  boolean $followSymlinks whether or not symbolic links should be followed
207
     * @return void
208
     */
209 0
    public function setFollowSymlinks($followSymlinks)
210
    {
211 0
        $this->fileset->setExpandSymbolicLinks($followSymlinks);
212
    }
213

214
    /**
215
     * Indicates whether there are any selectors here.
216
     *
217
     * @return boolean Whether any selectors are in this container
218
     */
219 0
    public function hasSelectors()
220
    {
221 0
        return $this->fileset->hasSelectors();
222
    }
223

224
    /**
225
     * Gives the count of the number of selectors in this container
226
     *
227
     * @return int The number of selectors in this container
228
     */
229 0
    public function count()
230
    {
231 0
        return $this->fileset->count();
232
    }
233

234
    /**
235
     * Returns the set of selectors as an array.
236
     *
237
     * @param  Project $p
238
     * @return array FileSelector[] An array of selectors in this container
239
     */
240 0
    public function getSelectors(Project $p)
241
    {
242 0
        return $this->fileset->getSelectors($p);
243
    }
244

245
    /**
246
     * Returns an enumerator for accessing the set of selectors.
247
     *
248
     * @return array an enumerator that goes through each of the selectors
249
     */
250 0
    public function selectorElements()
251
    {
252 0
        return $this->fileset->selectorElements();
253
    }
254

255
    /**
256
     * Add a new selector into this container.
257
     *
258
     * @param  FileSelector $selector the new selector to add
259
     */
260 0
    public function appendSelector(FileSelector $selector)
261
    {
262 0
        $this->fileset->appendSelector($selector);
263
    }
264

265
    /* Methods below all add specific selectors */
266

267
    /**
268
     * add a "Select" selector entry on the selector list
269
     */
270 0
    public function addSelector(SelectSelector $selector)
271
    {
272 0
        $this->fileset->addSelector($selector);
273
    }
274

275
    /**
276
     * add an "And" selector entry on the selector list
277
     */
278 0
    public function addAnd(AndSelector $selector)
279
    {
280 0
        $this->fileset->addAnd($selector);
281
    }
282

283
    /**
284
     * add an "Or" selector entry on the selector list
285
     */
286 0
    public function addOr(OrSelector $selector)
287
    {
288 0
        $this->fileset->addOr($selector);
289
    }
290

291
    /**
292
     * add a "Not" selector entry on the selector list
293
     */
294 0
    public function addNot(NotSelector $selector)
295
    {
296 0
        $this->fileset->addNot($selector);
297
    }
298

299
    /**
300
     * add a "None" selector entry on the selector list
301
     */
302 0
    public function addNone(NoneSelector $selector)
303
    {
304 0
        $this->fileset->addNone($selector);
305
    }
306

307
    /**
308
     * add a majority selector entry on the selector list
309
     */
310 0
    public function addMajority(MajoritySelector $selector)
311
    {
312 0
        $this->fileset->addMajority($selector);
313
    }
314

315
    /**
316
     * add a selector date entry on the selector list
317
     */
318 0
    public function addDate(DateSelector $selector)
319
    {
320 0
        $this->fileset->addDate($selector);
321
    }
322

323
    /**
324
     * add a selector size entry on the selector list
325
     */
326 0
    public function addSize(SizeSelector $selector)
327
    {
328 0
        $this->fileset->addSize($selector);
329
    }
330

331
    /**
332
     * add a selector filename entry on the selector list
333
     */
334 0
    public function addFilename(FilenameSelector $selector)
335
    {
336 0
        $this->fileset->addFilename($selector);
337
    }
338

339
    /**
340
     * add an extended selector entry on the selector list
341
     *
342
     * @return ExtendSelector
343
     */
344 0
    public function addCustom(ExtendSelector $selector)
345
    {
346 0
        return $this->fileset->addCustom($selector);
347
    }
348

349
    /**
350
     * add a contains selector entry on the selector list
351
     */
352 0
    public function addContains(ContainsSelector $selector)
353
    {
354 0
        $this->fileset->addContains($selector);
355
    }
356

357
    /**
358
     * add a present selector entry on the selector list
359
     */
360 0
    public function addPresent(PresentSelector $selector)
361
    {
362 0
        $this->fileset->addPresent($selector);
363
    }
364

365
    /**
366
     * add a depth selector entry on the selector list
367
     */
368 0
    public function addDepth(DepthSelector $selector)
369
    {
370 0
        $this->fileset->addDepth($selector);
371
    }
372

373
    /**
374
     * add a depends selector entry on the selector list
375
     */
376 0
    public function addDepend(DependSelector $selector)
377
    {
378 0
        $this->fileset->addDepend($selector);
379
    }
380

381
    /**
382
     * add a executable selector entry on the selector list
383
     */
384 0
    public function addExecutable(ExecutableSelector $selector)
385
    {
386 0
        $this->fileset->addExecutable($selector);
387
    }
388

389
    /**
390
     * add a readable selector entry on the selector list
391
     */
392 0
    public function addReadable(ReadableSelector $selector)
393
    {
394 0
        $this->fileset->addReadable($selector);
395
    }
396

397
    /**
398
     * add a writable selector entry on the selector list
399
     */
400 0
    public function addWritable(WritableSelector $selector)
401
    {
402 0
        $this->fileset->addWritable($selector);
403
    }
404

405
    /**
406
     * add a different selector entry on the selector list
407
     */
408 0
    public function addDifferent(DifferentSelector $selector)
409
    {
410 0
        $this->fileset->addDifferent($selector);
411
    }
412

413
    /**
414
     * add a type selector entry on the selector list
415
     *
416
     * @param TypeSelector $selector
417
     */
418 0
    public function addType(TypeSelector $selector)
419
    {
420 0
        $this->fileset->addType($selector);
421
    }
422

423
    /**
424
     * add a contains selector entry on the selector list
425
     *
426
     * @param ContainsRegexpSelector $selector
427
     */
428 0
    public function addContainsRegexp(ContainsRegexpSelector $selector)
429
    {
430 0
        $this->fileset->addContainsRegexp($selector);
431
    }
432

433 0
    public function addSymlink(SymlinkSelector $selector)
434
    {
435 0
        $this->fileset->addSymlink($selector);
436
    }
437

438
    /**
439
     * Accessor for the implict fileset.
440
     *
441
     * @return FileSet
442
     */
443 0
    final protected function getImplicitFileSet()
444
    {
445 0
        return $this->fileset;
446
    }
447
}

Read our documentation on viewing source code .

Loading