whitespace adjustments
[ryf-theme.git] / modules / footer / src / Plugin / Block / FooterBlock.php
CommitLineData
a8a2b83e
VSB
1<?php
2/**
3 * @file
4 * Contains \Drupal\footer\Plugin\Block\FooterBlock.
5 */
6namespace Drupal\footer\Plugin\Block;
7use Drupal\Core\Menu\MenuTreeParameters;
8use Drupal\Core\Block\BlockBase;
9use Drupal\node\Entity\Node;
10use Drupal\Core\Block\BlockPluginInterface;
11use Drupal\Core\Form\FormStateInterface;
12
13
14/**
15 * Provides a 'footer' block.
16 *
17 * @Block(
18 * id = "footer_block",
19 * admin_label = @Translation("Footer"),
20 * category = @Translation("RYF Custom Module")
21 * )
22 */
23class FooterBlock extends BlockBase implements BlockPluginInterface {
24 /**
25 * {@inheritdoc}
26 */
27 public function build() {
28
29 $menu_tree_parameters = new MenuTreeParameters();
30 $tree = \Drupal::menuTree()->load('footer', $menu_tree_parameters);
31
32 $cc = 0;
33 foreach($tree as $menu){
34 $title = $menu->link->getTitle();
35 $urlObject = $menu->link->getUrlObject();
36 $url = $urlObject->toString();
37 $weight = $menu->link->getWeight();
38 $enabled = $menu->link->isEnabled();
39
40 if($enabled) {
41 $menu_array[$cc]['title'] = $title;
42 $menu_array[$cc]['url'] = $url;
43 $menu_array[$cc]['weight'] = $weight;
44 $cc++;
45 }
46
47 }
48
49 usort($menu_array, function($a, $b) {
deb2cccb 50 return $a['weight'] - $b['weight'];
a8a2b83e
VSB
51 });
52
deb2cccb 53 return array(
a8a2b83e
VSB
54 '#theme' => 'footer',
55 '#menu_array' => $menu_array,
deb2cccb
AE
56 '#attached' => array(
57 'library' => array(
58 'footer/footer',
59 ),
60 ),
61 );
a8a2b83e 62
deb2cccb 63 }
a8a2b83e 64}