Bearsampp 2026.9.23
Loading...
Searching...
No Matches
PEAR_Installer_Role Class Reference

Static Public Member Functions

static & factory ($pkg, $role, &$config)
static getBaseinstallRoles ($clear=false)
static getInstallableRoles ($clear=false)
static getPhpRoles ($clear=false)
static getValidRoles ($release, $clear=false)
static initializeConfig (&$config)
static registerRoles ($dir=null)

Detailed Description

Definition at line 31 of file Role.php.

Member Function Documentation

◆ factory()

& factory ( $pkg,
$role,
& $config )
static
Parameters
PEAR_PackageFile_v2
stringrole name
PEAR_Config
Returns
PEAR_Installer_Role_Common

Definition at line 60 of file Role.php.

61 {
62 if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
64 }
65
66 if (!in_array($role, PEAR_Installer_Role::getValidRoles($pkg->getPackageType()))) {
67 $a = false;
68 return $a;
69 }
70
71 $a = 'PEAR_Installer_Role_' . ucfirst($role);
72 if (!class_exists($a)) {
73 require_once str_replace('_', '/', $a) . '.php';
74 }
75
76 $b = new $a($config);
77 return $b;
78 }
$GLOBALS['_PEAR_default_error_mode']
Definition PEAR.php:46
static registerRoles($dir=null)
Definition Role.php:222
static getValidRoles($release, $clear=false)
Definition Role.php:88
$config
Definition pearcmd.php:182

References $config, $GLOBALS, getValidRoles(), and registerRoles().

Referenced by PEAR_Installer\_installFile2(), and PEAR_Command_Registry\doFileList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getBaseinstallRoles()

getBaseinstallRoles ( $clear = false)
static

Return an array of roles that are affected by the baseinstalldir attribute

Most roles ignore this attribute, and instead install directly into: PackageName/filepath so a tests file tests/file.phpt is installed into PackageName/tests/filepath.php

Parameters
boolclear cache
Returns
array

Definition at line 156 of file Role.php.

157 {
158 if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
160 }
161
162 static $ret;
163 if ($clear) {
164 unset($ret);
165 }
166
167 if (isset($ret)) {
168 return $ret;
169 }
170
171 $ret = array();
172 foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
173 if ($okreleases['honorsbaseinstall']) {
174 $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
175 }
176 }
177
178 return $ret;
179 }

References $GLOBALS, and registerRoles().

Referenced by PEAR_Registry\_rebuildFileMap(), PEAR_Registry\checkFileMap(), and registerRoles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getInstallableRoles()

getInstallableRoles ( $clear = false)
static

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

Parameters
boolclear cache
Returns
array

Definition at line 122 of file Role.php.

123 {
124 if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
126 }
127
128 static $ret;
129 if ($clear) {
130 unset($ret);
131 }
132
133 if (isset($ret)) {
134 return $ret;
135 }
136
137 $ret = array();
138 foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
139 if ($okreleases['installable']) {
140 $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
141 }
142 }
143
144 return $ret;
145 }

References $GLOBALS, and registerRoles().

Referenced by PEAR_Registry\_rebuildFileMap(), PEAR_Registry\checkFileMap(), and registerRoles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getPhpRoles()

getPhpRoles ( $clear = false)
static

Return an array of file roles that should be analyzed for PHP content at package time, like the "php" role.

Parameters
boolclear cache
Returns
array

Definition at line 187 of file Role.php.

188 {
189 if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
191 }
192
193 static $ret;
194 if ($clear) {
195 unset($ret);
196 }
197
198 if (isset($ret)) {
199 return $ret;
200 }
201
202 $ret = array();
203 foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
204 if ($okreleases['phpfile']) {
205 $ret[] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
206 }
207 }
208
209 return $ret;
210 }

References $GLOBALS, and registerRoles().

Referenced by PEAR_PackageFile_v2_Validator\_analyzePhpFiles(), and registerRoles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getValidRoles()

getValidRoles ( $release,
$clear = false )
static

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.

Parameters
string
boolclear cache
Returns
array

Definition at line 88 of file Role.php.

89 {
90 if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
92 }
93
94 static $ret = array();
95 if ($clear) {
96 $ret = array();
97 }
98
99 if (isset($ret[$release])) {
100 return $ret[$release];
101 }
102
103 $ret[$release] = array();
104 foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $role => $okreleases) {
105 if (in_array($release, $okreleases['releasetypes'])) {
106 $ret[$release][] = strtolower(str_replace('PEAR_Installer_Role_', '', $role));
107 }
108 }
109
110 return $ret[$release];
111 }

References $GLOBALS, and registerRoles().

Referenced by PEAR_Installer\_installFile2(), PEAR_PackageFile_v2_Validator\_invalidFileRole(), PEAR_PackageFile_v2_Validator\_validateRole(), factory(), and registerRoles().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initializeConfig()

initializeConfig ( & $config)
static

Set up any additional configuration variables that file roles require

Never call this directly, it is called by the PEAR_Config constructor

Parameters
PEAR_Config

Definition at line 39 of file Role.php.

40 {
41 if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'])) {
43 }
44
45 foreach ($GLOBALS['_PEAR_INSTALLER_ROLES'] as $class => $info) {
46 if (!$info['config_vars']) {
47 continue;
48 }
49
50 $config->_addConfigVars($class, $info['config_vars']);
51 }
52 }

References $config, $GLOBALS, and registerRoles().

Here is the call graph for this function:

◆ registerRoles()

registerRoles ( $dir = null)
static

Scan through the Command directory looking for classes and see what commands they implement.

Parameters
stringwhich directory to look for classes, defaults to the Installer/Roles subdirectory of the directory from where this file (FILE) is included.
Returns
bool TRUE on success, a PEAR error on failure

Definition at line 222 of file Role.php.

223 {
224 $GLOBALS['_PEAR_INSTALLER_ROLES'] = array();
225 $parser = new PEAR_XMLParser;
226 if ($dir === null) {
227 $dir = dirname(__FILE__) . '/Role';
228 }
229
230 if (!file_exists($dir) || !is_dir($dir)) {
231 return PEAR::raiseError("registerRoles: opendir($dir) failed: does not exist/is not directory");
232 }
233
234 $dp = @opendir($dir);
235 if (empty($dp)) {
236 return PEAR::raiseError("registerRoles: opendir($dir) failed: $php_errmsg");
237 }
238
239 while ($entry = readdir($dp)) {
240 if ($entry[0] == '.' || substr($entry, -4) != '.xml') {
241 continue;
242 }
243
244 $class = "PEAR_Installer_Role_".substr($entry, 0, -4);
245 // List of roles
246 if (!isset($GLOBALS['_PEAR_INSTALLER_ROLES'][$class])) {
247 $file = "$dir/$entry";
248 $parser->parse(file_get_contents($file));
249 $data = $parser->getData();
250 if (!is_array($data['releasetypes'])) {
251 $data['releasetypes'] = array($data['releasetypes']);
252 }
253
254 $GLOBALS['_PEAR_INSTALLER_ROLES'][$class] = $data;
255 }
256 }
257
258 closedir($dp);
259 ksort($GLOBALS['_PEAR_INSTALLER_ROLES']);
264 return true;
265 }
static getBaseinstallRoles($clear=false)
Definition Role.php:156
static getPhpRoles($clear=false)
Definition Role.php:187
static getInstallableRoles($clear=false)
Definition Role.php:122

References $GLOBALS, getBaseinstallRoles(), getInstallableRoles(), getPhpRoles(), and getValidRoles().

Referenced by factory(), getBaseinstallRoles(), getInstallableRoles(), getPhpRoles(), getValidRoles(), and initializeConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file:
  • E:/Bearsampp-development/sandbox/core/libs/php/pear/pear/PEAR/Installer/Role.php