Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
druplan
Manage
Activity
Members
Labels
Code
Merge requests
3
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
planning
druplan
Merge requests
!130
imp: I-8127 project_id on rp_event_template
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
imp: I-8127 project_id on rp_event_template
imp-I-8127-project_id-on-rp_event_template
into
1.x
Overview
0
Commits
2
Pipelines
3
Changes
2
Merged
simon
requested to merge
imp-I-8127-project_id-on-rp_event_template
into
1.x
9 months ago
Overview
0
Commits
2
Pipelines
3
Changes
2
Expand
0
0
Merge request reports
Compare
1.x
version 2
a009e3da
9 months ago
version 1
1d82c77d
9 months ago
1.x (base)
and
latest version
latest version
53d94a1a
2 commits,
9 months ago
version 2
a009e3da
1 commit,
9 months ago
version 1
1d82c77d
1 commit,
9 months ago
2 files
+
66
−
0
Expand all files
Preferences
File browser
List view
Tree view
Compare changes
Inline
Side-by-side
Show whitespace changes
Show one file at a time
Search (e.g. *.vue) (Ctrl+P)
druplan.install
+
40
−
0
Options
@@ -6,6 +6,8 @@
*/
use
Drupal\resource_planning
\Entity\Calendar
;
use
Drupal\Core\Field\BaseFieldDefinition
;
use
Drupal\Core\Field\FieldStorageDefinitionInterface
;
/**
* Implements hook_install().
@@ -22,3 +24,41 @@ function druplan_install() {
}
}
/**
* Add project_id field to rp_event_template.
*/
function
druplan_update_8001
(
&
$sandbox
)
{
if
(
!
array_key_exists
(
'project_id'
,
\Drupal
::
service
(
'entity.last_installed_schema.repository'
)
->
getLastInstalledFieldStorageDefinitions
(
'rp_event_template'
)))
{
$storage_definition
=
BaseFieldDefinition
::
create
(
'entity_reference'
)
->
setLabel
(
t
(
'Project'
))
->
setSettings
([
'target_type'
=>
'node'
,
])
// ->setRequired(TRUE)
->
setDisplayOptions
(
'view'
,
[
'label'
=>
'above'
,
'type'
=>
'entity_reference_label'
,
'weight'
=>
0
,
])
->
setDisplayConfigurable
(
'view'
,
TRUE
)
->
setDisplayOptions
(
'form'
,
[
'type'
=>
'entity_reference_autocomplete'
,
'weight'
=>
5
,
'settings'
=>
[
'match_operator'
=>
'CONTAINS'
,
'size'
=>
'60'
,
'autocomplete_type'
=>
'tags'
,
'placeholder'
=>
''
,
],
])
->
setDisplayConfigurable
(
'form'
,
TRUE
);
\Drupal
::
entityDefinitionUpdateManager
()
->
installFieldStorageDefinition
(
'project_id'
,
'rp_event_template'
,
'rp_event_template'
,
$storage_definition
);
}
}