mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/15538] Extract service and enhance icon function
PHPBB3-15538
This commit is contained in:
parent
a7ae904195
commit
b4b6ba0a37
4 changed files with 13 additions and 17 deletions
|
@ -29,6 +29,7 @@ imports:
|
||||||
- { resource: services_text_formatter.yml }
|
- { resource: services_text_formatter.yml }
|
||||||
- { resource: services_text_reparser.yml }
|
- { resource: services_text_reparser.yml }
|
||||||
- { resource: services_twig.yml }
|
- { resource: services_twig.yml }
|
||||||
|
- { resource: services_twig_extensions.yml }
|
||||||
- { resource: services_ucp.yml }
|
- { resource: services_ucp.yml }
|
||||||
- { resource: services_user.yml }
|
- { resource: services_user.yml }
|
||||||
|
|
||||||
|
|
|
@ -54,13 +54,6 @@ services:
|
||||||
tags:
|
tags:
|
||||||
- { name: twig.extension }
|
- { name: twig.extension }
|
||||||
|
|
||||||
template.twig.extensions.icon:
|
|
||||||
class: phpbb\template\twig\extension\icon
|
|
||||||
arguments:
|
|
||||||
- '@user'
|
|
||||||
tags:
|
|
||||||
- { name: twig.extension }
|
|
||||||
|
|
||||||
template.twig.extensions.routing:
|
template.twig.extensions.routing:
|
||||||
class: phpbb\template\twig\extension\routing
|
class: phpbb\template\twig\extension\routing
|
||||||
arguments:
|
arguments:
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Twig extensions not needed by the installer
|
||||||
|
|
||||||
|
services:
|
||||||
|
template.twig.extensions.icon:
|
||||||
|
class: phpbb\template\twig\extension\icon
|
||||||
|
arguments:
|
||||||
|
- '@user'
|
||||||
|
tags:
|
||||||
|
- { name: twig.extension }
|
|
@ -67,7 +67,7 @@ class icon extends \Twig\Extension\AbstractExtension
|
||||||
*/
|
*/
|
||||||
public function icon(environment $environment, $type, $icon, $title = '', $hidden = false, $classes = '', array $attributes = [])
|
public function icon(environment $environment, $type, $icon, $title = '', $hidden = false, $classes = '', array $attributes = [])
|
||||||
{
|
{
|
||||||
$type = utf8_strtolower($type);
|
$type = strtolower($type);
|
||||||
|
|
||||||
switch ($type)
|
switch ($type)
|
||||||
{
|
{
|
||||||
|
@ -141,16 +141,9 @@ class icon extends \Twig\Extension\AbstractExtension
|
||||||
{
|
{
|
||||||
if ($element->nodeName === 'svg')
|
if ($element->nodeName === 'svg')
|
||||||
{
|
{
|
||||||
$children = [];
|
while (isset($element->firstChild))
|
||||||
|
|
||||||
foreach ($element->childNodes as $node)
|
|
||||||
{
|
{
|
||||||
$children[] = $node;
|
$element->parentNode->insertBefore($element->firstChild, $element);
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($children as $child)
|
|
||||||
{
|
|
||||||
$element->parentNode->insertBefore($child, $element);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue