PRADO PHP Framework
Current file: /Users/knut/Sites/prado/svn/trunk/framework/TApplicationComponent.php
Legend: executed not executed dead code

  Coverage
  Classes Methods Lines
Total
100.00 %100.00%
100.00% 1 / 1
25.00 %25.00%
25.00% 2 / 8
16.67 %16.67%
16.67% 2 / 12
 
TApplicationComponent
100.00 %100.00%
100.00% 1 / 1
25.00 %25.00%
25.00% 2 / 8
16.67 %16.67%
16.67% 2 / 12
 public function getApplication()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function getService()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getRequest()
100.00 %100.00%
100.00% 1 / 1
100.00 %100.00%
100.00% 1 / 1
 public function getResponse()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getSession()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function getUser()
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1
 public function publishAsset($assetPath, $className = NULL)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 5
 public function publishFilePath($fullPath)
0.00 %0.00%
0.00% 0 / 1
0.00 %0.00%
0.00% 0 / 1


       1                 : <?php                                                                                                                                
       2                 : /**                                                                                                                                  
       3                 :  * TApplicationComponent class                                                                                                       
       4                 :  *                                                                                                                                   
       5                 :  * @author Qiang Xue <qiang.xue@gmail.com>                                                                                           
       6                 :  * @link http://www.pradosoft.com/                                                                                                   
       7                 :  * @copyright Copyright &copy; 2005 PradoSoft                                                                                        
       8                 :  * @license http://www.pradosoft.com/license/                                                                                        
       9                 :  * @version $Id: TApplicationComponent.php 2112 2007-08-06 18:58:55Z xue $                                                           
      10                 :  * @package System                                                                                                                   
      11                 :  */                                                                                                                                  
      12                 :                                                                                                                                      
      13                 : /**                                                                                                                                  
      14                 :  * TApplicationComponent class                                                                                                       
      15                 :  *                                                                                                                                   
      16                 :  * TApplicationComponent is the base class for all components that are                                                               
      17                 :  * application-related, such as controls, modules, services, etc.                                                                    
      18                 :  *                                                                                                                                   
      19                 :  * TApplicationComponent mainly defines a few properties that are shortcuts                                                          
      20                 :  * to some commonly used methods. The {@link getApplication Application}                                                             
      21                 :  * property gives the application instance that this component belongs to;                                                           
      22                 :  * {@link getService Service} gives the current running service;                                                                     
      23                 :  * {@link getRequest Request}, {@link getResponse Response} and {@link getSession Session}                                           
      24                 :  * return the request and response modules, respectively;                                                                            
      25                 :  * And {@link getUser User} gives the current user instance.                                                                         
      26                 :  *                                                                                                                                   
      27                 :  * Besides, TApplicationComponent defines two shortcut methods for                                                                   
      28                 :  * publishing private files: {@link publishAsset} and {@link publishFilePath}.                                                       
      29                 :  *                                                                                                                                   
      30                 :  * @author Qiang Xue <qiang.xue@gmail.com>                                                                                           
      31                 :  * @version $Id: TApplicationComponent.php 2112 2007-08-06 18:58:55Z xue $                                                           
      32                 :  * @package System                                                                                                                   
      33                 :  * @since 3.0                                                                                                                        
      34                 :  */                                                                                                                                  
      35                 : class TApplicationComponent extends TComponent                                                                                       
      36                 : {                                                                                                                                    
      37                 : 	/**                                                                                                                                 
      38                 : 	 * @return TApplication current application instance                                                                                
      39                 : 	 */                                                                                                                                 
      40                 : 	public function getApplication()                                                                                                    
      41                 : 	{                                                                                                                                   
      42              83 : 		return Prado::getApplication();                                                                                                    
      43                 : 	}                                                                                                                                   
      44                 :                                                                                                                                      
      45                 : 	/**                                                                                                                                 
      46                 : 	 * @return IService the current service                                                                                             
      47                 : 	 */                                                                                                                                 
      48                 : 	public function getService()                                                                                                        
      49                 : 	{                                                                                                                                   
      50               0 : 		return Prado::getApplication()->getService();                                                                                      
      51                 : 	}                                                                                                                                   
      52                 :                                                                                                                                      
      53                 : 	/**                                                                                                                                 
      54                 : 	 * @return THttpRequest the current user request                                                                                    
      55                 : 	 */                                                                                                                                 
      56                 : 	public function getRequest()                                                                                                        
      57                 : 	{                                                                                                                                   
      58              12 : 		return Prado::getApplication()->getRequest();                                                                                      
      59                 : 	}                                                                                                                                   
      60                 :                                                                                                                                      
      61                 : 	/**                                                                                                                                 
      62                 : 	 * @return THttpResponse the response                                                                                               
      63                 : 	 */                                                                                                                                 
      64                 : 	public function getResponse()                                                                                                       
      65                 : 	{                                                                                                                                   
      66               0 : 		return Prado::getApplication()->getResponse();                                                                                     
      67                 : 	}                                                                                                                                   
      68                 :                                                                                                                                      
      69                 : 	/**                                                                                                                                 
      70                 : 	 * @return THttpSession user session                                                                                                
      71                 : 	 */                                                                                                                                 
      72                 : 	public function getSession()                                                                                                        
      73                 : 	{                                                                                                                                   
      74               0 : 		return Prado::getApplication()->getSession();                                                                                      
      75                 : 	}                                                                                                                                   
      76                 :                                                                                                                                      
      77                 : 	/**                                                                                                                                 
      78                 : 	 * @return IUser information about the current user                                                                                 
      79                 : 	 */                                                                                                                                 
      80                 : 	public function getUser()                                                                                                           
      81                 : 	{                                                                                                                                   
      82               0 : 		return Prado::getApplication()->getUser();                                                                                         
      83                 : 	}                                                                                                                                   
      84                 :                                                                                                                                      
      85                 : 	/**                                                                                                                                 
      86                 : 	 * Publishes a private asset and gets its URL.                                                                                      
      87                 : 	 * This method will publish a private asset (file or directory)                                                                     
      88                 : 	 * and gets the URL to the asset. Note, if the asset refers to                                                                      
      89                 : 	 * a directory, all contents under that directory will be published.                                                                
      90                 : 	 * Also note, it is recommended that you supply a class name as the second                                                          
      91                 : 	 * parameter to the method (e.g. publishAsset($assetPath,__CLASS__) ).                                                              
      92                 : 	 * By doing so, you avoid the issue that child classes may not work properly                                                        
      93                 : 	 * because the asset path will be relative to the directory containing the child class file.                                        
      94                 : 	 *                                                                                                                                  
      95                 : 	 * @param string path of the asset that is relative to the directory containing the specified class file.                           
      96                 : 	 * @param string name of the class whose containing directory will be prepend to the asset path. If null, it means get_class($this).
      97                 : 	 * @return string URL to the asset path.                                                                                            
      98                 : 	 */                                                                                                                                 
      99                 : 	public function publishAsset($assetPath,$className=null)                                                                            
     100                 : 	{                                                                                                                                   
     101               0 : 		if($className===null)                                                                                                              
     102               0 : 			$className=get_class($this);                                                                                                      
     103               0 : 		$class=new ReflectionClass($className);                                                                                            
     104               0 : 		$fullPath=dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath;                                                           
     105               0 : 		return $this->publishFilePath($fullPath);                                                                                          
     106                 : 	}                                                                                                                                   
     107                 :                                                                                                                                      
     108                 : 	/**                                                                                                                                 
     109                 : 	 * Publishes a file or directory and returns its URL.                                                                               
     110                 : 	 * @param string absolute path of the file or directory to be published                                                             
     111                 : 	 * @return string URL to the published file or directory                                                                            
     112                 : 	 */                                                                                                                                 
     113                 : 	public function publishFilePath($fullPath)                                                                                          
     114                 : 	{                                                                                                                                   
     115               0 : 		return Prado::getApplication()->getAssetManager()->publishFilePath($fullPath);                                                     
     116                 : 	}                                                                                                                                   
     117                 : }                                                                                                                                    
     118                 :                                                                                                                                      
     119                 : ?>                                                                                                                                   

Generated by PHPUnit 3.2.0 and Xdebug 2.0.2 at Thu Dec 6 20:12:45 CET 2007.