Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

Robo47_Validate_Doctrine_Abstract Class Reference

Inheritance diagram for Robo47_Validate_Doctrine_Abstract:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 __construct ($table, $field, $exclude=null)
 getExclude ()
 Returns the set exclude clause.
 getField ()
 Returns the set field.
 getTable ()
 Get Table.
 setExclude ($exclude)
 Sets a new exclude clause.
 setField ($field)
 Sets a new field.
 setTable ($table)
 Set Table.

Public Attributes

const ERROR_NO_RECORD_FOUND = 'noRecordFound'
 Error constants.
const ERROR_RECORD_FOUND = 'recordFound'

Protected Member Functions

 _query ($value)
 Run query and returns matches, or null if no matches are found.

Protected Attributes

 $_exclude = null
 $_field = ''
 $_messageTemplates
 $_table = ''

Detailed Description

Definition at line 33 of file Abstract.php.


Constructor & Destructor Documentation

Robo47_Validate_Doctrine_Abstract::__construct ( table,
field,
exclude = null 
)
Parameters:
Doctrine_Table|string $table
string $field
string|array $exclude

Definition at line 67 of file Abstract.php.

References setExclude(), setField(), and setTable().

    {
        $this->setTable($table);
        $this->setField($field);
        $this->setExclude($exclude);
    }

Here is the call graph for this function:


Member Function Documentation

Robo47_Validate_Doctrine_Abstract::_query ( value  )  [protected]

Run query and returns matches, or null if no matches are found.

Parameters:
String $value
Returns:
Doctrine_Collection when matches are found.

Definition at line 153 of file Abstract.php.

References getExclude(), getField(), and getTable().

Referenced by Robo47_Validate_Doctrine_RecordExists::isValid(), and Robo47_Validate_Doctrine_NoRecordExists::isValid().

    {
        $query = $this->getTable()->createQuery();

        $exclude = $this->getExclude();
        if (is_string($exclude) && !empty($exclude)) {
            $query->andWhere($exclude);
        } else if (is_array($exclude) && !empty($exclude)) {
            $query->andWhere($exclude['field'] . ' != ?', $exclude['value']);
        }

        return $query->andWhere($this->getField() . ' = ?', $value)
            ->limit(1)
            ->execute();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::getExclude (  ) 

Returns the set exclude clause.

Returns:
string|array

Definition at line 79 of file Abstract.php.

Referenced by _query().

    {
        return $this->_exclude;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::getField (  ) 

Returns the set field.

Returns:
string|array

Definition at line 101 of file Abstract.php.

Referenced by _query().

    {
        return $this->_field;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::getTable (  ) 

Get Table.

Returns:
Doctrine_Table

Definition at line 142 of file Abstract.php.

Referenced by _query(), and setTable().

    {
        return $this->_table;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::setExclude ( exclude  ) 

Sets a new exclude clause.

Parameters:
string|array $exclude
Returns:
Robo47_Validate_Doctrine_Abstract *Provides Flient Interface*

Definition at line 90 of file Abstract.php.

Referenced by __construct().

    {
        $this->_exclude = $exclude;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::setField ( field  ) 

Sets a new field.

Parameters:
string $field
Returns:
Robo47_Validate_Doctrine_Abstract *Provides Flient Interface*

Definition at line 112 of file Abstract.php.

Referenced by __construct().

    {
        $this->_field = (string) $field;
        return $this;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::setTable ( table  ) 

Set Table.

Parameters:
Doctrine_Table|string $table
Returns:
Robo47_Validate_Doctrine_Abstract *Provides Fluent Interface*

Definition at line 124 of file Abstract.php.

References getTable().

Referenced by __construct().

    {
        if (is_string($table)) {
            $table = Doctrine_Core::getTable($table);
        }
        if (!$table instanceof Doctrine_Table) {
            $message = 'table not instance of Doctrine_Table.';
            throw new Robo47_Log_Writer_Exception($message);
        }
        $this->_table = $table;
        return $this;
    }

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Robo47_Validate_Doctrine_Abstract::$_exclude = null [protected]

Definition at line 59 of file Abstract.php.

Robo47_Validate_Doctrine_Abstract::$_field = '' [protected]

Definition at line 55 of file Abstract.php.

Robo47_Validate_Doctrine_Abstract::$_messageTemplates [protected]
Initial value:
 array(
        self::ERROR_NO_RECORD_FOUND => 'No record matching %value% was found',
        self::ERROR_RECORD_FOUND => 'A record matching %value% was found',
    )

Definition at line 44 of file Abstract.php.

Robo47_Validate_Doctrine_Abstract::$_table = '' [protected]

Definition at line 51 of file Abstract.php.

Error constants.

Definition at line 38 of file Abstract.php.

Definition at line 39 of file Abstract.php.


The documentation for this class was generated from the following file: