Author: Derick Rethans
Date: 2006-01-12 18:14:33 +0100 (Thu, 12 Jan 2006)
New Revision: 1801
Log:
- Added a dependency checker so that components will not be loaded/used if one
of the dependencies is missing.
Modified:
packages/Base/trunk/src/base.php
packages/UserInput/trunk/src/input_autoload.php
Modified: packages/Base/trunk/src/base.php
===================================================================
--- packages/Base/trunk/src/base.php 2006-01-12 17:08:44 UTC (rev 1800)
+++ packages/Base/trunk/src/base.php 2006-01-12 17:14:33 UTC (rev 1801)
@@ -15,6 +15,16 @@
class ezcBase
{
/**
+ * Used for dependency checking, to check for a PHP extension.
+ */
+ const DEP_PHP_EXTENSION = "extension";
+
+ /**
+ * Used for dependency checking, to check for a PHP version.
+ */
+ const DEP_PHP_VERSION = "version";
+
+ /**
* Indirectly it determines the path where the autoloads are stored.
*/
const libraryMode = "devel";
@@ -190,5 +200,34 @@
require( ezcBase::$packageDir . $file );
}
+
+ public static function checkDependency( $type, $value )
+ {
+ switch ( $type )
+ {
+ case self::DEP_PHP_EXTENSION:
+ if ( extension_loaded( $value ) )
+ {
+ return;
+ }
+ else
+ {
+ die( "\nThis component depends on the PHP extension
<{$value}>, which is not loaded.\n" );
+ }
+ break;
+
+ case self::DEP_PHP_VERSION:
+ $phpVersion = phpversion();
+ if ( version_compare( $phpVersion, $value, '>=' ) )
+ {
+ return;
+ }
+ else
+ {
+ die( "\nThis component depends on the PHP version
<{$value}>, but the current version is <{$phpVersion}>.\n" );
+ }
+ break;
+ }
+ }
}
?>
Modified: packages/UserInput/trunk/src/input_autoload.php
===================================================================
--- packages/UserInput/trunk/src/input_autoload.php 2006-01-12 17:08:44 UTC
(rev 1800)
+++ packages/UserInput/trunk/src/input_autoload.php 2006-01-12 17:14:33 UTC
(rev 1801)
@@ -9,6 +9,8 @@
* @package UserInput
*/
+ezcBase::checkDependency( ezcBase::DEP_PHP_EXTENSION, "filter" );
+
return array(
'ezcInputForm' => 'UserInput/input_form.php',
'ezcInputFormDefinitionElement' =>
'UserInput/structs/definition_element.php',
--
svn-components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/svn-components