Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal_cms
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
drupal_cms
Merge requests
!488
Installer kit
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Installer kit
issue/drupal_cms-3502760:installer-kit
into
1.x
Overview
15
Commits
37
Pipelines
35
Changes
40
Merged
Adam G-H
requested to merge
issue/drupal_cms-3502760:installer-kit
into
1.x
2 months ago
Overview
9
Commits
37
Pipelines
35
Changes
40
Expand
0
0
Merge request reports
Compare
1.x
version 34
12e57927
2 months ago
version 33
12e57927
2 months ago
version 32
12e57927
2 months ago
version 31
12e57927
2 months ago
version 30
e1305b5f
2 months ago
version 29
5492b619
2 months ago
version 28
f69bd682
2 months ago
version 27
7d311f54
2 months ago
version 26
b194ef8d
2 months ago
version 25
808a709e
2 months ago
version 24
400932f2
2 months ago
version 23
5f362542
2 months ago
version 22
6355cf55
2 months ago
version 21
5fa5afe0
2 months ago
version 20
e8e966c7
2 months ago
version 19
3deb054b
2 months ago
version 18
f0c47311
2 months ago
version 17
bcf91c1a
2 months ago
version 16
4f49cc3f
2 months ago
version 15
b003a5f8
2 months ago
version 14
1598c446
2 months ago
version 13
d997d81d
2 months ago
version 12
87af3f76
2 months ago
version 11
cd7f8e99
2 months ago
version 10
61a61d80
2 months ago
version 9
a2554e84
2 months ago
version 8
bd35100f
2 months ago
version 7
8c2b760a
2 months ago
version 6
f59fa510
2 months ago
version 5
4aeac119
2 months ago
version 4
f1046bd1
2 months ago
version 3
6b9479f8
2 months ago
version 2
126e9fe4
2 months ago
version 1
704a4cc8
2 months ago
1.x (base)
and
latest version
latest version
12e57927
37 commits,
2 months ago
version 34
12e57927
37 commits,
2 months ago
version 33
12e57927
37 commits,
2 months ago
version 32
12e57927
37 commits,
2 months ago
version 31
12e57927
37 commits,
2 months ago
version 30
e1305b5f
35 commits,
2 months ago
version 29
5492b619
34 commits,
2 months ago
version 28
f69bd682
33 commits,
2 months ago
version 27
7d311f54
32 commits,
2 months ago
version 26
b194ef8d
31 commits,
2 months ago
version 25
808a709e
30 commits,
2 months ago
version 24
400932f2
30 commits,
2 months ago
version 23
5f362542
29 commits,
2 months ago
version 22
6355cf55
28 commits,
2 months ago
version 21
5fa5afe0
27 commits,
2 months ago
version 20
e8e966c7
27 commits,
2 months ago
version 19
3deb054b
26 commits,
2 months ago
version 18
f0c47311
25 commits,
2 months ago
version 17
bcf91c1a
24 commits,
2 months ago
version 16
4f49cc3f
23 commits,
2 months ago
version 15
b003a5f8
22 commits,
2 months ago
version 14
1598c446
22 commits,
2 months ago
version 13
d997d81d
21 commits,
2 months ago
version 12
87af3f76
20 commits,
2 months ago
version 11
cd7f8e99
19 commits,
2 months ago
version 10
61a61d80
18 commits,
2 months ago
version 9
a2554e84
17 commits,
2 months ago
version 8
bd35100f
16 commits,
2 months ago
version 7
8c2b760a
15 commits,
2 months ago
version 6
f59fa510
14 commits,
2 months ago
version 5
4aeac119
14 commits,
2 months ago
version 4
f1046bd1
14 commits,
2 months ago
version 3
6b9479f8
12 commits,
2 months ago
version 2
126e9fe4
11 commits,
2 months ago
version 1
704a4cc8
10 commits,
2 months ago
40 files
+
170
−
675
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
40
Search (e.g. *.vue) (Ctrl+P)
project_template/web/profiles/drupal_cms_installer/src/Form/RecipesForm.php deleted
100644 → 0
+
0
−
120
Options
<?php
namespace
Drupal\drupal_cms_installer\Form
;
use
Drupal\Core\Form\FormBase
;
use
Composer\InstalledVersions
;
use
Drupal\Component\Serialization\Yaml
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Render\Element\Checkboxes
;
/**
* Provides a form to choose the site template and optional add-on recipes.
*
* @todo Present this as a mini project browser once
* https://www.drupal.org/i/3450629 is fixed.
*/
final
class
RecipesForm
extends
FormBase
{
/**
* {@inheritdoc}
*/
public
function
getFormId
():
string
{
return
'drupal_cms_installer_recipes_form'
;
}
/**
* {@inheritdoc}
*/
public
function
buildForm
(
array
$form
,
FormStateInterface
$form_state
):
array
{
$form
[
'#title'
]
=
$this
->
t
(
'Get started'
);
$form
[
'help'
]
=
[
'#prefix'
=>
'<p class="cms-installer__subhead">'
,
'#markup'
=>
$this
->
t
(
'You can select pre-configured types of content now, or add them later.'
),
'#suffix'
=>
'</p>'
,
];
$form
[
'add_ons'
]
=
[
'#prefix'
=>
'<div class="cms-installer__form-group">'
,
'#suffix'
=>
'</div>'
,
'#type'
=>
'checkboxes'
,
'#value_callback'
=>
static
::
class
.
'::valueCallback'
,
];
$base_recipe_path
=
InstalledVersions
::
getInstallPath
(
'drupal/drupal_cms_starter'
);
$cookbook_path
=
dirname
(
$base_recipe_path
);
// Read the list of optional recipes from the base recipe's `composer.json`.
$composer
=
file_get_contents
(
$base_recipe_path
.
'/composer.json'
);
$composer
=
json_decode
(
$composer
,
TRUE
,
flags
:
JSON_THROW_ON_ERROR
);
$optional_recipes
=
array_keys
(
$composer
[
'suggest'
]
??
[]);
foreach
(
$optional_recipes
as
$name
)
{
$recipe
=
$cookbook_path
.
'/'
.
basename
(
$name
)
.
'/recipe.yml'
;
if
(
file_exists
(
$recipe
))
{
$recipe
=
file_get_contents
(
$recipe
);
$recipe
=
Yaml
::
decode
(
$recipe
);
$key
=
basename
(
$name
);
$form
[
'add_ons'
][
'#options'
][
$key
]
=
$recipe
[
'name'
];
}
}
$form
[
'add_ons'
][
'help'
]
=
[
'#prefix'
=>
'<p class="cms-installer__info">'
,
'#markup'
=>
$this
->
t
(
'Don’t see what you’re looking for? You can set up customized content later.'
),
'#suffix'
=>
'</p>'
,
'#weight'
=>
100
,
];
$form
[
'actions'
]
=
[
'submit'
=>
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Next'
),
'#button_type'
=>
'primary'
,
'#op'
=>
'submit'
,
'#attributes'
=>
[
'class'
=>
[
'button--next'
]
]
],
'skip'
=>
[
'#type'
=>
'submit'
,
'#value'
=>
$this
->
t
(
'Skip this step'
),
'#op'
=>
'skip'
,
],
'#type'
=>
'actions'
,
];
return
$form
;
}
/**
* {@inheritdoc}
*/
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
):
void
{
global
$install_state
;
$install_state
[
'parameters'
][
'recipes'
]
=
[
'drupal_cms_starter'
];
$pressed_button
=
$form_state
->
getTriggeringElement
();
// Only choose add-ons if the Next button was pressed, or if the form was
// submitted programmatically (i.e., by `drush site:install`).
if
((
$pressed_button
&&
$pressed_button
[
'#op'
]
===
'submit'
)
||
$form_state
->
isProgrammed
())
{
$add_ons
=
$form_state
->
getValue
(
'add_ons'
,
[]);
$add_ons
=
array_filter
(
$add_ons
);
array_push
(
$install_state
[
'parameters'
][
'recipes'
],
...
array_values
(
$add_ons
));
}
}
public
static
function
valueCallback
(
&
$element
,
$input
,
FormStateInterface
$form_state
)
:
array
{
// If the input was a comma-separated string or `*`, transform it -- this is
// for compatibility with `drush site:install`.
if
(
is_string
(
$input
))
{
$selections
=
$input
===
'*'
?
array_keys
(
$element
[
'#options'
])
:
array_map
(
'trim'
,
explode
(
','
,
$input
));
$input
=
array_combine
(
$selections
,
$selections
);
}
return
Checkboxes
::
valueCallback
(
$element
,
$input
,
$form_state
);
}
}
Loading