X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fregistration%2FExtensionRegistry.php;h=3138b37a04731c41bfe99aed3a05ed7ffff37432;hb=7b05197301ee330865d2d377cc1005b6c61cb251;hp=d21ae412f13dc129fb45f864e2ea46f58b045b07;hpb=eadc306573803f444fd692b701823f9939fdd9e7;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/registration/ExtensionRegistry.php b/includes/registration/ExtensionRegistry.php index d21ae412f1..3138b37a04 100644 --- a/includes/registration/ExtensionRegistry.php +++ b/includes/registration/ExtensionRegistry.php @@ -1,5 +1,7 @@ loaded[$name] ); + public function isLoaded( $name, $constraint = '*' ) { + $isLoaded = isset( $this->loaded[$name] ); + if ( $constraint === '*' || !$isLoaded ) { + return $isLoaded; + } + // if a specific constraint is requested, but no version is set, throw an exception + if ( !isset( $this->loaded[$name]['version'] ) ) { + $msg = "{$name} does not expose its version, but an extension or a skin" + . " requires: {$constraint}."; + throw new LogicException( $msg ); + } + + return SemVer::satisfies( $this->loaded[$name]['version'], $constraint ); } /** @@ -392,11 +409,7 @@ class ExtensionRegistry { * @return array */ public function getAttribute( $name ) { - if ( isset( $this->attributes[$name] ) ) { - return $this->attributes[$name]; - } else { - return []; - } + return $this->attributes[$name] ?? []; } /**