1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-05 07:07:51 +02:00

[ticket/16944] Add missing definitions and make logging optional

PHPBB3-16944
This commit is contained in:
Marc Alexander 2023-11-12 16:00:59 +01:00
parent 3db2089208
commit 1f5ae7be76
No known key found for this signature in database
GPG Key ID: 50E0D2423696F995
3 changed files with 31 additions and 6 deletions

View File

@ -9,6 +9,18 @@ imports:
- { resource: ../../default/container/services_twig.yml }
services:
assets.bag:
class: phpbb\template\assets_bag
shared: false
arguments:
- '@assets.iconify_bundler'
assets.iconify_bundler:
class: phpbb\assets\iconify_bundler
shared: false
arguments:
- ~
cache.driver:
class: '%cache.driver.class%'
arguments:
@ -76,6 +88,7 @@ services:
template.twig.environment:
class: phpbb\template\twig\environment
arguments:
- '@assets.bag'
- '@config'
- '@filesystem'
- '@path_helper'

View File

@ -14,10 +14,11 @@
namespace phpbb\assets;
use Iconify\JSONTools\Collection;
use phpbb\log\log_interface;
class iconify_bundler
{
/** @var \phpbb\log\log_interface */
/** @var log_interface */
protected $log;
/** @var string[] Icons list */
@ -26,9 +27,9 @@ class iconify_bundler
/**
* Constructor for iconify bundler
*
* @param \phpbb\log\log_interface $log Logger
* @param log_interface|null $log Logger
*/
public function __construct(\phpbb\log\log_interface $log)
public function __construct(?log_interface $log)
{
$this->log = $log;
}
@ -113,7 +114,10 @@ class iconify_bundler
if ($icon === null || $icon['provider'] !== '')
{
// Invalid name or icon name does not have provider
if ($this->log)
{
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_INVALID', false, [$icon_name]);
}
continue;
}
@ -213,18 +217,25 @@ class iconify_bundler
// Load icon set
$collection = new Collection($prefix);
if (!$collection->loadIconifyCollection($prefix))
{
if ($this->log)
{
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_COLLECTION_INVALID', false, [$prefix]);
}
continue;
}
// Make sure all icons exist
foreach ($iconsList as $name)
{
if (!$collection->iconExists($name))
{
if ($this->log)
{
$this->log->add('critical', ANONYMOUS, '', 'LOG_ICON_INVALID', false, [$prefix . ':' . $name]);
}
}
}
// Get data for all icons as string
$output .= $collection->scriptify([

View File

@ -69,6 +69,7 @@ class phpbb_email_parsing_test extends phpbb_test_case
$log = new \phpbb\log\dummy();
$iconify_bundler = new \phpbb\assets\iconify_bundler($log);
$assets_bag = new \phpbb\template\assets_bag($iconify_bundler);
$phpbb_container->set('assets.bag', $assets_bag);
$context = new \phpbb\template\context();
$twig = new \phpbb\template\twig\environment(