Skip to content

Commit a9b4897

Browse files
committed
Use constants for version constraints to make languages more maintainable
Signed-off-by: Matt Friedman <maf675@gmail.com>
1 parent 243936f commit a9b4897

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

ext.php

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,28 @@
1515
*/
1616
class ext extends \phpbb\extension\base
1717
{
18+
/**
19+
* Require phpBB 3.3.12 due to new template and core events.
20+
*/
21+
public const PHPBB_MIN_VERSION = '3.3.12';
22+
23+
/**
24+
* Should not be installed in phpBB 4 because it already has push notifications.
25+
*/
26+
public const PHPBB_MAX_VERSION = '4.0.0-dev';
27+
28+
/**
29+
* Require PHP 7.3 due to 3rd party libraries included.
30+
*/
31+
public const PHP_MIN_VERSION = '7.3';
32+
1833
/**
1934
* @var array An array of installation error messages
2035
*/
2136
protected $errors = [];
2237

2338
/**
2439
* {@inheritdoc}
25-
*
26-
* Requires phpBB 3.3.12 due to new template and core events.
27-
* Should not be installed in phpBB 4.0.0-a1 because it already has push notifications.
28-
* Requires PHP 7.3 due to 3rd party libraries included.
2940
*/
3041
public function is_enableable()
3142
{
@@ -42,12 +53,12 @@ public function is_enableable()
4253
*/
4354
protected function check_phpbb_version()
4455
{
45-
if (phpbb_version_compare(PHPBB_VERSION, '3.3.12', '<'))
56+
if (phpbb_version_compare(PHPBB_VERSION, self::PHPBB_MIN_VERSION, '<'))
4657
{
4758
$this->errors[] = 'PHPBB_VERSION_MIN_ERROR';
4859
}
4960

50-
if (phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>='))
61+
if (phpbb_version_compare(PHPBB_VERSION, self::PHPBB_MAX_VERSION, '>='))
5162
{
5263
$this->errors[] = 'PHPBB_VERSION_MAX_ERROR';
5364
}

language/en/install.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
$lang = array_merge($lang, [
4141
'PHPBB_VERSION_MAX_ERROR' => 'This extension can not be installed on this board. This is a phpBB 4 board, which already contains the features in this extension.',
42-
'PHPBB_VERSION_MIN_ERROR' => 'phpBB 3.3.12 or newer is required.',
43-
'PHP_VERSION_ERROR' => 'PHP 7.3 or newer is required.',
42+
'PHPBB_VERSION_MIN_ERROR' => 'phpBB ' . \phpbb\webpushnotifications\ext::PHPBB_MIN_VERSION . ' or newer is required.',
43+
'PHP_VERSION_ERROR' => 'PHP ' . \phpbb\webpushnotifications\ext::PHP_MIN_VERSION . ' or newer is required.',
4444
'PHP_EXT_MISSING' => 'The “%s” extension for PHP must be installed on this server.',
4545
]);

language/ru/install.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@
3939

4040
$lang = array_merge($lang, [
4141
'PHPBB_VERSION_MAX_ERROR' => 'Данное расширение несовместимо с установленной версией конференции. Вы используете версию phpBB 4, которая уже содержит соответствующие функции.',
42-
'PHPBB_VERSION_MIN_ERROR' => 'Данное расширение несовместимо с установленной версией конференции. Необходима версия phpBB 3.3.12 или выше.',
43-
'PHP_VERSION_ERROR' => 'Данное расширение несовместимо с установленной на сервере версией PHP. Необходима версия PHP 7.3 или выше.',
42+
'PHPBB_VERSION_MIN_ERROR' => 'Данное расширение несовместимо с установленной версией конференции. Необходима версия phpBB ' . \phpbb\webpushnotifications\ext::PHPBB_MIN_VERSION . ' или выше.',
43+
'PHP_VERSION_ERROR' => 'Данное расширение несовместимо с установленной на сервере версией PHP. Необходима версия PHP ' . \phpbb\webpushnotifications\ext::PHP_MIN_VERSION . ' или выше.',
4444
]);

0 commit comments

Comments
 (0)