Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lb_branch_hours_blocks
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
lb_branch_hours_blocks
Commits
aca2f16c
Commit
aca2f16c
authored
1 year ago
by
Davyd Burianuvatyi
Browse files
Options
Downloads
Patches
Plain Diff
Issue [
#3416384
]: Missed content blocks
parent
20bfa519
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!23
Resolve #3416384 "Missed content blocks"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lb_branch_hours_blocks.install
+68
-0
68 additions, 0 deletions
lb_branch_hours_blocks.install
with
68 additions
and
0 deletions
lb_branch_hours_blocks.install
0 → 100644
+
68
−
0
View file @
aca2f16c
<?php
/**
* @file
* Installation and update implementations.
*/
use
Drupal\layout_builder
\Section
;
use
Drupal\layout_builder
\SectionComponent
;
/**
* Implements hook_install().
*/
function
lb_branch_hours_blocks_install
()
{
// Update form and view displays for Branch content type.
_lb_branch_hours_blocks_update_displays_on_install
();
}
/**
* Update Branch content type display modes on enabling the module.
*
* @throws \Drupal\Core\Entity\EntityStorageException
*/
function
_lb_branch_hours_blocks_update_displays_on_install
()
{
/** @var \Drupal\Core\Entity\EntityDisplayRepositoryInterface $entity_display_repository */
$entity_display_repository
=
\Drupal
::
service
(
'entity_display.repository'
);
$uuid_service
=
\Drupal
::
service
(
'uuid'
);
// Update Branch content type view displays.
$view_modes
=
$entity_display_repository
->
getViewModeOptionsByBundle
(
'node'
,
'branch'
);
foreach
(
array_keys
(
$view_modes
)
as
$view_mode
)
{
/** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
$view_display
=
$entity_display_repository
->
getViewDisplay
(
'node'
,
'branch'
,
$view_mode
);
if
(
$view_mode
==
'full'
)
{
$sections
=
$view_display
->
getThirdPartySetting
(
'layout_builder'
,
'sections'
);
$section
=
new
Section
(
'bootstrap_layout_builder:blb_col_1'
,
[
'container'
=>
'container'
,
'label'
=>
'Branch header'
,
'container_wrapper'
=>
[
'bootstrap_styles'
=>
[
'background'
=>
[
'background_type'
=>
'color'
],
'background_color'
=>
[
'class'
=>
'ylb-bg-semi-light-grey'
],
'text_color'
=>
[
'class'
=>
'ylb-text-white'
],
],
],
'container_wrapper_classes'
=>
'location-header'
,
]);
$component
=
new
SectionComponent
(
$uuid_service
->
generate
(),
'blb_region_col_1'
,
[
'id'
=>
'lb_branch_hours'
,
'label'
=>
'Branch Hours'
,
'label_display'
=>
'0'
,
'provider'
=>
'lb_branch_hours_blocks'
,
'context_mapping'
=>
[
'node'
=>
'layout_builder.entity'
],
]);
$section
->
appendComponent
(
$component
);
$sections
[]
=
$section
;
$sections
=
_y_branch_create_sections_layout_builder
();
$view_display
->
setThirdPartySetting
(
'layout_builder'
,
'sections'
,
$sections
);
}
$view_display
->
save
();
}
}
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