【发布时间】:2013-06-06 03:58:30
【问题描述】:
我正在尝试在 laravel 4 中扩展一个 facede,但在尝试调用方法时我只收到下一个错误。
Non-static method App\Libraries\Theme::setActive() should not be called statically
编辑
@Antonio 响应后,将方法更改为静态,让使用关键字 $this-> 在方法内部的威力。
Symfony\Component\Debug\Exception\FatalErrorException 使用
$this 当不在 $active = $this->ensureRegistered($active); 的对象上下文中时
我的代码:
<?php namespace App\Libraries;
use Cartalyst\Themes\Facades\Theme as ThemeBag;
class Theme extends ThemeBag {
/**
* Sets the active theme.
*
* @param mixed $active
* @return Cartalyst\Themes\ThemeInterface
*/
public static function setActive($active)
{
$active = $this->ensureRegistered($active);
if ( ! isset($this->themes[$active->getSlug()]))
{
$this->register($active);
}
$this->active = $active;
include $this->getActive()->getPath() . '\\helpers\\composers.php';
}
}
【问题讨论】: