IndexGenerator.php 600 Bytes
Newer Older
doctrine's avatar
doctrine committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
<?php
class Doctrine_IndexGenerator {
    /**
     * @var string $name
     */
    private $name;
    /**
     * @param string $name
     */
    public function __construct($name) {
        $this->name = $name;
    }
    /**
     * @param Doctrine_Record $record
     * @return mixed
     */
    public function getIndex(Doctrine_Record $record) {
        $value = $record->get($this->name);
        if($value === null)
            throw new Doctrine_Exception("Couldn't create collection index. Record field '".$this->name."' was null.");

        return $value;
    }
}
?>