We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Brainstorming result:
class SystemSubscriber implements EventSubscriberInterface { /** * Handle a load language file event. * * @param LoadLanguageFileEvent $event The event. * * @return void */ public function handleLoadLanguageFile(LoadLanguageFileEvent $event) { $hash = $event->getSemaphoreHash(); if (LoadLanguageFileEvent::$cameFromHook[$hash] === false) { throw new \InvalidConditionException(); } if (LoadLanguageFileEvent::$cameFromHook[$hash] === null) { LoadLanguageFileEvent::$cameFromHook[$hash] = false; \System::loadLanguageFile( $event->getFileName(), $event->getLanguage(), $event->isCacheIgnored() ); unset(LoadLanguageFileEvent::$cameFromHook[$hash]); } } } class TristanSubscriber { public function handleLoadLanguageFile(LoadLanguageFileEvent $event) { // fire twice. } } $eventDispatcher->addSubscriber(new SystemSubscriber(), PHP_INT_MAX); class SystemHookHandler { public function loadLanguageFile($fileName, $language = null, $ignoreCache = false) { $hash = LoadLanguageFileEvent::generateSemaphoreHash($fileName, $language, $ignoreCache); if (LoadLanguageFileEvent::$cameFromHook[$hash] === true) { throw new \InvalidConditionException(); } if (LoadLanguageFileEvent::$cameFromHook[$hash]=== null) { LoadLanguageFileEvent::$cameFromHook[$hash] = true; $event->setCameFromHook(true); $eventDispatcher->dispatch($event); unset(LoadLanguageFileEvent::$cameFromHook[$hash]); } } } $GLOBALS['TL_HOOKS']['loadLanguageFile'][] = array('SystemHookHandler', 'loadLanguageFile'); class LoadLanguageFileEvent { protected $fileName; protected $cameFromHook; public function getSemaphoreHash() { return self::generateSemaphoreHash($this->get....(), ...); } public static generateSemaphoreHash($filename, ...) { return md5($filename . ...); } } Via plain call: 1. $this->loadLanguageFile(); 2. SystemHookHandler::loadLanguageFile(); => cameFromHook == true 3. dispatcher->dispatch() 4. SystemSubscriber::handleLoadLanguageFile(); == NO-OP 5. done Via event: 1. dispatcher->dispatch() => cameFromHook == false 2. SystemSubscriber::LoadLanguageFileEvent(); ==> call \System::loadLanguageFile(); 2.1. SystemHookHandler::loadLanguageFile(); => cameFromHook == true 2.2. dispatcher->dispatch() 2.3. SystemSubscriber::handleLoadLanguageFile(); == NO-OP 3. SystemSubscriber::LoadLanguageFileEvent(); -> stop event
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Brainstorming result:
The text was updated successfully, but these errors were encountered: