如何从外部PHP文件中检查 symfony 1.4 中的isAuthenticated
或isLogged
?
位于/web/js/filemanager.php
答案 0 :(得分:0)
通过isAuthenticated到另一个外部php文件的唯一方法是传递sfUser类的对象
@应用程序/前端/模块/ indexAction.class.php
<?php
class modulenameAction extends sfAction
{
public function execute($request)
{
$user = $this->getUser();
$sample = new Sample();
$sample
->setUser($user)
->setOtherFunction($blabla)
->setOtherFunction($blabla);
if ($sample->result()) {
return $this->renderText('Authenticated');
} else return $this->renderText('Not authenticated');
}
}
然后关于你的Sample类
<?php
class Sample
{
private $user;
public function setUser($user)
{
$this->user = $user;
return $this;
}
public function result()
{
if ($this->user->isAuthenticated())
{
return true;
}
return false;
}
}