Skip to content
Snippets Groups Projects

Resolve #3420357 "Create drupal 10"

1 file
+ 73
19
Compare changes
  • Side-by-side
  • Inline
@@ -72,7 +72,8 @@ class MetatagsQuickAdminSettingsForm extends ConfigFormBase {
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = $this->config('metatags_quick.settings');
$known_tags = \Drupal::service('metatags_quick.known_tags')->getKnownTags();
$fields = \Drupal::service('entity_field.manager')->getFieldMap();
$known_tags = $this->getKnownTags();
$module_path = \Drupal::service('extension.list.module')->getPath('metatags_quick');
// Build the form elements.
@@ -83,6 +84,7 @@ class MetatagsQuickAdminSettingsForm extends ConfigFormBase {
'#collapsed' => TRUE,
];
$metatags_found = FALSE;
foreach ($fields as $key => $field) {
if ($field->module != 'metatags_quick') {
continue;
@@ -139,12 +141,9 @@ class MetatagsQuickAdminSettingsForm extends ConfigFormBase {
foreach ($known_tags as $name => $tag) {
$header[$name] = $tag['title'];
}
$bundles = $this->entityTypeBundleInfo->getBundleInfo();
$bundles = $this->entityTypeBundleInfo->getAllBundleInfo();
foreach ($bundles as $entity_type => $bundles) {
$entity_type_info = $this->entityTypeBundleInfo->getDefinition($entity_type);
if (!$entity_info->isFieldable()) {
continue;
}
$entity_type_info =\Drupal::entityTypeManager()->getDefinition($entity_type);
$form['bundles'][$entity_type] = [
'#type' => 'details',
'#title' => new TranslatableMarkup('@label settings', ['@label' => $entity_type_info->getLabel()]),
@@ -170,16 +169,12 @@ class MetatagsQuickAdminSettingsForm extends ConfigFormBase {
}
// How do we mark that specific meta is already attached to bundle.
$checked_markup = [
'#markup' => theme(
'image',
[
'uri' => 'core/misc/watchdog-ok.png',
'width' => 18,
'height' => 18,
'alt' => 'ok',
'title' => 'ok',
]
),
'#theme' => 'image',
'#uri' => 'core/misc/watchdog-ok.png',
'#width' => 18,
'#height' => 18,
'#alt' => 'ok',
'#title' => 'ok',
];
foreach ($bundles as $key => $bundle) {
@@ -238,15 +233,15 @@ class MetatagsQuickAdminSettingsForm extends ConfigFormBase {
'#theme' => 'table',
'#header' => $header,
'#rows' => $options,
'#empty' => t('No content available.'),
'#empty' => $this->t('No content available.'),
];
$form['standard_tags']['basic_init_op'] = [
'#type' => 'submit',
'#value' => t('Attach'),
'#value' => $this->t('Attach'),
];
$form['op'] = [
'#value' => t('Submit'),
'#value' => $this->t('Submit'),
'#type' => 'submit',
];
return parent::buildForm($form, $form_state);
@@ -286,4 +281,63 @@ class MetatagsQuickAdminSettingsForm extends ConfigFormBase {
}
}
/**
*
*/
public function getKnownTags() {
return [
'abstract' => [
'type' => 'meta_contents',
'widget' => 'metatags_quick_textfield',
'title' => $this->t('Abstract'),
'description' => $this->t('Enter a short abstract. Typically it is one sentence.'),
],
'canonical' => [
'type' => 'head_link',
'widget' => 'metatags_quick_textfield',
'formatter' => 'metatags_quick_link',
'title' => $this->t('Canonical URL'),
'description' => $this->t('Canonical URLs are used from the search engines, and allow them to not report duplicate titles for HTML pages that are accessible from different URLs. Use an absolute path for your URL; canonical URLs that point to a different domain are normally not accepted.'),
],
'copyright' => [
'type' => 'meta_contents',
'widget' => 'metatags_quick_textfield',
'title' => $this->t('Copyright'),
'description' => $this->t('Enter a short copyright statement.'),
],
'description' => [
'type' => 'meta_contents',
'widget' => 'metatags_quick_textarea',
'title' => $this->t('Description'),
'description' => $this->t('Enter a description. Limit your description to about 20 words, with a maximum of 255 characters. It should not contain any HTML tags or other formatting.'),
],
'keywords' => [
'type' => 'meta_contents',
'widget' => 'metatags_quick_textfield',
'title' => $this->t('Keywords'),
'description' => $this->t('Enter a short abstract. Typically it is one sentence.'),
],
'revisit_after' => [
'meta_name' => 'revisit-after',
'type' => 'meta_contents',
'widget' => 'metatags_quick_textfield',
'title' => $this->t('Revisit after'),
'description' => $this->t('day(s)'),
],
'robots' => [
'type' => 'meta_contents',
'widget' => 'metatags_quick_checkboxes',
'title' => $this->t('Robots'),
'options' => 'noarchive,nofollow,noindex,noodp,nosnippet,noydir',
],
'meta_title' => [
'meta_name' => 'title',
'type' => 'meta_contents',
'widget' => 'metatags_quick_textfield',
'title' => $this->t('Title'),
'description' => $this->t('Custom title.'),
],
];
}
}
Loading