PHP Objects, Patterns and Practice (3rd edition)

(Barry) #1

CHAPTER 19 ■ AUTOMATED BUILD WITH PHING


Table 19–3. Some Attributes of the fileset Element


Attribute Required Description

Id No A unique handle for referring to the element

Dir No The fileset directory

Excludes No A list of patterns for exclusion

Includes No A list of patterns for inclusion

Refid No Current fileset is a reference to fileset of given ID

PatternSet


As you build up patterns in your fileset elements (and in others), there is a danger that you will begin to
repeat groups of exclude and include elements. In my previous example, I defined patterns for test files
and regular code files. I may add to these over time (perhaps I wish to include .conf and .inc extensions
to my definition of code files). If I define other fileset elements that also use these patterns, I will be
forced to make any adjustments across all relevant fileset elements.
You can overcome this problem by grouping patterns into patternset elements. The patternset
element groups include and exclude elements so that they can be referenced later from within other
types. Here I extract the include and exclude elements from my fileset example and add them to
patternset elements:











I create two patternset elements, setting their id attributes to inc_code and exc_test respectively.
inc_code contains the include elements for including code files, and exc_test contains the exclude files
for excluding test files. I can now reference these patternset elements within a fileset:






To reference an existing patternset, you must use another patternset element. The second element
must set a single attribute: refid. The refid attribute should refer to the id of the patternset element
you wish to use in the current context. In this way, I can reuse patternset elements:

Free download pdf