namespace Drupal\node\Form;
+use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\ConfirmFormBase;
* The node storage.
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
* The date formatter service.
+ * @param \Drupal\Component\Datetime\TimeInterface $time
+ * The time service.
*/
- public function __construct(EntityStorageInterface $node_storage, DateFormatterInterface $date_formatter) {
+ public function __construct(EntityStorageInterface $node_storage, DateFormatterInterface $date_formatter, TimeInterface $time) {
$this->nodeStorage = $node_storage;
$this->dateFormatter = $date_formatter;
- $this->time = \Drupal::service('datetime.time');
+ $this->time = $time;
}
/**
public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager')->getStorage('node'),
- $container->get('date.formatter')
+ $container->get('date.formatter'),
+ $container->get('datetime.time')
);
}