summaryrefslogtreecommitdiff
path: root/framework/Web/UI/WebControls/TReadOnlyDataSource.php
blob: 4af50348122983000456c750cac4276d6caf618d (plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
/**
 * IDataSource, TDataSourceControl, TReadOnlyDataSource class file
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @link http://www.pradosoft.com/
 * @copyright Copyright &copy; 2005-2014 PradoSoft
 * @license http://www.pradosoft.com/license/
 * @package Prado\Web\UI\WebControls
 */

namespace Prado\Web\UI\WebControls;

/**
 * TDataSourceControl class
 *
 * @author Qiang Xue <qiang.xue@gmail.com>
 * @package Prado\Web\UI\WebControls
 * @since 3.0
 */
class TReadOnlyDataSource extends TDataSourceControl
{
	private $_dataSource;
	private $_dataMember;

	public function __construct($dataSource,$dataMember)
	{
		if(!is_array($dataSource) && !($dataSource instanceof IDataSource) && !($dataSource instanceof Traversable))
			throw new TInvalidDataTypeException('readonlydatasource_datasource_invalid');
		$this->_dataSource=$dataSource;
		$this->_dataMember=$dataMember;
	}

	public function getView($viewName)
	{
		if($this->_dataSource instanceof IDataSource)
			return $this->_dataSource->getView($viewName);
		else
			return new TReadOnlyDataSourceView($this,$this->_dataMember,$this->_dataSource);
	}
}