Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
WCMS
uw_dashboard
Commits
a34ff16a
Commit
a34ff16a
authored
Nov 27, 2020
by
Liam Morland
Browse files
Coding standards
parent
67ea1f90
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
35 deletions
+68
-35
src/Form/AllowedBlocksForm.php
src/Form/AllowedBlocksForm.php
+13
-7
src/Plugin/Block/ContentManagementMenuBlock.php
src/Plugin/Block/ContentManagementMenuBlock.php
+20
-12
src/Plugin/Block/FormsListBlock.php
src/Plugin/Block/FormsListBlock.php
+0
-1
src/Plugin/Block/SiteManagementMenuBlock.php
src/Plugin/Block/SiteManagementMenuBlock.php
+16
-8
src/Plugin/LayoutBuilderRestriction/UwDashboardRestrictBlocksLayouts.php
...utBuilderRestriction/UwDashboardRestrictBlocksLayouts.php
+17
-5
uw_dashboard.info.yml
uw_dashboard.info.yml
+2
-2
No files found.
src/Form/AllowedBlocksForm.php
View file @
a34ff16a
<?php
namespace
Drupal\uw_dashboard\Form
;
use
Drupal\Core\Block\BlockManagerInterface
;
use
Drupal\Core\Form\ConfigFormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Class for blocks allowed on the dashboard.
*/
class
AllowedBlocksForm
extends
ConfigFormBase
{
const
SETTINGS
=
'uw_dashboard.allowed_blocks'
;
/** @var \Drupal\Core\Block\BlockManagerInterface */
/**
* The plugin manager block.
*
* @var \Drupal\Core\Block\BlockManagerInterface
*/
protected
$blockManager
;
/**
...
...
@@ -28,13 +33,14 @@ class AllowedBlocksForm extends ConfigFormBase {
* UWDashboardBlockRestriction constructor.
*
* @param \Drupal\Core\Block\BlockManagerInterface $pluginManagerBlock
* The plugin manager block.
*/
public
function
__construct
(
BlockManagerInterface
$pluginManagerBlock
)
{
$this
->
blockManager
=
$pluginManagerBlock
;
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
protected
function
getEditableConfigNames
()
{
return
[
...
...
@@ -43,14 +49,14 @@ class AllowedBlocksForm extends ConfigFormBase {
}
/**
* @inherit
D
oc
*
{
@inherit
d
oc
}
*/
public
function
getFormId
()
{
return
'uw_dashboard_block_restrictions'
;
}
/**
* @inherit
D
oc
*
{
@inherit
d
oc
}
*/
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
)
{
$rows
=
[];
...
...
@@ -85,7 +91,7 @@ class AllowedBlocksForm extends ConfigFormBase {
}
/**
* @inherit
D
oc
*
{
@inherit
d
oc
}
*/
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$blocks
=
$form_state
->
getValue
(
'allowed_blocks'
);
...
...
src/Plugin/Block/ContentManagementMenuBlock.php
View file @
a34ff16a
...
...
@@ -9,9 +9,8 @@ use Drupal\Core\Menu\MenuTreeParameters;
use
Drupal\Core\Plugin\ContainerFactoryPluginInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Class
C
ontent
M
anagement
M
enu
B
lock.
* Class
for the c
ontent
m
anagement
m
enu
b
lock.
*
* @package Drupal\uw_dashboard\Plugin\Block
*
...
...
@@ -22,11 +21,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class
ContentManagementMenuBlock
extends
BlockBase
implements
ContainerFactoryPluginInterface
{
/** @var \Drupal\Core\Menu\MenuLinkTree */
/**
* The menu link tree.
*
* @var \Drupal\Core\Menu\MenuLinkTree
*/
protected
$menuLinkTree
;
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
function
build
()
{
$build
=
[];
...
...
@@ -51,7 +54,8 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
if
(
!
empty
(
$secondary_menu
))
{
// If sub menu exists for primary menu item, use it as default, but
// also append new menu items (items that are added after block has
// been configured. If not (else block) use secondary menu by default.
// been configured. If not (else block) use secondary menu by
// default.
if
(
isset
(
$configured
[
$id
]))
{
$selected_secondary
=
array_keys
(
array_filter
(
$configured
[
$id
]
+
$secondary_menu
));
}
...
...
@@ -112,7 +116,7 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
static
function
create
(
ContainerInterface
$container
,
...
...
@@ -132,9 +136,13 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
* ContentManagementMenuBlock constructor.
*
* @param array $configuration
* @param $plugin_id
* @param $plugin_definition
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Menu\MenuLinkTreeInterface $menuLinkTree
* The menu link tree.
*/
public
function
__construct
(
array
$configuration
,
...
...
@@ -147,7 +155,7 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
function
blockForm
(
$form
,
FormStateInterface
$form_state
)
{
$form
[
'#attached'
][
'library'
][]
=
'uw_dashboard/uw-styles'
;
...
...
@@ -197,7 +205,7 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
function
submitConfigurationForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$menu_first_level
=
$this
->
getContentMenuItems
();
...
...
@@ -243,13 +251,13 @@ class ContentManagementMenuBlock extends BlockBase implements ContainerFactoryPl
/**
* Process menu tree, setting key to be plugin id, and value to be title.
*
* @param $tree
* @param
array
$tree
* Tree to be processed, access level checked.
*
* @return array
* Array where key is plugin id, and title is the value.
*/
protected
function
processMenuTree
(
$tree
)
{
protected
function
processMenuTree
(
array
$tree
)
{
$menu
=
[];
foreach
(
$tree
as
$menu_item
)
{
...
...
src/Plugin/Block/FormsListBlock.php
View file @
a34ff16a
...
...
@@ -107,7 +107,6 @@ class FormsListBlock extends BlockBase {
// '#default_value' => $this->configuration['display_my_forms'] ?? 'no',
// ];
// @endcode
return
$form
;
}
...
...
src/Plugin/Block/SiteManagementMenuBlock.php
View file @
a34ff16a
...
...
@@ -10,7 +10,7 @@ use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Class UwDblSiteManagement
* Class UwDblSiteManagement
.
*
* @package Drupal\uw_site_management\Plugin\Block
*
...
...
@@ -21,11 +21,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class
SiteManagementMenuBlock
extends
BlockBase
implements
ContainerFactoryPluginInterface
{
/** @var \Drupal\Core\Menu\MenuLinkTree */
/**
* The menu link tree.
*
* @var \Drupal\Core\Menu\MenuLinkTree
*/
protected
$menuLinkTree
;
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
function
build
()
{
$links
=
[];
...
...
@@ -45,7 +49,7 @@ class SiteManagementMenuBlock extends BlockBase implements ContainerFactoryPlugi
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
static
function
create
(
ContainerInterface
$container
,
...
...
@@ -65,9 +69,13 @@ class SiteManagementMenuBlock extends BlockBase implements ContainerFactoryPlugi
* UwDblSiteManagement constructor.
*
* @param array $configuration
* @param $plugin_id
* @param $plugin_definition
* A configuration array containing information about the plugin instance.
* @param string $plugin_id
* The plugin_id for the plugin instance.
* @param mixed $plugin_definition
* The plugin implementation definition.
* @param \Drupal\Core\Menu\MenuLinkTreeInterface $menuLinkTree
* The menu link tree.
*/
public
function
__construct
(
array
$configuration
,
...
...
@@ -80,7 +88,7 @@ class SiteManagementMenuBlock extends BlockBase implements ContainerFactoryPlugi
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
function
blockForm
(
$form
,
FormStateInterface
$form_state
)
{
$menu_items
=
$this
->
getMenuItems
();
...
...
@@ -104,7 +112,7 @@ class SiteManagementMenuBlock extends BlockBase implements ContainerFactoryPlugi
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
function
submitConfigurationForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$menus
=
$form_state
->
getValue
(
'selected_menus'
);
...
...
src/Plugin/LayoutBuilderRestriction/UwDashboardRestrictBlocksLayouts.php
View file @
a34ff16a
...
...
@@ -7,7 +7,7 @@ use Drupal\layout_builder_restrictions\Plugin\LayoutBuilderRestriction\EntityVie
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
*
UwDashboardR
estrict
B
locks
L
ayouts
class
.
*
Class for r
estrict
ing b
locks
/l
ayouts
for UW dashboard
.
*
* @LayoutBuilderRestriction(
* id = "uw_dashboard_restrict_blocks_layouts",
...
...
@@ -17,11 +17,15 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
*/
class
UwDashboardRestrictBlocksLayouts
extends
EntityViewModeRestriction
{
/** @var \Drupal\Core\Config\ConfigFactoryInterface */
/**
* Config factory to load blocks allowed to be displayed on dashboard.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected
$configFactory
;
/**
* @inherit
D
oc
*
{
@inherit
d
oc
}
*/
public
static
function
create
(
ContainerInterface
$container
,
...
...
@@ -62,7 +66,7 @@ class UwDashboardRestrictBlocksLayouts extends EntityViewModeRestriction {
}
/**
* {@inherit
D
oc}
* {@inherit
d
oc}
*/
public
function
alterBlockDefinitions
(
array
$definitions
,
array
$context
)
{
...
...
@@ -93,7 +97,14 @@ class UwDashboardRestrictBlocksLayouts extends EntityViewModeRestriction {
if
(
$context
[
'section_storage'
]
->
pluginId
==
'dashboards'
||
$context
[
'section_storage'
]
->
pluginId
==
'dashboards_override'
)
{
// The allowed layouts machine names.
$allowed_layouts
=
[
'layout_1'
,
'uw_1_column'
,
'uw_2_column'
,
'uw_3_column'
,
'uw_inverted_l_left'
,
'uw_inverted_l_right'
];
$allowed_layouts
=
[
'layout_1'
,
'uw_1_column'
,
'uw_2_column'
,
'uw_3_column'
,
'uw_inverted_l_left'
,
'uw_inverted_l_right'
,
];
// Step through each of the definitions and unset anything
// that is not in the allowed layouts array.
...
...
@@ -110,4 +121,5 @@ class UwDashboardRestrictBlocksLayouts extends EntityViewModeRestriction {
return
$definitions
;
}
}
uw_dashboard.info.yml
View file @
a34ff16a
name
:
'
Dashboard
items'
description
:
'
Block
placement
for
dashboard
blocks
and
site
management
menu'
type
:
module
core_version_requirement
:
^
8 || ^9
core_version_requirement
:
'
^8.
8
||
^9
'
dependencies
:
-
better_exposed_filters
-
config_views
-
dashboards
-
layout_builder_restrictions
-
node
-
system
-
user
-
views
-
views_autocomplete_filters
-
layout_builder_restrictions
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment