Loading src/Form/ContentCloseForm.php +30 −2 Original line number Diff line number Diff line Loading @@ -5,12 +5,40 @@ namespace Drupal\content_close\Form; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\EntityTypeManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * ContentCloseForm close. */ class ContentCloseForm extends ConfigFormBase { /** * The entity type manager. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * Constructs a ContentCloseForm object. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. */ public function __construct(EntityTypeManagerInterface $entity_type_manager) { $this->entityTypeManager = $entity_type_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager') ); } /** * {@inheritdoc} */ Loading Loading @@ -38,7 +66,7 @@ class ContentCloseForm extends ConfigFormBase { '#open' => TRUE, ]; $node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple(); $node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); foreach ($node_types as $node_type) { $form['content_type_name'][$node_type->id()] = [ '#type' => 'datetime', Loading @@ -54,7 +82,7 @@ class ContentCloseForm extends ConfigFormBase { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple(); $node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); foreach ($node_types as $node_type) { $this->configFactory->getEditable('content_close.settings') ->set($node_type->id(), ($form_state->getValue($node_type->id())) ? $form_state->getValue($node_type->id())->getTimeStamp() : '') Loading Loading
src/Form/ContentCloseForm.php +30 −2 Original line number Diff line number Diff line Loading @@ -5,12 +5,40 @@ namespace Drupal\content_close\Form; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Datetime\DrupalDateTime; use Drupal\Core\Entity\EntityTypeManagerInterface; use Symfony\Component\DependencyInjection\ContainerInterface; /** * ContentCloseForm close. */ class ContentCloseForm extends ConfigFormBase { /** * The entity type manager. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * Constructs a ContentCloseForm object. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager. */ public function __construct(EntityTypeManagerInterface $entity_type_manager) { $this->entityTypeManager = $entity_type_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( $container->get('entity_type.manager') ); } /** * {@inheritdoc} */ Loading Loading @@ -38,7 +66,7 @@ class ContentCloseForm extends ConfigFormBase { '#open' => TRUE, ]; $node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple(); $node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); foreach ($node_types as $node_type) { $form['content_type_name'][$node_type->id()] = [ '#type' => 'datetime', Loading @@ -54,7 +82,7 @@ class ContentCloseForm extends ConfigFormBase { * {@inheritdoc} */ public function submitForm(array &$form, FormStateInterface $form_state) { $node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple(); $node_types = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); foreach ($node_types as $node_type) { $this->configFactory->getEditable('content_close.settings') ->set($node_type->id(), ($form_state->getValue($node_type->id())) ? $form_state->getValue($node_type->id())->getTimeStamp() : '') Loading