知识点滴

专注于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

月度归档: 2017 年 4 月

反射获取对象定义路径

2017年4月13日 by admin·反射获取对象定义路径已关闭评论

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