Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ui_patterns
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_patterns
Commits
c3479f06
Commit
c3479f06
authored
2 months ago
by
Mikael Meulle
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3512018
by just_like_good_vibes: Make Component element builder alterable (suite)
parent
6ee5db3b
No related branches found
No related tags found
1 merge request
!348
Resolve #3512018 "2.0.1 make componenent"
Pipeline
#444808
passed
2 months ago
Stage: build
Stage: validate
Stage: test
Changes
2
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Element/ComponentElementBuilder.php
+2
-2
2 additions, 2 deletions
src/Element/ComponentElementBuilder.php
ui_patterns.api.php
+9
-1
9 additions, 1 deletion
ui_patterns.api.php
with
11 additions
and
3 deletions
src/Element/ComponentElementBuilder.php
+
2
−
2
View file @
c3479f06
...
...
@@ -91,7 +91,7 @@ class ComponentElementBuilder implements TrustedCallbackInterface {
$build
=
$source
->
alterComponent
(
$build
);
$prop_type
=
$definition
[
'ui_patterns'
][
'type_definition'
];
$data
=
$source
->
getValue
(
$prop_type
);
$this
->
moduleHandler
->
alter
(
'ui_patterns_source_value'
,
$data
,
$source
);
$this
->
moduleHandler
->
alter
(
'ui_patterns_source_value'
,
$data
,
$source
,
$configuration
);
if
(
empty
(
$data
)
&&
$prop_type
->
getPluginId
()
!==
'attributes'
)
{
// For JSON Schema validator, empty value is not the same as missing
// value, and we want to prevent some of the prop types rules to be
...
...
@@ -186,7 +186,7 @@ class ComponentElementBuilder implements TrustedCallbackInterface {
}
$build
=
$source
->
alterComponent
(
$build
);
$source_value
=
$source
->
getValue
(
$slot_prop_type
)
??
[];
$this
->
moduleHandler
->
alter
(
'ui_patterns_source_value'
,
$source_value
,
$source
);
$this
->
moduleHandler
->
alter
(
'ui_patterns_source_value'
,
$source_value
,
$source
,
$source_configuration
);
if
(
Element
::
isRenderArray
(
$source_value
))
{
$build
[
"#slots"
][
$slot_id
][]
=
$this
->
isSingletonRenderArray
(
$source_value
)
?
array_values
(
$source_value
)[
0
]
:
$source_value
;
}
...
...
This diff is collapsed.
Click to expand it.
ui_patterns.api.php
+
9
−
1
View file @
c3479f06
...
...
@@ -24,8 +24,16 @@ function hook_component_info_alter(array &$definitions) {
* Value produced by the source.
* @param \Drupal\ui_patterns\SourceInterface $source
* The source object which has produced the value.
* @param array $source_configuration
* The full raw configuration used to build the source.
*
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
function
hook_ui_patterns_source_value_alter
(
mixed
&
$value
,
\Drupal\ui_patterns\SourceInterface
$source
)
:
void
{
function
hook_ui_patterns_source_value_alter
(
mixed
&
$value
,
\Drupal\ui_patterns\SourceInterface
$source
,
array
&
$source_configuration
)
:
void
{
$type_definition
=
$source
->
getPropDefinition
()[
'ui_patterns'
][
'type_definition'
];
if
(
$type_definition
instanceof
\Drupal\ui_patterns\Plugin\UiPatterns\PropType\SlotPropType
)
{
if
(
is_array
(
$value
))
{
$value
[
'#cache'
][
'tags'
][]
=
'custom_cache_tag'
;
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment