# classes/phing/types/selectors/PresentSelector.php

Selector that filters files based on whether they appear in another directory tree. It can contain a mapper element, so isn't available as an ExtendSelector (since those parameters can't hold other elements).

author
  Hans Lellelid <hans@xmpl.org> (Phing)
author
  Bruce Atherton <bruce@callenish.com> (Ant)
package
  phing.types.selectors

## \PresentSelector
jump to top

Selector that filters files based on whether they appear in another directory tree. It can contain a mapper element, so isn't available as an ExtendSelector (since those parameters can't hold other elements).

This class handles the common description attribute and provides a default implementation for reference handling and checking for circular references that is appropriate for types that can not be nested inside elements of the same type (i.e. patternset but not path)

Extends from
  \BaseSelector
author
  Hans Lellelid <hans@xmpl.org> (Phing)
author
  Bruce Atherton <bruce@callenish.com> (Ant)
package
  phing.types.selectors
version
  $Revision: 526 $

### Properties

`$destmustexist= 'true'`
Default value `true` Details

Type

`$filePresence= 'array'`
static
Default value `array` Details

Type

`$map= 'null'`
Default value `null` Details

Type

`$mapperElement= 'null'`
Default value `null` Details

Type

`$targetdir= 'null'`
Default value `null` Details

Type

### Methods

`createMapper( ) :`
Defines the FileNameMapper to use (nested mapper element).
Details

throws

`isSelected( \basedir $basedir, \filename $filename, \file $file ) : \whether`
The heart of the matter. This is where the selector gets to decide on the inclusion of a file in a particular fileset.
Parameters

Name | Type | Description
--- | --- | ---
$basedir | \basedir | the base directory the scan is being done from
$filename | \filename | is the name of the file to check
$file | \file | is a PhingFile object the selector can use

Returns

Type | Description
--- | ---
\whether |

`setPresent( string $fp ) :`
This sets whether to select a file if its dest file is present.

It could be a `negate` boolean, but by doing things this way, we get some documentation on how the system works. A user looking at the documentation should clearly understand that the ONLY files whose presence is being tested are those that already exist in the source directory, hence the lack of a `destonly` option.

Parameters

Name | Type | Description
--- | --- | ---
$fp | string | An attribute set to either `srconly` or `both`.

`setTargetdir( \targetdir $targetdir ) :`
The name of the file or directory which is checked for matching files.
Parameters

Name | Type | Description
--- | --- | ---
$targetdir | \targetdir | the directory to scan looking for matching files.

`toString( ) :`
`verifySettings( ) :`
Checks to make sure all settings are kosher. In this case, it means that the targetdir attribute has been set and we have a mapper.
Documentation was generated by DocBlox 0.13.1.