mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 00:06:55 +02:00
Add $modules->getModuleInfoProperty($module, 'name'); to retrieve just one property of module info, when useful.
This commit is contained in:
@@ -1287,7 +1287,6 @@ class Modules extends WireArray {
|
|||||||
try {
|
try {
|
||||||
if(!$this->initModule($module, array('clearSettings' => false, 'throw' => true))) {
|
if(!$this->initModule($module, array('clearSettings' => false, 'throw' => true))) {
|
||||||
return empty($options['returnError']) ? null : "Module '$module' failed init";
|
return empty($options['returnError']) ? null : "Module '$module' failed init";
|
||||||
$module = null;
|
|
||||||
}
|
}
|
||||||
} catch(\Exception $e) {
|
} catch(\Exception $e) {
|
||||||
if(empty($options['noThrow'])) throw $e;
|
if(empty($options['noThrow'])) throw $e;
|
||||||
@@ -1508,7 +1507,7 @@ class Modules extends WireArray {
|
|||||||
* #pw-internal Almost always recommend using findByPrefix() instead
|
* #pw-internal Almost always recommend using findByPrefix() instead
|
||||||
*
|
*
|
||||||
* @param string $selector Selector string
|
* @param string $selector Selector string
|
||||||
* @return Modules WireArray of found modules, instantiated and ready-to-use
|
* @return WireArray of found modules, instantiated and ready-to-use
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function find($selector) {
|
public function find($selector) {
|
||||||
@@ -2420,13 +2419,14 @@ class Modules extends WireArray {
|
|||||||
* @param $className
|
* @param $className
|
||||||
* @return array Only includes module info specified in the module file itself.
|
* @return array Only includes module info specified in the module file itself.
|
||||||
*
|
*
|
||||||
*/
|
|
||||||
protected function getModuleInfoInternalSafe($className) {
|
protected function getModuleInfoInternalSafe($className) {
|
||||||
// future addition
|
// future addition
|
||||||
// load file, preg_split by /^\s*(public|private|protected)[^;{]+function\s*([^)]*)[^{]*{/
|
// load file, preg_split by /^\s*(public|private|protected)[^;{]+function\s*([^)]*)[^{]*{/
|
||||||
// isolate the one that starts has getModuleInfo in matches[1]
|
// isolate the one that starts has getModuleInfo in matches[1]
|
||||||
// parse data from matches[2]
|
// parse data from matches[2]
|
||||||
|
return array();
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve module info for system properties: PHP or ProcessWire
|
* Retrieve module info for system properties: PHP or ProcessWire
|
||||||
@@ -2794,7 +2794,7 @@ class Modules extends WireArray {
|
|||||||
/**
|
/**
|
||||||
* Returns a verbose array of information for a Module
|
* Returns a verbose array of information for a Module
|
||||||
*
|
*
|
||||||
* This is the same as what's returned by `Modules::getModuleInfo()` except that it has the following additional properties:
|
* This is the same as what’s returned by `Modules::getModuleInfo()` except that it has the following additional properties:
|
||||||
*
|
*
|
||||||
* - `versionStr` (string): formatted module version string.
|
* - `versionStr` (string): formatted module version string.
|
||||||
* - `file` (string): module filename from PW installation root, or false when it can't be found.
|
* - `file` (string): module filename from PW installation root, or false when it can't be found.
|
||||||
@@ -2820,6 +2820,29 @@ class Modules extends WireArray {
|
|||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get just a single property of module info
|
||||||
|
*
|
||||||
|
* @param Module|string $class Module instance or module name
|
||||||
|
* @param string $property Name of property to get
|
||||||
|
* @param array $options Additional options (see getModuleInfo method for options)
|
||||||
|
* @return mixed|null Returns value of property or null if not found
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getModuleInfoProperty($class, $property, array $options = array()) {
|
||||||
|
if(isset($this->moduleInfoVerboseKeys[$property])) {
|
||||||
|
$info = $this->getModuleInfoVerbose($class, $options);
|
||||||
|
$info['verbose'] = true;
|
||||||
|
} else {
|
||||||
|
$info = $this->getModuleInfo($class, $options);
|
||||||
|
}
|
||||||
|
if(!isset($info[$property]) && empty($info['verbose'])) {
|
||||||
|
// try again, just in case we can find it in verbose data
|
||||||
|
$info = $this->getModuleInfoVerbose($class, $options);
|
||||||
|
}
|
||||||
|
return isset($info[$property]) ? $info[$property] : null;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get an array of all unique, non-default, non-root module namespaces mapped to directory names
|
* Get an array of all unique, non-default, non-root module namespaces mapped to directory names
|
||||||
*
|
*
|
||||||
@@ -4694,7 +4717,7 @@ class Modules extends WireArray {
|
|||||||
* #pw-internal
|
* #pw-internal
|
||||||
*
|
*
|
||||||
* @param Module|int|string $module Module object or class name
|
* @param Module|int|string $module Module object or class name
|
||||||
* @return array Returns number of files that were added
|
* @return int Returns number of files that were added
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function loadModuleFileAssets($module) {
|
public function loadModuleFileAssets($module) {
|
||||||
@@ -4772,7 +4795,7 @@ class Modules extends WireArray {
|
|||||||
*
|
*
|
||||||
* @param array|Wire|string $text
|
* @param array|Wire|string $text
|
||||||
* @param int $flags
|
* @param int $flags
|
||||||
* @return $this
|
* @return Modules|WireArray
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public function error($text, $flags = 0) {
|
public function error($text, $flags = 0) {
|
||||||
|
Reference in New Issue
Block a user