diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 8509154..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/cac_base/.DS_Store b/cac_base/.DS_Store deleted file mode 100644 index 5ca54c6..0000000 Binary files a/cac_base/.DS_Store and /dev/null differ diff --git a/cac_base/cac_base.routing.yml b/cac_base/cac_base.routing.yml index 9ad47d1..5330b6d 100644 --- a/cac_base/cac_base.routing.yml +++ b/cac_base/cac_base.routing.yml @@ -4,3 +4,11 @@ config_cac_base.description: _controller: '\Drupal\cac_base\Controller\NodeTypeCompanyRegistration::description' requirements: _permission: 'access content' + +cac_base.anony_login_prompt_dispatcher_form: + path: 'anony-login-prompt-dispatch-form' + defaults: + _form: '\Drupal\cac_base\Form\AnonyLoginPromptDispatchForm' + _title: 'AnonyLoginPrompt Dispatcher Form' + requirements: + _permission: 'access content' diff --git a/cac_base/src/AnonyLoginPrompt.php b/cac_base/src/AnonyLoginPrompt.php new file mode 100644 index 0000000..e731518 --- /dev/null +++ b/cac_base/src/AnonyLoginPrompt.php @@ -0,0 +1,24 @@ +referenceID = $referenceID; + } + + public function getReferenceID() { + return $this->referenceID; + } + + public function myEventDescription() { + return "AnonyLoginPrompt event"; + } +} \ No newline at end of file diff --git a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php index 304e0ea..ed254de 100644 --- a/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php +++ b/cac_base/src/EventSubscriber/AnonyLoginPromptSubscriber.php @@ -20,7 +20,9 @@ class AnonyLoginPromptSubscriber implements EventSubscriberInterface { public function anonymousLoginPrompt(FilterResponseEvent $event) { $request = $event->getRequest(); $redirect_url = $request->server->get('REQUEST_URI', null); - drupal_set_message(t('fffffffffff'), 'warning'); + if (\Drupal::currentUser()->isAnonymous()) { + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'warning'); + } } /** diff --git a/cac_base/src/Form/AnonyLoginPromptDispatchForm.php b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php new file mode 100644 index 0000000..353b5e2 --- /dev/null +++ b/cac_base/src/Form/AnonyLoginPromptDispatchForm.php @@ -0,0 +1,49 @@ + 'url', + '#title' => $this->t('Reference'), + '#maxlength' => 64, + '#size' => 64, + ); + $form['dispatch'] = array( + '#type' => 'submit', + '#value' => $this->t('Dispatch'), + ); + return $form; + } + /** + * {@inheritdoc} + */ + public function submitForm(array &$form, FormStateInterface $form_state) { + // Dispatching the event + $dispatcher = \Drupal::service('event_dispatcher'); + $event = new AnonyLoginPrompt($form_state->getValue('name')); + $dispatcher->dispatch(AnonyLoginPrompt::SUBMIT, $event); + + drupal_set_message(t('Please Login or Register to access all the services we offer.'), 'warning'); + } +} \ No newline at end of file