| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 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 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 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 sfAutoloadException exception. |
|---|
| 66 |
* |
|---|
| 67 |
* @return string Path to default Zend Loader class |
|---|
| 68 |
* @throws sfAutoloadException |
|---|
| 69 |
* |
|---|
| 70 |
* @author Simone Carletti <weppos@weppos.net> |
|---|
| 71 |
*/ |
|---|
| 72 |
public static function requireZendLoader() |
|---|
| 73 |
{ |
|---|
| 74 |
|
|---|
| 75 |
$base = sfConfig::get('sf_zend_lib_dir') ? sfConfig::get('sf_zend_lib_dir').'/' : ''; |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 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 sfAutoloadException('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 |
|
|---|