Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ui_suite_bootstrap
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
ui_suite_bootstrap
Merge requests
!223
Issue
#3486380
by grimreaper, pdureau: Fix views table
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3486380
by grimreaper, pdureau: Fix views table
issue/ui_suite_bootstrap-3486380:3486380-fix-views-table
into
5.1.x
Overview
0
Commits
5
Pipelines
6
Changes
8
Merged
Florent Torregrosa
requested to merge
issue/ui_suite_bootstrap-3486380:3486380-fix-views-table
into
5.1.x
5 months ago
Overview
0
Commits
5
Pipelines
6
Changes
8
Expand
Closes
#3486380
0
0
Merge request reports
Compare
5.1.x
version 4
91e4e3bd
5 months ago
version 3
51dee7fc
5 months ago
version 2
c406add5
5 months ago
version 1
674a4ac7
5 months ago
5.1.x (base)
and
latest version
latest version
d7eecca0
5 commits,
5 months ago
version 4
91e4e3bd
4 commits,
5 months ago
version 3
51dee7fc
3 commits,
5 months ago
version 2
c406add5
2 commits,
5 months ago
version 1
674a4ac7
1 commit,
5 months ago
8 files
+
137
−
59
Side-by-side
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
8
Search (e.g. *.vue) (Ctrl+P)
src/HookHandler/PreprocessViewsViewTable.php
0 → 100644
+
93
−
0
Options
<?php
declare
(
strict_types
=
1
);
namespace
Drupal\ui_suite_bootstrap\HookHandler
;
use
Drupal\Component\Render\FormattableMarkup
;
use
Drupal\Core\DependencyInjection\ContainerInjectionInterface
;
use
Drupal\Core\Render\RendererInterface
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Prepare header and row cells.
*/
class
PreprocessViewsViewTable
implements
ContainerInjectionInterface
{
use
StringTranslationTrait
;
public
function
__construct
(
protected
RendererInterface
$renderer
,
)
{}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
):
static
{
return
new
static
(
$container
->
get
(
'renderer'
)
);
}
/**
* Prepare header and row cells.
*
* @param array $variables
* The preprocessed variables.
*/
public
function
preprocess
(
array
&
$variables
):
void
{
if
(
isset
(
$variables
[
'header'
]))
{
foreach
(
$variables
[
'header'
]
as
$key
=>
$column
)
{
$column
+=
[
'content'
=>
''
,
'sort_indicator'
=>
[],
'url'
=>
''
,
'title'
=>
''
,
'wrapper_element'
=>
''
,
];
$columnContent
=
$column
[
'content'
]
.
$this
->
renderer
->
render
(
$column
[
'sort_indicator'
]);
if
(
$column
[
'url'
])
{
$variables
[
'header'
][
$key
][
'preparedContent'
]
=
[
'#type'
=>
'html_tag'
,
'#tag'
=>
'a'
,
'#value'
=>
$columnContent
,
'#attributes'
=>
[
'href'
=>
$column
[
'url'
],
'title'
=>
$column
[
'title'
],
'rel'
=>
'nofollow'
,
],
'#prefix'
=>
$column
[
'wrapper_element'
]
?
"<
{
$column
[
'wrapper_element'
]
}
>"
:
''
,
'#suffix'
=>
$column
[
'wrapper_element'
]
?
"</
{
$column
[
'wrapper_element'
]
}
>"
:
''
,
];
}
else
{
$variables
[
'header'
][
$key
][
'preparedContent'
]
=
[
'#markup'
=>
new
FormattableMarkup
(
$columnContent
,
[]),
'#prefix'
=>
$column
[
'wrapper_element'
]
?
"<
{
$column
[
'wrapper_element'
]
}
>"
:
''
,
'#suffix'
=>
$column
[
'wrapper_element'
]
?
"</
{
$column
[
'wrapper_element'
]
}
>"
:
''
,
];
}
}
}
if
(
isset
(
$variables
[
'rows'
]))
{
foreach
(
$variables
[
'rows'
]
as
$rowKey
=>
$row
)
{
foreach
(
$row
[
'columns'
]
as
$columnKey
=>
$column
)
{
$columnContent
=
''
;
foreach
(
$column
[
'content'
]
as
$content
)
{
$columnContent
.
=
$this
->
renderer
->
render
(
$content
[
'separator'
])
.
$this
->
renderer
->
render
(
$content
[
'field_output'
]);
}
$variables
[
'rows'
][
$rowKey
][
'columns'
][
$columnKey
][
'preparedContent'
]
=
[
'#markup'
=>
new
FormattableMarkup
(
$columnContent
,
[]),
'#prefix'
=>
$column
[
'wrapper_element'
]
?
"<
{
$column
[
'wrapper_element'
]
}
>"
:
''
,
'#suffix'
=>
$column
[
'wrapper_element'
]
?
"</
{
$column
[
'wrapper_element'
]
}
>"
:
''
,
];
}
}
}
}
}
Loading