Development

/branches/1.3/lib/plugins/sfCompat10Plugin/lib/bridge/sfZendFrameworkBridge.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/plugins/sfCompat10Plugin/lib/bridge/sfZendFrameworkBridge.class.php

Revision 5852, 2.7 kB (checked in by fabien, 7 years ago)

fixed sfZendFrameworkBridge AutoLoad? Not Working (closes #2314)

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
1 <?php
2
3 /*
4  * This file is part of the symfony package.
5  * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
6  *
7  * For the full copyright and license information, please view the LICENSE
8  * file that was distributed with this source code.
9  */
10
11 if (sfConfig::get('sf_zend_lib_dir'))
12 {
13   set_include_path(sfConfig::get('sf_zend_lib_dir').PATH_SEPARATOR.get_include_path());
14 }
15
16 sfZendFrameworkBridge::requireZendLoader();
17
18 /**
19  * This class makes easy to use Zend Framework classes within symfony.
20  *
21  * @package    symfony
22  * @subpackage addon
23  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
24  * @version    SVN: $Id$
25  */
26 class sfZendFrameworkBridge
27 {
28   static protected
29     $withLoader = true;
30
31   public static function autoload($class)
32   {
33     try
34     {
35       if (self::$withLoader)
36       {
37         Zend_Loader::loadClass($class);
38       }
39       else
40       {
41         Zend::loadClass($class);
42       }
43     }
44     catch (Zend_Exception $e)
45     {
46       return false;
47     }
48
49     return true;
50   }
51  
52   /**
53    * Detect and return the path to current Zend loader class.
54    *
55    * Starting from ZF 0.9.0 autoloading function has been moved
56    * from Zend.php to Zend/Loader.php class.
57    * Starting from ZF 1.0.0 Zend.php class no longer exists.
58    *
59    * This function tries to detect whether Zend_Loader exists
60    * and returns its path if yes.
61    * If the first step fails, the class will try to find Zend.php library
62    * available in ZF <= 0.9.0 and returns its path if its exists.
63    *
64    * If neither Zend/Loader.php nor Zend.php exists,
65    * then this function will raise a sfConfigurationException exception.
66    *
67    * @return  string  Path to default Zend Loader class
68    * @throws  sfConfigurationException
69    *
70    * @author  Simone Carletti <weppos@weppos.net>
71    */
72   public static function requireZendLoader()
73   {
74     // get base path according to sf setting
75     $base = sfConfig::get('sf_zend_lib_dir') ? sfConfig::get('sf_zend_lib_dir').'/' : '';
76
77     // first check whether Zend/Loader.php exists
78     // Zend/Loader.php is available starting from ZF 0.9.0
79     // Before ZF 0.9.0 you should call Zend.php
80     // Plese note that Zend.php is still available in ZF 0.9.0
81     // but it should not be called because deprecated
82     if (file_exists($base.'Zend/Loader.php'))
83     {
84       require_once($base.'Zend/Loader.php');
85       self::$withLoader = true;
86     }
87     else if (file_exists($base.'Zend.php'))
88     {
89       require_once($base.'Zend.php');
90       self::$withLoader = false;
91     }
92     else
93     {
94       throw new sfConfigurationException('Invalid Zend Framework library structure, unable to find Zend/Loader.php (ZF >= 0.9.0) or Zend.php (ZF < 0.9.0) library');
95     }
96   }
97 }
98
Note: See TracBrowser for help on using the browser.