<?php
/**
 * Created by PhpStorm.
 * User: Nikola
 * Date: 1/30/2015
 * Time: 1:40 PM
 */

class gumasValidator extends CValidator {

    public $uniqatt;

    protected function validateAttribute($object,$attribute)
    {
       // print_r($object->attributes);
      //  echo $attribute;
        $polozaji = array();
        $i=0;
        foreach($object->attributes as $key=>$value){
            if(($key == $this->uniqatt) ){
                $polozaji[$i++] = $value;
            }
        }

        if($this->array_has_dupes($polozaji)){
            $message = $this->message!==null ? $this->message : "The Combination of places should be unique in the current context.";

                $this->addError($object,$this->uniqatt,$message);

        }
    }

    function array_has_dupes($array) {
        // streamline per @Felix
        return count($array) !== count(array_unique($array));
    }

}

