Development

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

You must first sign up to be able to contribute.

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

Revision 10270, 2.8 kB (checked in by Carl.Vondrick, 6 years ago)

1.1: added deprecated warnings to all sfCompatPlugin classes (closes #3882)

  • 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  * WARNING: This class is deprecated and will be removed in symfony 1.2.
22  *
23  * @package    symfony
24  * @subpackage addon
25  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
26  * @version    SVN: $Id$
27  * @deprecated Deprecated since symfony 1.1
28  */
29 class sfZendFrameworkBridge
30 {
31   static protected
32     $withLoader = true;
33
34   public static function autoload($class)
35   {
36     try
37     {
38       if (self::$withLoader)
39       {
40         Zend_Loader::loadClass($class);
41       }
42       else
43       {
44         Zend::loadClass($class);
45       }
46     }
47     catch (Zend_Exception $e)
48     {
49       return false;
50     }
51
52     return true;
53   }
54  
55   /**
56    * Detect and return the path to current Zend loader class.
57    *
58    * Starting from ZF 0.9.0 autoloading function has been moved
59    * from Zend.php to Zend/Loader.php class.
60    * Starting from ZF 1.0.0 Zend.php class no longer exists.
61    *
62    * This function tries to detect whether Zend_Loader exists
63    * and returns its path if yes.
64    * If the first step fails, the class will try to find Zend.php library
65    * available in ZF <= 0.9.0 and returns its path if its exists.
66    *
67    * If neither Zend/Loader.php nor Zend.php exists,
68    * then this function will raise a sfConfigurationException exception.
69    *
70    * @return  string  Path to default Zend Loader class
71    * @throws  sfConfigurationException
72    *
73    * @author  Simone Carletti <weppos@weppos.net>
74    */
75   public static function requireZendLoader()
76   {
77     // get base path according to sf setting
78     $base = sfConfig::get('sf_zend_lib_dir') ? sfConfig::get('sf_zend_lib_dir').'/' : '';
79
80     // first check whether Zend/Loader.php exists
81     // Zend/Loader.php is available starting from ZF 0.9.0
82     // Before ZF 0.9.0 you should call Zend.php
83     // Plese note that Zend.php is still available in ZF 0.9.0
84     // but it should not be called because deprecated
85     if (file_exists($base.'Zend/Loader.php'))
86     {
87       require_once($base.'Zend/Loader.php');
88       self::$withLoader = true;
89     }
90     else if (file_exists($base.'Zend.php'))
91     {
92       require_once($base.'Zend.php');
93       self::$withLoader = false;
94     }
95     else
96     {
97       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');
98     }
99   }
100 }
101
Note: See TracBrowser for help on using the browser.