Symfony2 API
Class

Symfony\Component\Config\Definition\Builder\ExprBuilder

class ExprBuilder

This class builds an if expression.

Properties

$ifPart
$thenPart

Methods

__construct(NodeDefinition $node)

Constructor

ExprBuilder always(Closure $then = null)

Marks the expression as being always used.

ExprBuilder ifTrue(Closure $closure = null)

Sets a closure to use as tests.

ExprBuilder ifString()

Tests if the value is a string.

ExprBuilder ifNull()

Tests if the value is null.

ExprBuilder ifArray()

Tests if the value is an array.

ExprBuilder ifInArray(array $array)

Tests if the value is in an array.

ExprBuilder ifNotInArray(array $array)

Tests if the value is not in an array.

ExprBuilder then(Closure $closure)

Sets the closure to run if the test pass.

ExprBuilder thenEmptyArray()

Sets a closure returning an empty array.

ExprBuilder thenInvalid(string $message)

Sets a closure marking the value as invalid at validation time.

ExprBuilder thenUnset()

Sets a closure unsetting this key of the array at validation time.

NodeDefinition end()

Returns the related node

static array buildExpressions(array $expressions)

Builds the expressions.

Details

at line 32
public __construct(NodeDefinition $node)

Constructor

Parameters

NodeDefinition $node The related node

at line 44
public ExprBuilder always(Closure $then = null)

Marks the expression as being always used.

Parameters

Closure $then

Return Value

ExprBuilder

at line 64
public ExprBuilder ifTrue(Closure $closure = null)

Sets a closure to use as tests.

The default one tests if the value is true.

Parameters

Closure $closure

Return Value

ExprBuilder

at line 80
public ExprBuilder ifString()

Tests if the value is a string.

Return Value

ExprBuilder

at line 92
public ExprBuilder ifNull()

Tests if the value is null.

Return Value

ExprBuilder

at line 104
public ExprBuilder ifArray()

Tests if the value is an array.

Return Value

ExprBuilder

at line 118
public ExprBuilder ifInArray(array $array)

Tests if the value is in an array.

Parameters

array $array

Return Value

ExprBuilder

at line 132
public ExprBuilder ifNotInArray(array $array)

Tests if the value is not in an array.

Parameters

array $array

Return Value

ExprBuilder

at line 146
public ExprBuilder then(Closure $closure)

Sets the closure to run if the test pass.

Parameters

Closure $closure

Return Value

ExprBuilder

at line 158
public ExprBuilder thenEmptyArray()

Sets a closure returning an empty array.

Return Value

ExprBuilder

at line 176
public ExprBuilder thenInvalid(string $message)

Sets a closure marking the value as invalid at validation time.

if you want to add the value of the node in your message just use a %s placeholder.

Parameters

string $message

Return Value

ExprBuilder

Exceptions

InvalidArgumentException

at line 190
public ExprBuilder thenUnset()

Sets a closure unsetting this key of the array at validation time.

Return Value

ExprBuilder

Exceptions

UnsetKeyException

at line 204
public NodeDefinition end()

Returns the related node

Return Value

NodeDefinition

Exceptions

RuntimeException

at line 223
static public array buildExpressions(array $expressions)

Builds the expressions.

Parameters

array $expressions An array of ExprBuilder instances to build

Return Value

array