2014-05-20 57 views

回答

0

的唯一方法

外部PHP文件傳遞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; 
    } 
}