Advertisement
Guest User

MyUniqueObject

a guest
Jan 26th, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Core\Validator;
  4.  
  5. use DoctrineModule\Validator\UniqueObject;
  6.  
  7. /**
  8.  * Class that validates if objects exist in a given repository with a given list of matched fields only once.
  9.  *
  10.  * @license MIT
  11.  * @link    http://www.doctrine-project.org/
  12.  * @author  Oskar Bley <oskar@programming-php.net>
  13.  */
  14. class MyUniqueObject extends UniqueObject
  15. {
  16.    
  17.     protected function error($messageKey, $value = null)
  18.     {
  19.         if(is_array($value)){
  20.         $myKey = $this->getOption('myKey') ? $this->getOption('myKey') : 'servico';
  21.         return parent::error($messageKey, $value[$myKey]);
  22.     }
  23.     return parent::error($messageKey, $value);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement