GDS\Schema::setEntityClass PHP Метод

setEntityClass() закрытый публичный Метод

Must be GDS\Entity, or a sub-class of it
final public setEntityClass ( $str_class )
$str_class
    public final function setEntityClass($str_class)
    {
        if (class_exists($str_class)) {
            if (is_a($str_class, '\\GDS\\Entity', TRUE)) {
                $this->str_entity_class = $str_class;
            } else {
                throw new \InvalidArgumentException('Cannot set an Entity class that does not extend "GDS\\Entity": ' . $str_class);
            }
        } else {
            throw new \InvalidArgumentException('Cannot set missing Entity class: ' . $str_class);
        }
        return $this;
    }

Usage Example

Пример #1
0
 public function getSchema()
 {
     static $schema = false;
     if ($schema === false) {
         $schema = new Schema($this->getKind());
         $schema_def = $this->getDefinition();
         foreach ($schema_def as $name => $field) {
             if (!isset($field['type'])) {
                 throw new Exception('Error, type not set in field deffinition');
             }
             $func = 'add' . ucwords($field['type']);
             $index = isset($field['index']) ? $field['index'] : false;
             $schema->{$func}($name, $index);
             $schema->setEntityClass(get_called_class());
         }
     }
     return $schema;
 }