Constructor that initializes the requirement.
public __construct ( boolean $fulfilled, string $testMessage, string $helpHtml, string | null $helpText = null, boolean $optional = false ) | ||
$fulfilled | boolean | Whether the requirement is fulfilled |
$testMessage | string | The message for testing the requirement |
$helpHtml | string | The help text formatted in HTML for resolving the problem |
$helpText | string | null | The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) |
$optional | boolean | Whether this is only an optional recommendation not a mandatory requirement |
/** * Constructor that initializes the requirement. * * @param bool $fulfilled Whether the requirement is fulfilled * @param string $testMessage The message for testing the requirement * @param string $helpHtml The help text formatted in HTML for resolving the problem * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) * @param bool $optional Whether this is only an optional recommendation not a mandatory requirement * @param array<boolean> $types Three booleans (informative, dependant, fromApp) */ public function __construct($fulfilled, $testMessage, $helpHtml, $helpText = null, $optional = false, $types = [self::INFORMATIVE, self::DEPENDANT, self::FROM_APP]) { parent::__construct($fulfilled, $testMessage, $helpHtml, $helpText, $optional); $this->informative = (bool) $types[0]; $this->dependant = (bool) $types[1]; $this->fromApp = (bool) $types[2]; }
/** * Constructor that initializes the requirement. * * @param string $cfgName The configuration name used for ini_get() * @param Boolean|callback $evaluation Either a Boolean indicating whether the configuration should evaluate to true or false, or a callback function receiving the configuration value as parameter to determine the fulfillment of the requirement * @param Boolean $approveCfgAbsence If true the Requirement will be fulfilled even if the configuration option does not exist, i.e. ini_get() returns false. This is helpful for abandoned configs in later PHP versions or configs of an optional extension, like Suhosin. Example: You require a config to be true but PHP later removes this config and defaults it to true internally. * @param string|null $testMessage The message for testing the requirement (when null and $evaluation is a Boolean a default message is derived) * @param string|null $helpHtml The help text formatted in HTML for resolving the problem (when null and $evaluation is a Boolean a default help is derived) * @param string|null $helpText The help text (when null, it will be inferred from $helpHtml, i.e. stripped from HTML tags) * @param Boolean $optional Whether this is only an optional recommendation not a mandatory requirement */ public function __construct($cfgName, $evaluation, $approveCfgAbsence = false, $testMessage = null, $helpHtml = null, $helpText = null, $optional = false) { $cfgValue = ini_get($cfgName); if (is_callable($evaluation)) { if (null === $testMessage || null === $helpHtml) { throw new InvalidArgumentException('You must provide the parameters testMessage and helpHtml for a callback evaluation.'); } $fulfilled = call_user_func($evaluation, $cfgValue); } else { if (null === $testMessage) { $testMessage = sprintf('%s %s be %s in php.ini', $cfgName, $optional ? 'should' : 'must', $evaluation ? 'enabled' : 'disabled'); } if (null === $helpHtml) { $helpHtml = sprintf('Set <strong>%s</strong> to <strong>%s</strong> in php.ini<a href="#phpini">*</a>.', $cfgName, $evaluation ? 'on' : 'off'); } $fulfilled = $evaluation == $cfgValue; } parent::__construct($fulfilled || $approveCfgAbsence && false === $cfgValue, $testMessage, $helpHtml, $helpText, $optional); }
/** * @return PhpVersionRequirement */ public function __construct() { parent::__construct(Craft::t('iconv support'), null, false, '<a href="http://buildwithcraft.com">Craft</a>'); }
/** * @return WebRootExposedFolderRequirement */ public function __construct() { parent::__construct(Craft::t('Sensitive Craft folders should not be publicly accessible'), null, false, '<a href="http://craftcms.com">Craft CMS</a>'); }
/** * @return PhpVersionRequirement */ public function __construct() { parent::__construct(Craft::t('PHP Version'), null, true, '<a href="http://buildwithcraft.com">Craft</a>'); }
/** * @return IconvRequirement */ public function __construct() { parent::__construct(Craft::t('iconv support'), null, false, '<a href="http://craftcms.com">Craft CMS</a>'); }
/** * @return WebRootExposedFolderRequirement */ public function __construct() { parent::__construct(Craft::t('Craft folders in public web root'), null, false, '<a href="http://craftcms.com">Craft CMS</a>'); }