3 * File containing the ezcBaseMetaDataPearReader class.
7 * @copyright Copyright (C) 2005-2009 eZ Systems AS. All rights reserved.
8 * @license http://ez.no/licenses/new_bsd New BSD License
11 @require
'PEAR/Registry.php';
14 * Base class implements ways of fetching information about the installed
15 * eZ Components when installed as tarball.
17 * Note: there are lots of @ used here, because PEAR still lives in the stone
18 * age with their PHP 3 code and general liberal use of throwing warnings and
25 class ezcBaseMetaDataPearReader
28 * Stores the PEAR_Registry to query for information
35 * Creates the reader object and initialized the registry for querying
37 public function __construct()
39 @$this->registry
= new PEAR_Registry
;
43 * Returns the version string for the installed eZ Components bundle.
45 * A version string such as "2008.2.2" is returned.
49 public function getBundleVersion()
51 @$packageInfo = $this->registry
->packageInfo( 'ezcomponents', null, 'components.ez.no' );
52 return $packageInfo['version']['release'];
56 * Returns a PHP version string that describes the required PHP version for
57 * this installed eZ Components bundle.
61 public function getRequiredPhpVersion()
63 @$packageInfo = $this->registry
->packageInfo( 'ezcomponents', null, 'components.ez.no' );
64 if ( array_key_exists( 'required', $packageInfo['dependencies'] ) )
66 return $packageInfo['dependencies']['required']['php']['min'];
68 return $packageInfo['dependencies']['php']['min'];
72 * Returns whether $componentName is installed
74 * Checks the PEAR registry whether the component is there.
78 public function isComponentInstalled( $componentName )
80 @$packageInfo = $this->registry
->packageInfo( $componentName, null, 'components.ez.no' );
81 return is_array( $packageInfo );
85 * Returns the version string of the available $componentName or false when
86 * the component is not installed.
90 public function getComponentVersion( $componentName )
92 @$packageInfo = $this->registry
->packageInfo( $componentName, null, 'components.ez.no' );
93 $release = $packageInfo['version']['release'];
94 return $release === null ?
false : $release;
98 * Returns a list of components that $componentName depends on.
100 * If $componentName is left empty, all installed components are returned.
102 * The returned array has as keys the component names, and as values the
103 * version of the components.
105 * @return array(string=>string).
107 public function getComponentDependencies( $componentName = 'ezcomponents' )
109 @$packageInfo = $this->registry
->packageInfo( $componentName, 'dependencies', 'components.ez.no' );
110 if ( isset( $packageInfo['required']['package'] ) )
113 if ( isset( $packageInfo['required']['package']['name'] ) )
115 $deps[$packageInfo['required']['package']['name']] = $packageInfo['required']['package']['min'];
119 foreach ( $packageInfo['required']['package'] as $package )
121 $deps[$package['name']] = $package['min'];