Commit 15a50aae authored by Oluwafemi Sosami's avatar Oluwafemi Sosami Committed by Vaibhav Jain
Browse files

Issue #2875101 by saphemmy, tmaiochi, Munavijayalakshmi: Replaced deprecated functions

parent dcd0cedf
Loading
Loading
Loading
Loading
+31 −2
Original line number Diff line number Diff line
@@ -2,16 +2,45 @@

namespace Drupal\google_image_sitemap\Form;

use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
 * Provides a form to create new sitemap.
 */
class GoogleImageSitemapCreateForm extends FormBase {

  /**
   * Provides form to create a new sitemap time.
   * @property TimeInterface $time
   */

  /**
   * @var TimeInterface $time
   */
  protected $time;

  /**
   * @param TimeInterface $time
   */
  public function __construct(TimeInterface $time){
    $this->time = $time;
  }

  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container)
  {
    return new static(
      $container->get('datetime.time')
    );
  }

  /**
   * {@inheritdoc}
   */
@@ -79,11 +108,11 @@ class GoogleImageSitemapCreateForm extends FormBase {
    $sitemap_id = \Drupal::routeMatch()->getRawParameter('sitemap_id');
    // Set created key if new.
    if (empty($sitemap_id)) {
      $sitemap['created'] = \Drupal::time()->getRequestTime();
      $sitemap['created'] = $this->time->getRequestTime();
    }
    $sitemap['node_type'] = $sitemap_obj->node_type;
    $sitemap['license'] = $sitemap_obj->license;
    $sitemap['last_updated'] = \Drupal::time()->getRequestTime();
    $sitemap['last_updated'] = $this->time->getRequestTime();
    $sitemap_obj->sid = $form_state->getStorage();
    \Drupal::database()->merge('google_image_sitemap')->fields($sitemap)->condition('sid', $sitemap_id)->execute();
    // Redirect to main page of sitemap.