如何从外部PHP文件检查symfony 1.4中的isAuthenticated
或isLogged
?
外部PHP文件位于/web/js/filemanager.php
将isAuthenticated传递给另一个外部php文件的唯一方法是传递一个sfUser类的对象
@app/前端/模块/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');
}
}
关于你的样本类
<?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;
}
}