1: <?php
2: /**
3: * CExtController class file.
4: *
5: * @author Qiang Xue <qiang.xue@gmail.com>
6: * @link http://www.yiiframework.com/
7: * @copyright 2008-2013 Yii Software LLC
8: * @license http://www.yiiframework.com/license/
9: */
10:
11:
12: /**
13: * CExtController is the base class for controllers distributed as extension.
14: *
15: * The main purpose of CExtController is to redefine the {@link viewPath} property
16: * so that it points to the "views" subdirectory under the directory containing
17: * the controller class file.
18: *
19: * @property string $viewPath The directory containing the view files for this controller.
20: *
21: * @author Qiang Xue <qiang.xue@gmail.com>
22: * @package system.web
23: * @since 1.0
24: */
25: class CExtController extends CController
26: {
27: private $_viewPath;
28:
29: /**
30: * Returns the directory containing view files for this controller.
31: * This method overrides the parent implementation by specifying the view path
32: * to be the "views" subdirectory under the directory containing the controller
33: * class file.
34: * @return string the directory containing the view files for this controller.
35: */
36: public function getViewPath()
37: {
38: if($this->_viewPath===null)
39: {
40: $class=new ReflectionClass(get_class($this));
41: $this->_viewPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.'views';
42: }
43: return $this->_viewPath;
44: }
45:
46: /**
47: * @param string $value the directory containing the view files for this controller.
48: */
49: public function setViewPath($value)
50: {
51: $this->_viewPath=$value;
52: }
53: }
54: