lithium\data\model\Query::models PHP Method

models() public method

Return the generated aliases mapped to their corresponding model
public models ( Source $source = null ) : array
$source lithium\data\Source Instance of the data source to use for conversion.
return array Map between aliases and their corresponding fully-namespaced model names.
    public function models(Source $source = null)
    {
        if ($source) {
            $this->applyStrategy($source);
        }
        return $this->_models;
    }

Usage Example

Example #1
0
 public function testModels()
 {
     $model = 'lithium\\tests\\mocks\\data\\model\\MockQueryPost';
     $query = new Query(array('model' => $model, 'with' => 'MockQueryComment'));
     $expected = array('MockQueryPost' => 'lithium\\tests\\mocks\\data\\model\\MockQueryPost', 'MockQueryComment' => 'lithium\\tests\\mocks\\data\\model\\MockQueryComment');
     $this->assertEqual($expected, $query->models($this->db));
     $query = new Query(array('model' => $model, 'alias' => 'Post', 'with' => array('MockQueryComment' => array('alias' => 'Comment'), 'MockQueryComment.MockQueryPost' => array('alias' => 'Post2'))));
     $expected = array('Post' => 'lithium\\tests\\mocks\\data\\model\\MockQueryPost', 'Comment' => 'lithium\\tests\\mocks\\data\\model\\MockQueryComment', 'Post2' => 'lithium\\tests\\mocks\\data\\model\\MockQueryPost');
     $this->assertEqual($expected, $query->models($this->db));
 }
All Usage Examples Of lithium\data\model\Query::models