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

Robo47_Validate_Doctrine_NoRecordExists Class Reference

Inheritance diagram for Robo47_Validate_Doctrine_NoRecordExists:
Inheritance graph
[legend]
Collaboration diagram for Robo47_Validate_Doctrine_NoRecordExists:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 getExclude ()
 Returns the set exclude clause.
 getField ()
 Returns the set field.
 getTable ()
 Get Table.
 isValid ($value)
 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 NoRecordExists.php.


Member Function Documentation

Robo47_Validate_Doctrine_Abstract::_query ( value  )  [protected, inherited]

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 Robo47_Validate_Doctrine_Abstract::getExclude(), Robo47_Validate_Doctrine_Abstract::getField(), and Robo47_Validate_Doctrine_Abstract::getTable().

Referenced by Robo47_Validate_Doctrine_RecordExists::isValid(), and 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 (  )  [inherited]

Returns the set exclude clause.

Returns:
string|array

Definition at line 79 of file Abstract.php.

Referenced by Robo47_Validate_Doctrine_Abstract::_query().

    {
        return $this->_exclude;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::getField (  )  [inherited]

Returns the set field.

Returns:
string|array

Definition at line 101 of file Abstract.php.

Referenced by Robo47_Validate_Doctrine_Abstract::_query().

    {
        return $this->_field;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::getTable (  )  [inherited]

Get Table.

Returns:
Doctrine_Table

Definition at line 142 of file Abstract.php.

Referenced by Robo47_Validate_Doctrine_Abstract::_query(), and Robo47_Validate_Doctrine_Abstract::setTable().

    {
        return $this->_table;
    }

Here is the caller graph for this function:

Robo47_Validate_Doctrine_NoRecordExists::isValid ( value  ) 

Definition at line 37 of file NoRecordExists.php.

References Robo47_Validate_Doctrine_Abstract::_query().

    {
        $valid = true;
        $this->_setValue($value);

        $result = $this->_query($value);
        if (count($result) != 0) {
            $valid = false;
            $this->_error(self::ERROR_RECORD_FOUND);
        }

        return $valid;
    }

Here is the call graph for this function:

Robo47_Validate_Doctrine_Abstract::setExclude ( exclude  )  [inherited]

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 Robo47_Validate_Doctrine_Abstract::__construct().

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

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::setField ( field  )  [inherited]

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 Robo47_Validate_Doctrine_Abstract::__construct().

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

Here is the caller graph for this function:

Robo47_Validate_Doctrine_Abstract::setTable ( table  )  [inherited]

Set Table.

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

Definition at line 124 of file Abstract.php.

References Robo47_Validate_Doctrine_Abstract::getTable().

Referenced by Robo47_Validate_Doctrine_Abstract::__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, inherited]

Definition at line 59 of file Abstract.php.

Robo47_Validate_Doctrine_Abstract::$_field = '' [protected, inherited]

Definition at line 55 of file Abstract.php.

Robo47_Validate_Doctrine_Abstract::$_messageTemplates [protected, inherited]
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, inherited]

Definition at line 51 of file Abstract.php.

const Robo47_Validate_Doctrine_Abstract::ERROR_NO_RECORD_FOUND = 'noRecordFound' [inherited]

Error constants.

Definition at line 38 of file Abstract.php.

const Robo47_Validate_Doctrine_Abstract::ERROR_RECORD_FOUND = 'recordFound' [inherited]

Definition at line 39 of file Abstract.php.


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