Loading invite.services.yml +1 −0 Original line number Diff line number Diff line services: reg_code: class: Drupal\invite\ParamConverter\InviteParamConverter arguments: ['@entity_type.manager'] tags: - { name: paramconverter } plugin.manager.invite: Loading modules/invite_link/src/Plugin/Block/InviteLinkBlock.php +29 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\invite_link\Plugin\Block; use Drupal\Core\Block\BlockBase; use Drupal\invite_link\Form\InviteLinkBlockForm; use Drupal\Core\Form\FormBuilderInterface; /** * Provides an 'InviteLinkBlock' block. Loading @@ -16,13 +17,40 @@ use Drupal\invite_link\Form\InviteLinkBlockForm; */ class InviteLinkBlock extends BlockBase { /** * The form builder. * * @var \Drupal\Core\Form\FormBuilderInterface */ protected $formBuilder; /** * Constructs a new Invite Link Block object. * * @param \Drupal\Core\Form\FormBuilderInterface $form_builder * The form builder. */ public function __construct(FormBuilderInterface $form_builder) { parent::__construct($entity_type, $storage); $this->formBuilder = $form_builder; } /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container) { return new static( $container->get('form_builder'), ); } /** * {@inheritdoc} */ public function build() { $block_id = $this->getDerivativeId(); $build = []; $form = \Drupal::formBuilder()->getForm(new InviteLinkBlockForm(), $block_id); $form = $this->formBuilder->getForm(new InviteLinkBlockForm(), $block_id); $build['form'] = $form; return $build; Loading src/Controller/InviteList.php +2 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ class InviteList extends ControllerBase { * * @param \Drupal\Core\Database\Connection $database * Connection database. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * Module handler interface. */ public function __construct(Connection $database, ModuleHandlerInterface $module_handler) { $this->database = $database; Loading src/Form/InviteTypeForm.php +13 −3 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Drupal\invite\Entity\InviteSender; use Drupal\invite\InvitePluginManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Config\ConfigFactoryInterface; /** * Form controller for Invite type edit forms. Loading Loading @@ -48,6 +49,13 @@ class InviteTypeForm extends EntityForm { */ protected $messenger; /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * {@inheritdoc} */ Loading @@ -56,18 +64,20 @@ class InviteTypeForm extends EntityForm { $container->get('plugin.manager.invite'), $container->get('plugin.manager.block'), $container->get('database'), $container->get('messenger') $container->get('messenger'), $container->get('config.factory') ); } /** * {@inheritdoc} */ public function __construct(InvitePluginManager $plugin_manager, BlockManager $block_plugin_manager, Connection $database, MessengerInterface $messenger) { public function __construct(InvitePluginManager $plugin_manager, BlockManager $block_plugin_manager, Connection $database, MessengerInterface $messenger, ConfigFactoryInterface $config_factory) { $this->pluginManager = $plugin_manager; $this->database = $database; $this->blockManager = $block_plugin_manager; $this->messenger = $messenger; $this->configFactory = $config_factory; } /** Loading @@ -75,7 +85,7 @@ class InviteTypeForm extends EntityForm { */ public function getDefaultSendMethods($invite_type) { $defaults = []; foreach (explode('||', \Drupal::config('invite.invite_sender.' . $invite_type->getType())->get('sending_methods')) as $sending_method) { foreach (explode('||', $this->configFactory('invite.invite_sender.' . $invite_type->getType())->get('sending_methods')) as $sending_method) { if ($sending_method != '0') { $defaults[$sending_method] = $sending_method; } Loading src/ParamConverter/InviteParamConverter.php +19 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\invite\ParamConverter; use Drupal\Core\ParamConverter\ParamConverterInterface; use Drupal\invite\Entity\Invite; use Symfony\Component\Routing\Route; use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Class InviteParamConverter. Loading @@ -13,6 +14,23 @@ use Symfony\Component\Routing\Route; */ class InviteParamConverter implements ParamConverterInterface { /** * The entity type manager service. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * Constructs an object. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager service. */ public function __construct(EntityTypeManagerInterface $entity_type_manager) { $this->entityTypeManager = $entity_type_manager; } /** * Applies function. */ Loading @@ -24,7 +42,7 @@ class InviteParamConverter implements ParamConverterInterface { * Converts reg_code to invite. */ public function convert($reg_code, $definition, $name, array $defaults) { $invite = \Drupal::entityQuery('invite') $invite = $this->entityTypeManager->getStorage('invite') ->condition('reg_code', $reg_code) ->execute(); return Invite::load(reset($invite)); Loading Loading
invite.services.yml +1 −0 Original line number Diff line number Diff line services: reg_code: class: Drupal\invite\ParamConverter\InviteParamConverter arguments: ['@entity_type.manager'] tags: - { name: paramconverter } plugin.manager.invite: Loading
modules/invite_link/src/Plugin/Block/InviteLinkBlock.php +29 −1 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ namespace Drupal\invite_link\Plugin\Block; use Drupal\Core\Block\BlockBase; use Drupal\invite_link\Form\InviteLinkBlockForm; use Drupal\Core\Form\FormBuilderInterface; /** * Provides an 'InviteLinkBlock' block. Loading @@ -16,13 +17,40 @@ use Drupal\invite_link\Form\InviteLinkBlockForm; */ class InviteLinkBlock extends BlockBase { /** * The form builder. * * @var \Drupal\Core\Form\FormBuilderInterface */ protected $formBuilder; /** * Constructs a new Invite Link Block object. * * @param \Drupal\Core\Form\FormBuilderInterface $form_builder * The form builder. */ public function __construct(FormBuilderInterface $form_builder) { parent::__construct($entity_type, $storage); $this->formBuilder = $form_builder; } /** * {@inheritdoc} */ public static function createInstance(ContainerInterface $container) { return new static( $container->get('form_builder'), ); } /** * {@inheritdoc} */ public function build() { $block_id = $this->getDerivativeId(); $build = []; $form = \Drupal::formBuilder()->getForm(new InviteLinkBlockForm(), $block_id); $form = $this->formBuilder->getForm(new InviteLinkBlockForm(), $block_id); $build['form'] = $form; return $build; Loading
src/Controller/InviteList.php +2 −0 Original line number Diff line number Diff line Loading @@ -40,6 +40,8 @@ class InviteList extends ControllerBase { * * @param \Drupal\Core\Database\Connection $database * Connection database. * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler * Module handler interface. */ public function __construct(Connection $database, ModuleHandlerInterface $module_handler) { $this->database = $database; Loading
src/Form/InviteTypeForm.php +13 −3 Original line number Diff line number Diff line Loading @@ -11,6 +11,7 @@ use Drupal\invite\Entity\InviteSender; use Drupal\invite\InvitePluginManager; use Symfony\Component\DependencyInjection\ContainerInterface; use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\Core\Config\ConfigFactoryInterface; /** * Form controller for Invite type edit forms. Loading Loading @@ -48,6 +49,13 @@ class InviteTypeForm extends EntityForm { */ protected $messenger; /** * The config factory. * * @var \Drupal\Core\Config\ConfigFactoryInterface */ protected $configFactory; /** * {@inheritdoc} */ Loading @@ -56,18 +64,20 @@ class InviteTypeForm extends EntityForm { $container->get('plugin.manager.invite'), $container->get('plugin.manager.block'), $container->get('database'), $container->get('messenger') $container->get('messenger'), $container->get('config.factory') ); } /** * {@inheritdoc} */ public function __construct(InvitePluginManager $plugin_manager, BlockManager $block_plugin_manager, Connection $database, MessengerInterface $messenger) { public function __construct(InvitePluginManager $plugin_manager, BlockManager $block_plugin_manager, Connection $database, MessengerInterface $messenger, ConfigFactoryInterface $config_factory) { $this->pluginManager = $plugin_manager; $this->database = $database; $this->blockManager = $block_plugin_manager; $this->messenger = $messenger; $this->configFactory = $config_factory; } /** Loading @@ -75,7 +85,7 @@ class InviteTypeForm extends EntityForm { */ public function getDefaultSendMethods($invite_type) { $defaults = []; foreach (explode('||', \Drupal::config('invite.invite_sender.' . $invite_type->getType())->get('sending_methods')) as $sending_method) { foreach (explode('||', $this->configFactory('invite.invite_sender.' . $invite_type->getType())->get('sending_methods')) as $sending_method) { if ($sending_method != '0') { $defaults[$sending_method] = $sending_method; } Loading
src/ParamConverter/InviteParamConverter.php +19 −1 Original line number Diff line number Diff line Loading @@ -5,6 +5,7 @@ namespace Drupal\invite\ParamConverter; use Drupal\Core\ParamConverter\ParamConverterInterface; use Drupal\invite\Entity\Invite; use Symfony\Component\Routing\Route; use Drupal\Core\Entity\EntityTypeManagerInterface; /** * Class InviteParamConverter. Loading @@ -13,6 +14,23 @@ use Symfony\Component\Routing\Route; */ class InviteParamConverter implements ParamConverterInterface { /** * The entity type manager service. * * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ protected $entityTypeManager; /** * Constructs an object. * * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity type manager service. */ public function __construct(EntityTypeManagerInterface $entity_type_manager) { $this->entityTypeManager = $entity_type_manager; } /** * Applies function. */ Loading @@ -24,7 +42,7 @@ class InviteParamConverter implements ParamConverterInterface { * Converts reg_code to invite. */ public function convert($reg_code, $definition, $name, array $defaults) { $invite = \Drupal::entityQuery('invite') $invite = $this->entityTypeManager->getStorage('invite') ->condition('reg_code', $reg_code) ->execute(); return Invite::load(reset($invite)); Loading