Perforce Chronicle 2012.2/486814
API Documentation
|
Validates string for suitability as a content id. More...
Public Member Functions | |
__construct () | |
Add a message templates upon instantiation. | |
allowEmpty () | |
Returns the current setting for allowEmpty; default value is false. | |
allowExisting () | |
Returns the current setting for allowExisting; default value is true. | |
allowNonExistent () | |
Returns the current setting for allowNonExistent; default value is true. | |
getAdapter () | |
Returns the currently specified adapter or null if unset. | |
isValid ($value) | |
Defined by Zend_Validate_Interface. | |
setAdapter (P4Cms_Record_Adapter $adapter=null) | |
Allows the caller to specify an adapter which will be used when performing 'onlyExisting' checks. | |
setAllowEmpty ($allowed) | |
Updates the setting for allowEmpty. | |
setAllowExisting ($allowed) | |
Updates the setting for allowExisting. | |
setAllowNonExistent ($allowed) | |
Updates the setting for allowNonExistent. | |
Public Attributes | |
const | DOESNT_EXIST = 'doesntExist' |
const | EXISTS = 'exists' |
Protected Attributes | |
$_adapter = null | |
$_allowEmpty = false | |
$_allowExisting = true | |
$_allowForwardSlash = false | |
$_allowNonExistent = true |
Validates string for suitability as a content id.
P4Cms_Validate_ContentId::__construct | ( | ) |
Add a message templates upon instantiation.
{ $message = "The specified content id does not exist."; $this->_messageTemplates[self::DOESNT_EXIST] = $message; $message = "The specified content id already exists."; $this->_messageTemplates[self::EXISTS] = $message; }
P4Cms_Validate_ContentId::allowEmpty | ( | ) |
Returns the current setting for allowEmpty; default value is false.
{ return (bool) $this->_allowEmpty; }
P4Cms_Validate_ContentId::allowExisting | ( | ) |
Returns the current setting for allowExisting; default value is true.
{ return (bool) $this->_allowExisting; }
P4Cms_Validate_ContentId::allowNonExistent | ( | ) |
Returns the current setting for allowNonExistent; default value is true.
{ return (bool) $this->_allowNonExistent; }
P4Cms_Validate_ContentId::getAdapter | ( | ) |
Returns the currently specified adapter or null if unset.
{
return $this->_adapter;
}
P4Cms_Validate_ContentId::isValid | ( | $ | value | ) |
Defined by Zend_Validate_Interface.
Checks if the given string is a valid content type id.
string | $value | The value to validate. |
Reimplemented from P4Cms_Validate_RecordId.
{ // If we allow empty values and receive one; skip parent and return success if ($this->allowEmpty() && !strlen($value)) { return true; } $result = parent::isValid($value); // If we passed the basic sanity checks and are set to // dis-allow non-existent entries validate entries presence if ($result && !$this->allowNonExistent()) { if (!P4Cms_Content::exists($value, null, $this->getAdapter())) { $this->_error(self::DOESNT_EXIST); $result = false; } } // dis-allow existing ids (ensure uniqueness) if ($result && !$this->allowExisting()) { if (P4Cms_Content::exists($value, null, $this->getAdapter())) { $this->_error(self::EXISTS); $result = false; } } return $result; }
P4Cms_Validate_ContentId::setAdapter | ( | P4Cms_Record_Adapter $ | adapter = null | ) |
Allows the caller to specify an adapter which will be used when performing 'onlyExisting' checks.
Setting this is optional, the default adapter will be utilized if unset.
P4Cms_Record_Adapter | null | $adapter | storage adapter to use for 'onlyExisting' checks. |
{
$this->_adapter = $adapter;
return $this;
}
P4Cms_Validate_ContentId::setAllowEmpty | ( | $ | allowed | ) |
Updates the setting for allowEmpty.
bool | $allowed | True if empty IDs are permitted, False otherwise |
{
$this->_allowEmpty = (bool) $allowed;
return $this;
}
P4Cms_Validate_ContentId::setAllowExisting | ( | $ | allowed | ) |
Updates the setting for allowExisting.
bool | $allowed | True if existing IDs are permitted, False otherwise |
{
$this->_allowExisting = (bool) $allowed;
return $this;
}
P4Cms_Validate_ContentId::setAllowNonExistent | ( | $ | allowed | ) |
Updates the setting for allowNonExistent.
bool | $allowed | True if non-existent IDs are permitted, False otherwise |
{
$this->_allowNonExistent = (bool) $allowed;
return $this;
}
P4Cms_Validate_ContentId::$_adapter = null [protected] |
P4Cms_Validate_ContentId::$_allowEmpty = false [protected] |
P4Cms_Validate_ContentId::$_allowExisting = true [protected] |
P4Cms_Validate_ContentId::$_allowForwardSlash = false [protected] |
Reimplemented from P4Cms_Validate_RecordId.
P4Cms_Validate_ContentId::$_allowNonExistent = true [protected] |
const P4Cms_Validate_ContentId::DOESNT_EXIST = 'doesntExist' |
const P4Cms_Validate_ContentId::EXISTS = 'exists' |