- Issue created by @trigdog
- Status changed to Needs review
over 1 year ago 10:59pm 25 May 2023 - last update
over 1 year ago Build Successful The last submitted patch, 2: dynamic-regcodes-event-dispatcher_3362786-2.diff, failed testing. View results β
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- last update
over 1 year ago Build Successful - last update
over 1 year ago Build Successful The last submitted patch, 6: dynamic-regcodes-event-dispatcher_3362786-6.diff, failed testing. View results β
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.The last submitted patch, 7: dynamic-regcodes-event-dispatcher_3362786-7.diff, failed testing. View results β
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.- Open on Drupal.org βCore: 9.5.5 + Environment: PHP 7.3 & MySQL 5.7last update
over 1 year ago Waiting for branch to pass - πΊπΈUnited States trigdog
Missed a couple. Hopefully this one is good.
- πΊπΈUnited States trigdog
Here is an example of how to use this on your site:
In a custom module create a services file (ex. - mymodule.services.yml) file and an event subscriber (ex. - src/Event/MyModuleRegcodeSubscriber):
services: mymodule.regcode_subscriber: class: Drupal\mymodule\Event\MyModuleRegcodeSubscriber tags: - { name: 'event_subscriber' }
<?php namespace Drupal\mymodule\Event; use Drupal\regcode\Event\RegcodeValidateEvent; use Symfony\Component\EventDispatcher\EventSubscriberInterface; class MyModuleRegcodeSubscriber implements EventSubscriberInterface { /** * {@inheritdoc} * * @return array * The event names to listen for, and the methods that should be executed. */ public static function getSubscribedEvents() { return [ RegcodeValidateEvent::REGCODE_VALIDATE => 'updateRegcode', ]; } /** * React to a regcode validate event. * * @param \Drupal\regcode\Event\RegcodeValidateEvent $event * Regcode validate event. */ public function updateRegcode(RegcodeValidateEvent $event) { $user_code = $event->getUserEnteredRegcode(); $db_code = $event->getRegcode(); // Only react if the code isn't in regcode db table. if (!$db_code) { // Check if code is valid. if ($this->checkRegcode($user_code)) { // Create code on the fly. $code = new \stdClass(); $code->code = $user_code; $event->setAndSaveAlteredRegcode($code); } } } /** * Validate the code. * * @return bool * TRUE or FALSE if the code is valid. * */ private function checkRegcode($code) { // Put custom validation code here. } }
- last update
over 1 year ago Build Successful The last submitted patch, 10: dynamic-regcodes-event-dispatcher_3362786-10.diff, failed testing. View results β
- Status changed to Needs work
about 2 months ago 5:50am 4 October 2024