Propel API
Class

Rule

class Rule extends XMLElement

Data about a validation rule used in an application.

Methods

loadFromXML(array $attributes)

This is the entry point method for loading data from XML.

from XMLElement
array getAttributes()

Returns the assoc array of attributes.

from XMLElement
mixed getAttribute(string $name, mixed $defaultValue = null)

Gets a particular attribute by [case-insensitive] name.

from XMLElement
appendXml(DOMNode $node)

VendorInfo addVendorInfo(mixed $data)

Sets an associated VendorInfo object.

from XMLElement
VendorInfo getVendorInfoForType($type)

Gets the any associated VendorInfo object.

from XMLElement
string getConfiguredBehavior(string $bname)

Find the best class name for a given behavior Looks in build.properties for path like propel.behavior.[bname].class If not found, tries to autoload [Bname]Behavior If no success, returns 'Behavior'

from XMLElement
toString()

String representation of the current object.

from XMLElement
__toString()

Magic string method

from XMLElement
setValidator(Validator $validator)

Sets the owning validator for this rule.

Validator getValidator()

Gets the owning validator for this rule.

setClass(string $classname)

Sets the dot-path name of class to use for rule.

string getClass()

Gets the dot-path name of class to use for rule.

setName(string $name)

Sets the name of the validator for this rule.

string getName()

Gets the name of the validator for this rule.

setValue(string $value)

Sets the value parameter for this validator rule.

string getValue()

Gets the value parameter for this validator rule.

setMessage(string $message)

Sets the message that will be displayed to the user if validation fails.

string getMessage()

Gets the message that will be displayed to the user if validation fails.

Details

in XMLElement at line 47
public loadFromXML(array $attributes)

This is the entry point method for loading data from XML.

It calls a setupObject() method that must be implemented by the child class.

Parameters

array $attributes The attributes for the XML tag.

in XMLElement at line 58
public array getAttributes()

Returns the assoc array of attributes.

All attribute names (keys) are lowercase.

Return Value

array

in XMLElement at line 70
public mixed getAttribute(string $name, mixed $defaultValue = null)

Gets a particular attribute by [case-insensitive] name.

If attribute is not set then the $defaultValue is returned.

Parameters

string $name The [case-insensitive] name of the attribute to lookup.
mixed $defaultValue The default value to use in case the attribute is not set.

Return Value

mixed The value of the attribute or $defaultValue if not set.

at line 176
public appendXml(DOMNode $node)

Parameters

DOMNode $node

See also

XMLElement::appendXml(DOMNode)

in XMLElement at line 106
public VendorInfo addVendorInfo(mixed $data)

Sets an associated VendorInfo object.

Parameters

mixed $data VendorInfo object or XML attrib data (array)

Return Value

VendorInfo

in XMLElement at line 123
public VendorInfo getVendorInfoForType($type)

Gets the any associated VendorInfo object.

Parameters

$type

Return Value

VendorInfo

in XMLElement at line 142
public string getConfiguredBehavior(string $bname)

Find the best class name for a given behavior Looks in build.properties for path like propel.behavior.[bname].class If not found, tries to autoload [Bname]Behavior If no success, returns 'Behavior'

Parameters

string $bname behavior name, e.g. 'timestampable'

Return Value

string behavior class name, e.g. 'TimestampableBehavior'

in XMLElement at line 165
public toString()

String representation of the current object.

This is an xml representation with the XML declaration removed.

See also

appendXml()

in XMLElement at line 178
public __toString()

Magic string method

See also

toString()

at line 67
public setValidator(Validator $validator)

Sets the owning validator for this rule.

Parameters

Validator $validator

See also

Validator::addRule()

at line 76
public Validator getValidator()

Gets the owning validator for this rule.

Return Value

Validator

at line 87
public setClass(string $classname)

Sets the dot-path name of class to use for rule.

If no class is specified in XML, then a classname will
be built based on the 'name' attrib.

Parameters

string $classname dot-path classname (e.g. myapp.propel.MyValidator)

at line 98
public string getClass()

Gets the dot-path name of class to use for rule.

If no class was specified, this method will build a default classname
based on the 'name' attribute. E.g. 'maxLength' -> 'propel.validator.MaxLengthValidator'

Return Value

string dot-path classname (e.g. myapp.propel.MyValidator)

at line 112
public setName(string $name)

Sets the name of the validator for this rule.

This name is used to build the classname if none was specified.

Parameters

string $name Validator name for this rule (e.g. "maxLength", "required").

See also

getClass()

at line 121
public string getName()

Gets the name of the validator for this rule.

Return Value

string Validator name for this rule (e.g. "maxLength", "required").

at line 132
public setValue(string $value)

Sets the value parameter for this validator rule.

Note: not all validators need a value parameter (e.g. 'required' validator
does not).

Parameters

string $value

at line 141
public string getValue()

Gets the value parameter for this validator rule.

Return Value

string

at line 154
public setMessage(string $message)

Sets the message that will be displayed to the user if validation fails.

This message may be a Gettext msgid (if translation="gettext") or some other
id for an alternative not-yet-supported translation system. It may also
be a simple, single-language string.

Parameters

string $message

See also

setTranslation()

at line 167
public string getMessage()

Gets the message that will be displayed to the user if validation fails.

This message may be a Gettext msgid (if translation="gettext") or some other
id for an alternative not-yet-supported translation system. It may also
be a simple, single-language string.

Return Value

string

See also

setTranslation()