Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / modules / contrib / metatag / metatag_views / src / Form / MetatagViewsEditForm.php
index 4398c235a5dc83d702d023b7aeca649477a13a26..96e970b9bfd0e180a9bcdf5ef0fb73338fe0e799 100644 (file)
@@ -7,7 +7,6 @@ use Drupal\Core\Form\FormBase;
 use Drupal\Core\Form\FormStateInterface;
 use Drupal\metatag\MetatagManagerInterface;
 use Drupal\metatag_views\MetatagViewsValuesCleanerTrait;
-use Drupal\views\ViewEntityInterface;
 use Symfony\Component\DependencyInjection\ContainerInterface;
 
 /**
@@ -32,24 +31,30 @@ class MetatagViewsEditForm extends FormBase {
   protected $viewsManager;
 
   /**
-   * Array of display settings as returned from getDisplay of ViewEntityInterface
+   * Array of display settings from ViewEntityInterface::getDisplay().
    *
-   * @var  array
+   * @var array
    */
   protected $display;
 
   /**
-   * View entity object
+   * View entity object.
    *
-   * @var  ViewEntityInterface
+   * @var \Drupal\views\ViewEntityInterface
    */
   protected $view;
 
+  /**
+   * {@inheritdoc}
+   */
   public function __construct(MetatagManagerInterface $metatag_manager, EntityTypeManagerInterface $entity_manager) {
     $this->metatagManager = $metatag_manager;
     $this->viewsManager = $entity_manager->getStorage('view');
   }
 
+  /**
+   * {@inheritdoc}
+   */
   public static function create(ContainerInterface $container) {
     return new static(
       $container->get('metatag.manager'),
@@ -72,7 +77,7 @@ class MetatagViewsEditForm extends FormBase {
     $view_id = \Drupal::request()->get('view_id');
     $display_id = \Drupal::request()->get('display_id');
 
-    // Get metatags from the view entity.
+    // Get meta tags from the view entity.
     $metatags = [];
     if ($view_id && $display_id) {
       $metatags = metatag_get_view_tags($view_id, $display_id);
@@ -82,8 +87,8 @@ class MetatagViewsEditForm extends FormBase {
     $form['metatags']['#title'] = t('Metatags');
     $form['metatags']['#type'] = 'fieldset';
 
-    // Need to create that AFTER the $form['metatags'] as the whole form
-    // is passed to the $metatagManager->form() which causes duplicated field.
+    // Need to create that AFTER the $form['metatags'] as the whole form is
+    // passed to the $metatagManager->form() which causes duplicated field.
     $form['view'] = [
       '#type' => 'value',
       '#title' => $this->t('View'),
@@ -92,10 +97,10 @@ class MetatagViewsEditForm extends FormBase {
       '#required' => TRUE,
     ];
 
-    $form['submit'] = array(
+    $form['actions']['submit'] = [
       '#type' => 'submit',
       '#value' => t('Submit'),
-    );
+    ];
 
     return $form;
   }
@@ -104,7 +109,6 @@ class MetatagViewsEditForm extends FormBase {
    * {@inheritdoc}
    */
   public function form(array $values, array $element, array $token_types = [], array $included_groups = NULL, array $included_tags = NULL) {
-
     // Add the outer fieldset.
     $element += [
       '#type' => 'details',
@@ -158,15 +162,15 @@ class MetatagViewsEditForm extends FormBase {
     unset($metatags['view']);
     $metatags = $this->clearMetatagViewsDisallowedValues($metatags);
 
-    /** @var ViewEntityInterface $view */
+    /** @var \Drupal\views\ViewEntityInterface $view */
     $view = $this->viewsManager->load($view_id);
 
-    // Store the metatags on the view.
+    // Store the meta tags on the view.
     $config_name = $view->getConfigDependencyName();
     $config_path = 'display.' . $display_id . '.display_options.display_extenders.metatag_display_extender.metatags';
 
-    // Set configuration values based on form submission.
-    // This always edits the original language.
+    // Set configuration values based on form submission. This always edits the
+    // original language.
     $configuration = $this->configFactory()->getEditable($config_name);
     if (empty($this->removeEmptyTags($metatags))) {
       $configuration->clear($config_path);