Skip to content
Snippets Groups Projects
Commit 2420680d authored by KUNAL SAHU's avatar KUNAL SAHU Committed by Tim Diels
Browse files

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!1Issue #3296233: Drupal Coding Standard Issue
......@@ -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
......@@ -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']);
}
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment