Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
layout_builder_modal
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
layout_builder_modal
Merge requests
!9
Fixed Drupal calls.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Open
Fixed Drupal calls.
issue/layout_builder_modal-3427778:3427778-drupal-calls-should
into
8.x-1.x
Overview
0
Commits
1
Pipelines
0
Changes
1
Open
Chaitanya Dessai
requested to merge
issue/layout_builder_modal-3427778:3427778-drupal-calls-should
into
8.x-1.x
1 year ago
Overview
0
Commits
1
Pipelines
0
Changes
1
Expand
Closes
#3427778
0
0
Merge request reports
Compare
8.x-1.x
8.x-1.x (HEAD)
and
latest version
latest version
baf9ea67
1 commit,
1 year ago
1 file
+
33
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
src/Form/LayoutBuilderModalSettingsForm.php
+
33
−
4
Options
@@ -2,14 +2,44 @@
namespace
Drupal\layout_builder_modal\Form
;
use
Drupal\Core\Config\ConfigFactoryInterface
;
use
Drupal\Core\Form\ConfigFormBase
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Theme\ThemeManagerInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
/**
* Provides the layout builder modal configuration form.
*/
class
LayoutBuilderModalSettingsForm
extends
ConfigFormBase
{
protected
$themeConfig
;
protected
$themeHandler
;
/**
* Constructs a LayoutBuilderModalSettingsForm object.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The config factory.
* @param \Drupal\Core\Theme\ThemeManagerInterface $theme_manager
* The theme manager.
*/
public
function
__construct
(
ConfigFactoryInterface
$config_factory
,
ThemeManagerInterface
$theme_manager
)
{
parent
::
__construct
(
$config_factory
);
$this
->
themeConfig
=
$config_factory
->
get
(
'system.theme'
);
$this
->
themeHandler
=
$theme_manager
;
}
/**
* {@inheritdoc}
*/
public
static
function
create
(
ContainerInterface
$container
)
{
return
new
static
(
$container
->
get
(
'config.factory'
),
$container
->
get
(
'theme.manager'
)
);
}
/**
* {@inheritdoc}
*/
@@ -63,10 +93,9 @@ class LayoutBuilderModalSettingsForm extends ConfigFormBase {
'#default_value'
=>
$config
->
get
(
'modal_autoresize'
),
'#description'
=>
$this
->
t
(
'Allow modal to automatically resize and enable scrolling for dialog content. If enabled, the ability to drag and resize the dialog will be disabled.'
),
];
$theme_config
=
\Drupal
::
config
(
'system.theme'
);
$theme_handler
=
\Drupal
::
service
(
'theme_handler'
);
$theme_config
=
$this
->
themeConfig
;
$theme_options
=
[
'default_theme'
=>
$this
->
t
(
'Default (%default_theme)'
,
[
'%default_theme'
=>
$theme_handler
->
getName
(
$theme_config
->
get
(
'default'
)
)
]),
'default_theme'
=>
$this
->
t
(
'Default (%default_theme)'
,
[
'%default_theme'
=>
$theme_config
->
get
(
'default'
)]),
'seven'
=>
$this
->
t
(
"Administrative (Seven)"
),
];
$form
[
'options'
][
'theme_display'
]
=
[
@@ -86,7 +115,7 @@ class LayoutBuilderModalSettingsForm extends ConfigFormBase {
public
function
validateForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$width
=
$form_state
->
getValue
(
'modal_width'
);
if
(
substr_count
(
$width
,
'%'
)
==
1
&&
$width
[
strlen
(
$width
)
-
1
]
==
'%'
)
{
$percentage_value
=
substr
(
$width
,
0
,
-
1
);
$percentage_value
=
substr
(
$width
,
0
,
-
1
);
if
(
!
is_numeric
(
$percentage_value
)
||
$percentage_value
<
1
||
$percentage_value
>
100
)
{
$form_state
->
setErrorByName
(
'modal_width'
,
$this
->
t
(
'Width must be a positive number or a percentage.'
));
}
Loading