Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nextjs
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
nextjs
Merge requests
!2
Issue
#3450055
: Remove dedicated environments
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3450055
: Remove dedicated environments
3450055-remove-dedicated-environments
into
1.0.x
Overview
0
Commits
1
Pipelines
2
Changes
18
Merged
Christian Foidl
requested to merge
3450055-remove-dedicated-environments
into
1.0.x
11 months ago
Overview
0
Commits
1
Pipelines
2
Changes
18
Expand
Closes
#3450055
0
0
Merge request reports
Compare
1.0.x
1.0.x (base)
and
latest version
latest version
bd8181a3
1 commit,
11 months ago
18 files
+
60
−
672
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
18
Search (e.g. *.vue) (Ctrl+P)
src/Element/NextjsEnvironmentSelect.php deleted
100644 → 0
+
0
−
74
Options
<?php
namespace
Drupal\nextjs\Element
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Render\Element\Select
;
use
Drupal\Core\StringTranslation\TranslatableMarkup
;
use
Drupal\Core\Url
;
/**
* Provides a select form element that displays available nextjs environments.
*
* Properties:
* - #empty_option: The label that will be displayed to denote no selection.
* - #empty_value: The value of the option that is used to denote no selection.
* - #env_description: A boolean value that determines if information about
* environment is added to the element's description.
*
* @FormElement("nextjs_environment_select")
*/
class
NextjsEnvironmentSelect
extends
Select
{
/**
* {@inheritdoc}
*/
public
function
getInfo
()
{
$info
=
parent
::
getInfo
();
$class
=
get_class
(
$this
);
// Add a process function.
array_unshift
(
$info
[
'#process'
],
[
$class
,
'processNextjsEnvironmentSelect'
]);
// Add a property for Next.js environment description.
$info
[
'#env_description'
]
=
TRUE
;
// Add the 'empty' option.
$info
[
'#empty_option'
]
=
$this
->
t
(
'- Select a Next.js environment -'
);
return
$info
;
}
/**
* Processes a Next.js environment select list form element.
*
* @param array $element
* The form element to process.
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
* @param array $complete_form
* The complete form structure.
*
* @return array
* The processed element.
*/
public
static
function
processNextjsEnvironmentSelect
(
array
&
$element
,
FormStateInterface
$form_state
,
array
&
$complete_form
)
{
// Get the list of available environments and define the options.
$options
=
\Drupal
::
service
(
'nextjs_environment.repository'
)
->
getEnvironmentNamesAsOptions
();
$element
[
'#options'
]
=
$options
;
// Prefix the default description with information about
// Next.js environments, unless disabled.
if
(
$element
[
'#env_description'
])
{
$originalDescription
=
(
isset
(
$element
[
'#description'
]))
?
$element
[
'#description'
]
:
''
;
// @todo this causes escaping.
$envDescription
=
new
TranslatableMarkup
(
'Choose an available environment. If the desired environment is not listed, <a href=":link">create a new environment</a>.'
,
[
':link'
=>
Url
::
fromRoute
(
'entity.nextjs_environment.add_form'
)
->
toString
(),
]);
$element
[
'#description'
]
=
$envDescription
.
' '
.
$originalDescription
;
}
return
$element
;
}
}
Loading