知识点滴

专注于php应用开发

标签

Annotation array_merge composer Debugbar git gitlab indexer json message server nfs nginx opcache pack php php-fpm php_doc php_session rabbitmq redis Reflection safe sphinx squid statis swoole twig Vagrant varnish vue vue_dom wordpress plug xcache yield 异步io

分类

  • git
  • go
  • javascript
  • linux sa
  • php
  • safe
  • search
  • service
  • 未分类

归档

  • 2018年7月
  • 2017年12月
  • 2017年9月
  • 2017年7月
  • 2017年6月
  • 2017年4月
  • 2017年3月
  • 2016年12月
  • 2016年11月
  • 2016年9月
  • 2016年6月
  • 2016年5月
  • 2016年4月
  • 2016年3月
  • 2016年2月
  • 2016年1月
  • 2015年12月
  • 2015年11月
  • 2015年10月
  • 2015年9月
  • 2015年7月
  • 2015年6月
  • 2015年5月

功能

  • 登录
  • 条目feed
  • 评论feed
  • WordPress.org
蜀ICP备15000937号-1

标签: Reflection

反射获取对象定义路径

2017年4月13日 by admin·0评论

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
    /**
     * 重新定义视图文件路径
     * @param $file
     * @return string
     */
    protected function getTemplate($file){
        $reflection = new \ReflectionClass($this);
        $path = dirname($reflection->getFileName());
        return $path . '/views/' . $file  . ".php";
    }
 
    protected function setTemplate($tpl){
        if($this->actionDirAsView){
            $tpl = $this->getTemplate($tpl);
        }
        return parent::setTemplate($tpl);
    }
 
    protected function getDefaultTemplate(){
        if($this->actionDirAsView){
            return basename($this->id) ;
        } else {
            return parent::getDefaultTemplate();
        }
    }

 

由WordPress自豪地提供. 主题:Flat 1.7.8 by Themeisle