3 * File containing the ezcBaseMetaData 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 * Base class implements ways of fetching information about the installed
12 * eZ Components. It knows whether to use the PEAR registry or the bundled XML
13 * file, depending on how eZ Components is installed.
22 * Creates a ezcBaseMetaData object
24 * The sole parameter $installMethod should only be used if you are really
25 * sure that you need to use it. It is mostly there to make testing at
26 * least slightly possible. Again, do not set it unless instructed.
28 * @param string $installMethod
30 public function __construct( $installMethod = NULL )
32 $installMethod = $installMethod !== NULL ?
$installMethod : ezcBase
::getInstallMethod();
34 // figure out which reader to use
35 switch ( $installMethod )
38 $this->reader
= new ezcBaseMetaDataTarballReader
;
41 $this->reader
= new ezcBaseMetaDataPearReader
;
44 throw new ezcBaseMetaDataReaderException( "Unknown install method '$installMethod'." );
50 * Returns the version string for the installed eZ Components bundle.
52 * A version string such as "2008.2.2" is returned.
56 public function getBundleVersion()
58 return $this->reader
->getBundleVersion();
62 * Returns a PHP version string that describes the required PHP version for
63 * this installed eZ Components bundle.
67 public function getRequiredPhpVersion()
69 return $this->reader
->getRequiredPhpVersion();
73 * Returns whether $componentName is installed
75 * If installed with PEAR, it checks the PEAR registry whether the
76 * component is there. In case the tarball installation method is used, it
77 * will return true for every component that exists (because all of them
78 * are then available).
82 public function isComponentInstalled( $componentName )
84 return $this->reader
->isComponentInstalled( $componentName );
88 * Returns the version string of the available $componentName or false when
89 * the component is not installed.
93 public function getComponentVersion( $componentName )
95 return $this->reader
->getComponentVersion( $componentName );
99 * Returns a list of components that $componentName depends on.
101 * If $componentName is left empty, all installed components are returned.
103 * The returned array has as keys the component names, and as values the
104 * version of the components.
106 * @return array(string=>string).
108 public function getComponentDependencies( $componentName = null )
110 if ( $componentName === null )
112 return $this->reader
->getComponentDependencies();
116 return $this->reader
->getComponentDependencies( $componentName );