Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
metatag
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
metatag
Merge requests
!177
Issue
#3504986
by andresalvarez: Missing Coding Standard.
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Issue
#3504986
by andresalvarez: Missing Coding Standard.
issue/metatag-3504986:3504986-coding-standard
into
2.1.x
Overview
0
Commits
7
Pipelines
7
Changes
14
Merged
andres alvarez
requested to merge
issue/metatag-3504986:3504986-coding-standard
into
2.1.x
4 months ago
Overview
0
Commits
7
Pipelines
7
Changes
14
Expand
Closes
#3504986
0
0
Merge request reports
Compare
2.1.x
version 6
df14dde4
2 months ago
version 5
e48dcacb
2 months ago
version 4
c74d1c11
2 months ago
version 3
b4959052
3 months ago
version 2
14c5ac3b
3 months ago
version 1
2fb017b5
4 months ago
2.1.x (base)
and
latest version
latest version
83db925b
7 commits,
2 months ago
version 6
df14dde4
6 commits,
2 months ago
version 5
e48dcacb
5 commits,
2 months ago
version 4
c74d1c11
4 commits,
2 months ago
version 3
b4959052
3 commits,
3 months ago
version 2
14c5ac3b
2 commits,
3 months ago
version 1
2fb017b5
1 commit,
4 months ago
14 files
+
77
−
45
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
14
Search (e.g. *.vue) (Ctrl+P)
metatag_custom_tags/src/Form/MetaTagCustomTagForm.php
+
41
−
8
Options
@@ -3,24 +3,54 @@
namespace
Drupal\metatag_custom_tags\Form
;
use
Drupal\Core\Entity\EntityForm
;
use
Drupal\Core\Entity\EntityTypeManagerInterface
;
use
Drupal\Core\Form\FormStateInterface
;
use
Drupal\Core\Messenger\MessengerInterface
;
use
Drupal\Core\StringTranslation\TranslatableMarkup
;
use
Drupal\metatag\MetatagTagPluginManager
;
use
Drupal\metatag_custom_tags
\MetaTagCustomTagInterface
;
/**
* Form handler for the MetaTag Custom Tag entity type.
*
* @package Drupal\metatag_custom_tags\Form
*/
class
MetaTagCustomTagForm
extends
EntityForm
{
/**
* The metatag tag plugin manager.
*
* @var \Drupal\metatag\MetatagTagPluginManager
*/
protected
MetatagTagPluginManager
$metatagTagPluginManager
;
/**
* Constructs a new MetaTagCustomTagForm.
*/
public
function
__construct
(
MetatagTagPluginManager
$metatagTagPluginManager
,
MessengerInterface
$messenger
,
EntityTypeManagerInterface
$entityTypeManager
,
)
{
$this
->
metatagTagPluginManager
=
$metatagTagPluginManager
;
$this
->
messenger
=
$messenger
;
$this
->
entityTypeManager
=
$entityTypeManager
;
}
/**
* {@inheritdoc}
*/
public
function
form
(
array
$form
,
FormStateInterface
$form_state
):
array
{
public
static
function
create
(
$container
)
{
return
new
static
(
$container
->
get
(
'plugin.manager.metatag.tag'
),
$container
->
get
(
'messenger'
),
$container
->
get
(
'entity_type.manager'
)
);
}
/**
* {@inheritdoc}
*/
public
function
form
(
array
$form
,
FormStateInterface
$form_state
):
array
{
$form
=
parent
::
form
(
$form
,
$form_state
);
$entity
=
$this
->
entity
;
$form
[
'label'
]
=
[
@@ -98,13 +128,16 @@ class MetaTagCustomTagForm extends EntityForm {
public
function
save
(
array
$form
,
FormStateInterface
$form_state
):
int
{
$result
=
parent
::
save
(
$form
,
$form_state
);
$message_args
=
[
'%label'
=>
$this
->
entity
->
label
()];
$this
->
messenger
()
->
addStatus
(
match
(
$result
)
{
$this
->
messenger
->
addStatus
(
match
(
$result
)
{
\SAVED_NEW
=>
$this
->
t
(
'Created %label Custom tag.'
,
$message_args
),
\SAVED_UPDATED
=>
$this
->
t
(
'Updated %label Custom tag.'
,
$message_args
),
}
);
\Drupal
::
service
(
'plugin.manager.metatag.tag'
)
->
clearCachedDefinitions
();
// Clear cached definitions using injected service.
$this
->
metatagTagPluginManager
->
clearCachedDefinitions
();
$form_state
->
setRedirectUrl
(
$this
->
entity
->
toUrl
(
'collection'
));
return
$result
;
}
@@ -112,7 +145,7 @@ class MetaTagCustomTagForm extends EntityForm {
/**
* Helper function to check whether the configuration entity exists.
*/
public
function
exist
(
$id
)
{
public
function
exist
(
$id
)
:
bool
{
$entity
=
$this
->
entityTypeManager
->
getStorage
(
'metatag_custom_tag'
)
->
getQuery
()
->
accessCheck
(
FALSE
)
->
condition
(
'id'
,
$id
)
Loading