1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-05-05 15:16:16 +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 } - { resource: ../../default/container/services_twig.yml }
services: 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: cache.driver:
class: '%cache.driver.class%' class: '%cache.driver.class%'
arguments: arguments:
@ -76,6 +88,7 @@ services:
template.twig.environment: template.twig.environment:
class: phpbb\template\twig\environment class: phpbb\template\twig\environment
arguments: arguments:
- '@assets.bag'
- '@config' - '@config'
- '@filesystem' - '@filesystem'
- '@path_helper' - '@path_helper'

View File

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

View File

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