Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
lb_aos
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_aos
Commits
2420680d
Commit
2420680d
authored
1 year ago
by
KUNAL SAHU
Committed by
Tim Diels
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3296233
by thomasfava, tim-diels, Rakhi Soni: Drupal Coding Standard Issue
parent
6aa34a28
Branches
1.0.x
Tags
1.0.3
1 merge request
!1
Issue #3296233: Drupal Coding Standard Issue
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
lb_aos.info.yml
+2
-2
2 additions, 2 deletions
lb_aos.info.yml
lb_aos.module
+3
-6
3 additions, 6 deletions
lb_aos.module
src/EventSubscriber/BlockComponentRenderArraySubscriber.php
+8
-7
8 additions, 7 deletions
src/EventSubscriber/BlockComponentRenderArraySubscriber.php
with
13 additions
and
15 deletions
lb_aos.info.yml
+
2
−
2
View file @
2420680d
...
...
@@ -3,5 +3,5 @@ description: 'Allow layout builder blocks to define an animation on scroll'
core_version_requirement
:
^8.8 || ~9.0 || ^10
type
:
module
dependencies
:
-
aos
-
layout_builder
-
aos
:aos
-
drupal:
layout_builder
This diff is collapsed.
Click to expand it.
lb_aos.module
+
3
−
6
View file @
2420680d
...
...
@@ -2,7 +2,7 @@
/**
* @file
*
lb_aos
module.
*
Contains hooks for the Layout Builder Animate On Scroll
module.
*/
use
Drupal\Core\Form\FormStateInterface
;
...
...
@@ -18,8 +18,7 @@ use Drupal\Core\Form\FormStateInterface;
*
* Modify the configuration form for layout builder components (blocks).
*/
function
lb_aos_form_alter
(
array
&
$form
,
FormStateInterface
$formState
):
void
{
function
lb_aos_form_alter
(
array
&
$form
,
FormStateInterface
$formState
):
void
{
if
(
$form
[
'#form_id'
]
===
'layout_builder_add_block'
||
$form
[
'#form_id'
]
===
'layout_builder_update_block'
)
{
$formObject
=
$formState
->
getFormObject
();
...
...
@@ -75,12 +74,10 @@ function lb_aos_form_alter(array &$form, FormStateInterface $formState): void
* Persists the configured block animation to the component configuration data,
* which is later persisted to section storage by layout builder's base form.
*/
function
_lb_aos_submit_block_form
(
array
$form
,
FormStateInterface
$formState
):
void
{
function
_lb_aos_submit_block_form
(
array
$form
,
FormStateInterface
$formState
):
void
{
$formObject
=
$formState
->
getFormObject
();
$component
=
$formObject
->
getCurrentComponent
();
$animation
=
$formState
->
getValue
(
'animations'
);
$component
->
set
(
'animation_type'
,
$animation
[
'animation_type'
]);
}
This diff is collapsed.
Click to expand it.
src/EventSubscriber/BlockComponentRenderArraySubscriber.php
+
8
−
7
View file @
2420680d
...
...
@@ -5,11 +5,11 @@ namespace Drupal\lb_aos\EventSubscriber;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\layout_builder
\Event\SectionComponentBuildRenderArrayEvent
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
use
Drupal\layout_builder
\LayoutBuilderEvents
;
use
Symfony\Component\EventDispatcher\EventSubscriberInterface
;
/**
*
Class
BlockComponentRenderArraySubscriber.
* Block
Component
Render
Array
Subscriber.
*/
class
BlockComponentRenderArraySubscriber
implements
EventSubscriberInterface
{
...
...
@@ -21,7 +21,7 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface {
protected
$entityTypeManager
;
/**
*
Drupal\Core\Config\ConfigFactoryInterface definition
.
*
The configuration factory
.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
...
...
@@ -33,7 +33,7 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface {
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
*
Access
configuration.
*
The
configuration
factory
.
*/
public
function
__construct
(
EntityTypeManagerInterface
$entityTypeManager
,
ConfigFactoryInterface
$config_factory
)
{
$this
->
entityTypeManager
=
$entityTypeManager
;
...
...
@@ -46,7 +46,10 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface {
public
static
function
getSubscribedEvents
()
{
// Layout Builder also subscribes to this event to build the initial render
// array. We use a higher weight so that we execute after it.
$events
[
LayoutBuilderEvents
::
SECTION_COMPONENT_BUILD_RENDER_ARRAY
]
=
[
'onBuildRender'
,
50
];
$events
[
LayoutBuilderEvents
::
SECTION_COMPONENT_BUILD_RENDER_ARRAY
]
=
[
'onBuildRender'
,
50
,
];
return
$events
;
}
...
...
@@ -59,7 +62,6 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface {
public
function
onBuildRender
(
SectionComponentBuildRenderArrayEvent
$event
)
{
$build
=
$event
->
getBuild
();
// This shouldn't happen - Layout Builder should have already created the
// initial build data.
if
(
empty
(
$build
))
{
...
...
@@ -70,7 +72,6 @@ class BlockComponentRenderArraySubscriber implements EventSubscriberInterface {
if
(
$animation_type
)
{
$build
[
'#animation_type'
]
=
$animation_type
;
$build
[
'#attributes'
][
'data-aos'
]
=
$animation_type
;
$build
[
'#attached'
][
'library'
][]
=
'aos/aos'
;
$build
[
'#cache'
][
'tags'
][]
=
'config:lb_aos.animation_type.'
.
$animation_type
;
...
...
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