Loading config/install/node_read_time.settings.yml 0 → 100644 +3 −0 Original line number Diff line number Diff line reading_time: container: { } words_per_minute: '225' config/schema/node_read_time.schema.yml 0 → 100644 +7 −0 Original line number Diff line number Diff line node_read_time.settings: type: config_object label: 'Node read time settings' mapping: words_per_minute: type: integer label: 'Words per minute' node_read_time.links.menu.yml +1 −1 Original line number Diff line number Diff line reading_time.settings: title: 'Reading time' parent: system.admin_config parent: system.admin_config_system description: 'Manage the Read time field settings.' route_name: system.admin_config_reading_time src/Form/ReadingTimeConfigForm.php +8 −8 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ namespace Drupal\node_read_time\Form; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; Loading @@ -14,18 +14,18 @@ use Drupal\Core\Config\ConfigFactoryInterface; class ReadingTimeConfigForm extends ConfigFormBase { /** * The entity manager instance. * The entity type manager. * * @var \Drupal\Core\Entity\EntityManager * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityManager; protected $entityTypeManager; /** * Class constructor. */ public function __construct(ConfigFactoryInterface $config_factory, EntityManager $entityManager) { public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entityTypeManager) { parent::__construct($config_factory); $this->entityManager = $entityManager; $this->entityTypeManager = $entityTypeManager; } /** Loading @@ -34,7 +34,7 @@ class ReadingTimeConfigForm extends ConfigFormBase { public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), $container->get('entity.manager') $container->get('entity_type.manager') ); } Loading @@ -53,7 +53,7 @@ class ReadingTimeConfigForm extends ConfigFormBase { public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $config = $this->config('node_read_time.settings'); $contentTypes = $this->entityManager->getStorage('node_type')->loadMultiple(); $contentTypes = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); $words_per_minute = !empty($config->get('reading_time')['words_per_minute']) ? $config->get('reading_time')['words_per_minute'] : NULL; Loading Loading
config/install/node_read_time.settings.yml 0 → 100644 +3 −0 Original line number Diff line number Diff line reading_time: container: { } words_per_minute: '225'
config/schema/node_read_time.schema.yml 0 → 100644 +7 −0 Original line number Diff line number Diff line node_read_time.settings: type: config_object label: 'Node read time settings' mapping: words_per_minute: type: integer label: 'Words per minute'
node_read_time.links.menu.yml +1 −1 Original line number Diff line number Diff line reading_time.settings: title: 'Reading time' parent: system.admin_config parent: system.admin_config_system description: 'Manage the Read time field settings.' route_name: system.admin_config_reading_time
src/Form/ReadingTimeConfigForm.php +8 −8 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ namespace Drupal\node_read_time\Form; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Form\ConfigFormBase; use Drupal\Core\Form\FormStateInterface; use Symfony\Component\DependencyInjection\ContainerInterface; Loading @@ -14,18 +14,18 @@ use Drupal\Core\Config\ConfigFactoryInterface; class ReadingTimeConfigForm extends ConfigFormBase { /** * The entity manager instance. * The entity type manager. * * @var \Drupal\Core\Entity\EntityManager * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityManager; protected $entityTypeManager; /** * Class constructor. */ public function __construct(ConfigFactoryInterface $config_factory, EntityManager $entityManager) { public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entityTypeManager) { parent::__construct($config_factory); $this->entityManager = $entityManager; $this->entityTypeManager = $entityTypeManager; } /** Loading @@ -34,7 +34,7 @@ class ReadingTimeConfigForm extends ConfigFormBase { public static function create(ContainerInterface $container) { return new static( $container->get('config.factory'), $container->get('entity.manager') $container->get('entity_type.manager') ); } Loading @@ -53,7 +53,7 @@ class ReadingTimeConfigForm extends ConfigFormBase { public function buildForm(array $form, FormStateInterface $form_state) { $form = parent::buildForm($form, $form_state); $config = $this->config('node_read_time.settings'); $contentTypes = $this->entityManager->getStorage('node_type')->loadMultiple(); $contentTypes = $this->entityTypeManager->getStorage('node_type')->loadMultiple(); $words_per_minute = !empty($config->get('reading_time')['words_per_minute']) ? $config->get('reading_time')['words_per_minute'] : NULL; Loading