From 571a4d9ace754ad8c803abf4762943dbd6cc772a Mon Sep 17 00:00:00 2001 From: UndefinedOffset Date: Tue, 2 Jul 2019 14:55:36 -0300 Subject: [PATCH] NEW: Added support for config condition if PHP extension is loaded --- .../02_Developer_Guides/04_Configuration/00_Configuration.md | 1 + src/Core/Config/CoreConfigFactory.php | 3 +++ 2 files changed, 4 insertions(+) diff --git a/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md b/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md index 6eba335e3..3ddd11d95 100644 --- a/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md +++ b/docs/en/02_Developer_Guides/04_Configuration/00_Configuration.md @@ -339,6 +339,7 @@ You then list any of the following rules as sub-keys, with informational values - 'envvarset', in which case the value(s) should be environment variables that must be set - 'constantdefined', in which case the value(s) should be constants that must be defined - 'envorconstant' A variable which should be defined either via environment vars or constants + - 'extensionloaded', in which case the PHP extension(s) must be loaded For instance, to add a property to "foo" when a module exists, and "bar" otherwise, you could do this: diff --git a/src/Core/Config/CoreConfigFactory.php b/src/Core/Config/CoreConfigFactory.php index 4a0cc7073..7ab037ae5 100644 --- a/src/Core/Config/CoreConfigFactory.php +++ b/src/Core/Config/CoreConfigFactory.php @@ -182,6 +182,9 @@ class CoreConfigFactory }) ->addRule('moduleexists', function ($module) { return ModuleLoader::inst()->getManifest()->moduleExists($module); + }) + ->addRule('extensionloaded', function ($extension) { + return extension_loaded($extension); }); } }