code/model/database.php
public function setTable($table)
    {
        if(!($table instanceof DatabaseTableInterface))
        {
            if(is_string($table) && strpos($table, '.') === false )
            {
                $identifier         = $this->getIdentifier()->toArray();
                $identifier['path'] = array('database', 'table');
                $identifier['name'] = StringInflector::pluralize(StringInflector::underscore($table));

                $identifier = $this->getIdentifier($identifier);
            }
            else  $identifier = $this->getIdentifier($table);

            if($identifier->path[1] != 'table') {
                throw new \UnexpectedValueException('Identifier: '.$identifier.' is not a table identifier');
            }

            $table = $identifier;
        }

        $this->_table = $table;

        return $this;
    }
public function setTable($table)
    {
        if(!($table instanceof DatabaseTableInterface))
        {
            if(is_string($table) && strpos($table, '.') === false )
            {
                $identifier         = $this->getIdentifier()->toArray();
                $identifier['path'] = array('database', 'table');
                $identifier['name'] = StringInflector::pluralize(StringInflector::underscore($table));

                $identifier = $this->getIdentifier($identifier);
            }
            else  $identifier = $this->getIdentifier($table);

            if($identifier->path[1] != 'table') {
                throw new \UnexpectedValueException('Identifier: '.$identifier.' is not a table identifier');
            }

            $table = $identifier;
        }

        $this->_table = $table;

        return $this;
    }
public function setTable ( $ table ) { if ( ! ( $ table instanceof DatabaseTableInterface ) ) { if ( is_string ( $ table ) && strpos ( $ table , '.' ) === false ) { $ identifier = $ this -> getIdentifier ( ) -> toArray ( ) ; $ identifier [ 'path' ] = array ( 'database' , 'table' ) ; $ identifier [ 'name' ] = StringInflector :: pluralize ( StringInflector :: underscore ( $ table ) ) ; $ identifier = $ this -> getIdentifier ( $ identifier ) ; } else $ identifier = $ this -> getIdentifier ( $ table ) ; if ( $ identifier -> path [ 1 ] != 'table' ) { throw new \ UnexpectedValueException ( 'Identifier: ' . $ identifier . ' is not a table identifier' ) ; } $ table = $ identifier ; } $ this -> _table = $ table ; return $ this ; }
Method to set a table object attached to the model

@param   mixed   $table An object that implements ObjectInterface, ObjectIdentifier object
or valid identifier string
@throws  \UnexpectedValueException   If the identifier is not a table identifier
@return  ModelDatabase
Method to set a table object attached to the model