Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "phpbb-extension",
"description": "The official phpBB skeleton extension generator.",
"homepage": "https://www.phpbb.com/customise/db/official_tool/ext_skeleton/",
"version": "1.1.16",
"version": "1.2.0-dev",
"license": "GPL-2.0-only",
"authors": [
{
Expand All @@ -19,7 +19,7 @@
}
],
"require": {
"php": ">=5.6",
"php": ">=7.1",
"composer/installers": "~1.0",
"ext-zip": "*"
},
Expand All @@ -29,7 +29,7 @@
"extra": {
"display-name": "phpBB Skeleton Extension",
"soft-require": {
"phpbb/phpbb": ">=3.2.3,<4.0.0@dev"
"phpbb/phpbb": ">=3.3.0,<4.0.0@dev"
},
"version-check": {
"host": "www.phpbb.com",
Expand Down
18 changes: 9 additions & 9 deletions ext.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@

class ext extends \phpbb\extension\base
{
const DEFAULT_PHP = '7.1.3';
const DEFAULT_PHPBB_MIN = '3.3.0';
const DEFAULT_PHPBB_MAX = '4.0.0@dev';
public const DEFAULT_SKELETON_PHP = '7.1.3';
public const DEFAULT_SKELETON_PHPBB_MIN = '3.3.0';
public const DEFAULT_SKELETON_PHPBB_MAX = '4.0.0@dev';

const REQUIRE_PHPBB_MIN = '3.2.3';
const REQUIRE_PHPBB_MAX = '4.0.0-dev';
const REQUIRE_PHP = 50600;
public const MIN_PHPBB_ALLOWED = '3.3.0';
public const MAX_PHPBB_ALLOWED = '4.0.0-dev';
public const MIN_PHP_ALLOWED = 70100;

/**
* @var array An array of installation error messages
Expand Down Expand Up @@ -51,11 +51,11 @@ public function is_enableable()
*/
protected function phpbb_requirement($phpBB_version = PHPBB_VERSION)
{
if (phpbb_version_compare($phpBB_version, self::REQUIRE_PHPBB_MIN, '<'))
if (phpbb_version_compare($phpBB_version, self::MIN_PHPBB_ALLOWED, '<'))
{
$this->errors[] = 'PHPBB_VERSION_MIN_ERROR';
}
else if (phpbb_version_compare($phpBB_version, self::REQUIRE_PHPBB_MAX, '>='))
else if (phpbb_version_compare($phpBB_version, self::MAX_PHPBB_ALLOWED, '>='))
{
$this->errors[] = 'PHPBB_VERSION_MAX_ERROR';
}
Expand All @@ -69,7 +69,7 @@ protected function phpbb_requirement($phpBB_version = PHPBB_VERSION)
*/
protected function php_requirement($php_version = PHP_VERSION_ID)
{
if ($php_version < self::REQUIRE_PHP)
if ($php_version < self::MIN_PHP_ALLOWED)
{
$this->errors[] = 'PHP_VERSION_ERROR';
}
Expand Down
54 changes: 34 additions & 20 deletions helper/packager.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use phpbb\config\config;
use phpbb\di\service_collection;
use phpbb\filesystem\filesystem;
use phpbb\path_helper;
use phpbb\skeleton\ext;
use phpbb\skeleton\template\twig\extension\skeleton_version_compare;
use phpbb\template\context;
Expand Down Expand Up @@ -75,9 +74,9 @@ public function get_composer_dialog_values()
'extension_homepage' => null,
],
'requirements' => [
'php_version' => '>=' . ext::DEFAULT_PHP,
'phpbb_version_min' => '>=' . ext::DEFAULT_PHPBB_MIN,
'phpbb_version_max' => '<' . ext::DEFAULT_PHPBB_MAX,
'php_version' => '>=' . ext::DEFAULT_SKELETON_PHP,
'phpbb_version_min' => '>=' . ext::DEFAULT_SKELETON_PHPBB_MIN,
'phpbb_version_max' => '<' . ext::DEFAULT_SKELETON_PHPBB_MAX,
],
];
}
Expand Down Expand Up @@ -199,20 +198,35 @@ protected function get_template_engine()
'assets_version' => null,
]);

/** @var path_helper $path_helper */
$path_helper = $this->phpbb_container->get('path_helper');
/** @var filesystem $filesystem */
$filesystem = $this->phpbb_container->get('filesystem');
$environment = new environment(
$config,
$filesystem,
$path_helper,
$this->phpbb_container->getParameter('core.cache_dir'),
$this->phpbb_container->get('ext.manager'),
new loader(
new filesystem()
)
);
$container = $this->phpbb_container;
$path_helper = $container->get('path_helper');
$filesystem = $container->get('filesystem');
$cache_dir = $container->getParameter('core.cache_dir');
$ext_manager = $container->get('ext.manager');

$is_phpbb_4 = defined('PHPBB_VERSION') &&
phpbb_version_compare(PHPBB_VERSION, '4.0.0-dev', '>=');

$args = $is_phpbb_4
? [
$container->get('assets.bag'),
$config,
$filesystem,
$path_helper,
$cache_dir,
$ext_manager,
new loader()
]
: [
$config,
$filesystem,
$path_helper,
$cache_dir,
$ext_manager,
new loader(new filesystem())
];

$environment = new environment(...$args);

// Custom filter for use by packager to decode greater/less than symbols
$filter = new \Twig\TwigFilter('skeleton_decode', function ($string) {
Expand All @@ -225,8 +239,8 @@ protected function get_template_engine()
$config,
new context(),
$environment,
$this->phpbb_container->getParameter('core.cache_dir'),
$this->phpbb_container->get('user'),
$cache_dir,
$container->get('user'),
[
new skeleton_version_compare()
]
Expand Down
6 changes: 3 additions & 3 deletions language/en/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@

'SKELETON_QUESTION_PHP_VERSION' => 'Please enter the PHP requirement of the extension',
'SKELETON_QUESTION_PHP_VERSION_UI' => 'PHP requirement of the extension',
'SKELETON_QUESTION_PHP_VERSION_EXPLAIN' => 'default: &gt;=' . \phpbb\skeleton\ext::DEFAULT_PHP,
'SKELETON_QUESTION_PHP_VERSION_EXPLAIN' => 'default: &gt;=' . \phpbb\skeleton\ext::DEFAULT_SKELETON_PHP,
'SKELETON_QUESTION_PHPBB_VERSION_MIN' => 'Please enter the minimum phpBB requirement of the extension',
'SKELETON_QUESTION_PHPBB_VERSION_MIN_UI' => 'Minimum phpBB requirement of the extension',
'SKELETON_QUESTION_PHPBB_VERSION_MIN_EXPLAIN' => 'default: &gt;=' . \phpbb\skeleton\ext::DEFAULT_PHPBB_MIN,
'SKELETON_QUESTION_PHPBB_VERSION_MIN_EXPLAIN' => 'default: &gt;=' . \phpbb\skeleton\ext::DEFAULT_SKELETON_PHPBB_MIN,
'SKELETON_QUESTION_PHPBB_VERSION_MAX' => 'Please enter the maximum phpBB requirement of the extension',
'SKELETON_QUESTION_PHPBB_VERSION_MAX_UI' => 'Maximum phpBB requirement of the extension',
'SKELETON_QUESTION_PHPBB_VERSION_MAX_EXPLAIN' => 'default: &lt;' . \phpbb\skeleton\ext::DEFAULT_PHPBB_MAX,
'SKELETON_QUESTION_PHPBB_VERSION_MAX_EXPLAIN' => 'default: &lt;' . \phpbb\skeleton\ext::DEFAULT_SKELETON_PHPBB_MAX,

'SKELETON_QUESTION_COMPONENT_PHPLISTENER' => 'Create sample PHP event listeners',
'SKELETON_QUESTION_COMPONENT_PHPLISTENER_UI' => 'PHP event listeners',
Expand Down
4 changes: 2 additions & 2 deletions tests/controller/main_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public function test_handle($status_code, $page_content)
['vendor_name', '', true, \phpbb\request\request_interface::REQUEST, 'foo'],
['author_name', [''], true, \phpbb\request\request_interface::REQUEST, ['bar']],
['extension_version', '1.0.0-dev', true, \phpbb\request\request_interface::REQUEST, '1.0.0-dev'],
['php_version', '>=' . ext::DEFAULT_PHP, false, \phpbb\request\request_interface::REQUEST, '>=' . ext::DEFAULT_PHP],
['php_version', '>=' . ext::DEFAULT_SKELETON_PHP, false, \phpbb\request\request_interface::REQUEST, '>=' . ext::DEFAULT_SKELETON_PHP],
['component_phplistener', false, false, \phpbb\request\request_interface::REQUEST, true],
]);

Expand Down Expand Up @@ -229,7 +229,7 @@ public function test_handle($status_code, $page_content)
'NAME' => 'php_version',
'DESC' => 'SKELETON_QUESTION_PHP_VERSION_UI',
'DESC_EXPLAIN' => 'SKELETON_QUESTION_PHP_VERSION_EXPLAIN',
'VALUE' => '>=' . ext::DEFAULT_PHP,
'VALUE' => '>=' . ext::DEFAULT_SKELETON_PHP,
]],
['requirement', [
'NAME' => 'phpbb_version_min',
Expand Down
2 changes: 1 addition & 1 deletion tests/helper/packager_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public function test_get_template_engine_returns_twig_instance()
$user
);

$this->container->expects($this->exactly(2))
$this->container->expects($this->once())
->method('getParameter')
->with('core.cache_dir')
->willReturn(false);
Expand Down