Source for file Role.php
Documentation is available at Role.php
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Role.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR
* @since File available since Release 1.4.0a1
* base class for installer roles
require_once 'PEAR/Installer/Role/Common.php';
require_once 'PEAR/XMLParser.php';
* @author Greg Beaver <cellog@php.net>
* @copyright 1997-2009 The Authors
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version Release: 1.9.4
* @link http://pear.php.net/package/PEAR
* @since Class available since Release 1.4.0a1
* Set up any additional configuration variables that file roles require
* Never call this directly, it is called by the PEAR_Config constructor
function initializeConfig (&$config)
if (!isset ($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $class => $info) {
if (!$info['config_vars']) {
$config->_addConfigVars ($class, $info['config_vars']);
* @param PEAR_PackageFile_v2
* @param string role name
* @return PEAR_Installer_Role_Common
function &factory($pkg, $role, &$config)
if (!isset ($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
$a = 'PEAR_Installer_Role_' . ucfirst($role);
* Get a list of file roles that are valid for the particular release type.
* For instance, src files serve no purpose in regular php releases.
* @param bool clear cache
if (!isset ($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
if (isset ($ret[$release])) {
$ret[$release] = array ();
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
if (in_array ($release, $okreleases['releasetypes'])) {
$ret[$release][] = strtolower (str_replace ('PEAR_Installer_Role_', '', $role));
* Get a list of roles that require their files to be installed
* Most roles must be installed, but src and package roles, for instance
* are pseudo-roles. src files are compiled into a new extension. Package
* roles are actually fully bundled releases of a package
* @param bool clear cache
if (!isset ($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
if ($okreleases['installable']) {
* Return an array of roles that are affected by the baseinstalldir attribute
* Most roles ignore this attribute, and instead install directly into:
* so a tests file tests/file.phpt is installed into PackageName/tests/filepath.php
* @param bool clear cache
if (!isset ($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
if ($okreleases['honorsbaseinstall']) {
* Return an array of file roles that should be analyzed for PHP content at package time,
* @param bool clear cache
if (!isset ($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
if ($okreleases['phpfile']) {
* Scan through the Command directory looking for classes
* and see what commands they implement.
* @param string which directory to look for classes, defaults to
* the Installer/Roles subdirectory of
* the directory from where this file (__FILE__) is
* @return bool TRUE on success, a PEAR error on failure
$GLOBALS['_PEAR_INSTALLER_ROLES'] = array ();
$dir = dirname(__FILE__ ) . '/Role';
return PEAR::raiseError(" registerRoles: opendir($dir) failed: does not exist/is not directory" );
return PEAR::raiseError(" registerRoles: opendir($dir) failed: $php_errmsg" );
if ($entry{0 } == '.' || substr($entry, -4 ) != '.xml') {
$class = "PEAR_Installer_Role_". substr($entry, 0 , -4 );
if (!isset ($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) {
$data = $parser->getData ();
$data['releasetypes'] = array ($data['releasetypes']);
$GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = $data;
ksort($GLOBALS['_PEAR_INSTALLER_ROLES']);
Documentation generated on Wed, 06 Jul 2011 23:31:18 +0000 by phpDocumentor 1.4.3. PEAR Logo Copyright © PHP Group 2004.
|