cvs: pear-core /PEAR/Installer Role.php

From: Date: Fri, 10 Apr 2009 19:42:49 +0000
Subject: cvs: pear-core /PEAR/Installer Role.php
Groups: php.pear.cvs php.pear.core 
Request: Send a blank email to pear-core+get-8320@lists.php.net to get a copy of this message
dufuz Fri Apr 10 19:42:49 2009 UTC Modified files: /pear-core/PEAR/Installer Role.php Log: Cosmetics http://cvs.php.net/viewvc.cgi/pear-core/PEAR/Installer/Role.php?r1=1.21&r2=1.22&diff_format=u Index: pear-core/PEAR/Installer/Role.php diff -u pear-core/PEAR/Installer/Role.php:1.21 pear-core/PEAR/Installer/Role.php:1.22 --- pear-core/PEAR/Installer/Role.php:1.21 Tue Feb 24 23:45:18 2009 +++ pear-core/PEAR/Installer/Role.php Fri Apr 10 19:42:49 2009 @@ -9,7 +9,7 @@ * @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,v 1.21 2009/02/24 23:45:18 dufuz Exp $ + * @version CVS: $Id: Role.php,v 1.22 2009/04/10 19:42:49 dufuz Exp $ * @link http://pear.php.net/package/PEAR * @since File available since Release 1.4.0a1 */ @@ -44,10 +44,12 @@ if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) { PEAR_Installer_Role::registerRoles(); } + foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $class => $info) { if (!$info['config_vars']) { continue; } + $config->_addConfigVars($class, $info['config_vars']); } } @@ -64,14 +66,17 @@ if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) { PEAR_Installer_Role::registerRoles(); } + if (!in_array($role, PEAR_Installer_Role::getValidRoles($pkg->getPackageType()))) { $a = false; return $a; } + $a = 'PEAR_Installer_Role_' . ucfirst($role); if (!class_exists($a)) { require_once str_replace('_', '/', $a) . '.php'; } + $b = new $a($config); return $b; } @@ -90,19 +95,23 @@ if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) { PEAR_Installer_Role::registerRoles(); } + static $ret = array(); if ($clear) { $ret = array(); } + if (isset($ret[$release])) { return $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)); } } + return $ret[$release]; } @@ -121,18 +130,23 @@ if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) { PEAR_Installer_Role::registerRoles(); } + static $ret; if ($clear) { unset($ret); } - if (!isset($ret)) { - $ret = array(); - foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) { - if ($okreleases['installable']) { - $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role)); - } + + if (isset($ret)) { + return $ret; + } + + $ret = array(); + foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) { + if ($okreleases['installable']) { + $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role)); } } + return $ret; } @@ -151,18 +165,23 @@ if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) { PEAR_Installer_Role::registerRoles(); } + static $ret; if ($clear) { unset($ret); } - if (!isset($ret)) { - $ret = array(); - foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) { - if ($okreleases['honorsbaseinstall']) { - $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role)); - } + + if (isset($ret)) { + return $ret; + } + + $ret = array(); + foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) { + if ($okreleases['honorsbaseinstall']) { + $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role)); } } + return $ret; } @@ -178,18 +197,23 @@ if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) { PEAR_Installer_Role::registerRoles(); } + static $ret; if ($clear) { unset($ret); } - if (!isset($ret)) { - $ret = array(); - foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) { - if ($okreleases['phpfile']) { - $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role)); - } + + if (isset($ret)) { + return $ret; + } + + $ret = array(); + foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) { + if ($okreleases['phpfile']) { + $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role)); } } + return $ret; } @@ -212,17 +236,21 @@ if ($dir === null) { $dir = dirname(__FILE__) . '/Role'; } + if (!file_exists($dir) || !is_dir($dir)) { return PEAR::raiseError("registerRoles: opendir($dir) failed: does not exist/is not directory"); } + $dp = @opendir($dir); if (empty($dp)) { return PEAR::raiseError("registerRoles: opendir($dir) failed: $php_errmsg"); } + while ($entry = readdir($dp)) { if ($entry{0} == '.' || substr($entry, -4) != '.xml') { continue; } + $class = "PEAR_Installer_Role_".substr($entry, 0, -4); // List of roles if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) { @@ -232,9 +260,11 @@ if (!is_array($data['releasetypes'])) { $data['releasetypes'] = array($data['releasetypes']); } + $GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = $data; } } + closedir($dp); ksort($GLOBALS['_PEAR_INSTALLER_ROLES']); PEAR_Installer_Role::getBaseinstallRoles(true); @@ -243,5 +273,4 @@ PEAR_Installer_Role::getValidRoles('****', true); return true; } -} -?> +} \ No newline at end of file

« previous php.pear.core (#8320) next »