本文整理汇总了PHP中TYPO3\CMS\Extbase\SignalSlot\Dispatcher类的典型用法代码示例。如果您正苦于以下问题:PHP Dispatcher类的具体用法?PHP Dispatcher怎么用?PHP Dispatcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Dispatcher类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertPageIncache
/**
* Check if the SFC should create the cache
*
* @param TypoScriptFrontendController $pObj : The parent object
* @param string $timeOutTime : The timestamp when the page times out
*
* @return void
*/
public function insertPageIncache(TypoScriptFrontendController &$pObj, &$timeOutTime)
{
$isStaticCached = false;
$uri = $this->getUri();
// Signal: Initialize variables before starting the processing.
$preProcessArguments = ['frontendController' => $pObj, 'uri' => $uri];
$preProcessArguments = $this->signalDispatcher->dispatch(__CLASS__, 'preProcess', $preProcessArguments);
$uri = $preProcessArguments['uri'];
// cache rules
$ruleArguments = ['frontendController' => $pObj, 'uri' => $uri, 'explanation' => [], 'skipProcessing' => false];
$ruleArguments = $this->signalDispatcher->dispatch(__CLASS__, 'cacheRule', $ruleArguments);
$explanation = $ruleArguments['explanation'];
if (!$ruleArguments['skipProcessing']) {
// Don't continue if there is already an existing valid cache entry and we've got an invalid now.
// Prevents overriding if a logged in user is checking the page in a second call
// see https://forge.typo3.org/issues/67526
if (count($explanation) && $this->hasValidCacheEntry($uri)) {
return;
}
// The page tag pageId_NN is included in $pObj->pageCacheTags
$cacheTags = ObjectAccess::getProperty($pObj, 'pageCacheTags', true);
$cacheTags[] = 'sfc_pageId_' . $pObj->page['uid'];
$cacheTags[] = 'sfc_domain_' . str_replace('.', '_', parse_url($uri, PHP_URL_HOST));
// This is supposed to have "&& !$pObj->beUserLogin" in there as well
// This fsck's up the ctrl-shift-reload hack, so I pulled it out.
if (sizeof($explanation) === 0) {
// If page has a endtime before the current timeOutTime, use it instead:
if ($pObj->page['endtime'] > 0 && $pObj->page['endtime'] < $timeOutTime) {
$timeOutTime = $pObj->page['endtime'];
}
$timeOutSeconds = $timeOutTime - $GLOBALS['EXEC_TIME'];
$content = $pObj->content;
if ($this->configuration->get('showGenerationSignature')) {
$content .= "\n<!-- cached statically on: " . strftime($this->configuration->get('strftime'), $GLOBALS['EXEC_TIME']) . ' -->';
$content .= "\n<!-- expires on: " . strftime($this->configuration->get('strftime'), $timeOutTime) . ' -->';
}
// Signal: Process content before writing to static cached file
$processContentArguments = ['frontendController' => $pObj, 'uri' => $uri, 'content' => $content, 'timeOutSeconds' => $timeOutSeconds];
$processContentArguments = $this->signalDispatcher->dispatch(__CLASS__, 'processContent', $processContentArguments);
$content = $processContentArguments['content'];
$timeOutSeconds = $processContentArguments['timeOutSeconds'];
$uri = $processContentArguments['uri'];
$isStaticCached = true;
} else {
$cacheTags[] = 'explanation';
$content = $explanation;
$timeOutSeconds = 0;
}
// create cache entry
$this->cache->set($uri, $content, $cacheTags, $timeOutSeconds);
}
// Signal: Post process (no matter whether content was cached statically)
$postProcessArguments = ['frontendController' => $pObj, 'uri' => $uri, 'isStaticCached' => $isStaticCached];
$this->signalDispatcher->dispatch(__CLASS__, 'postProcess', $postProcessArguments);
}
示例2: setReceiverEmails
/**
* Set receiver mails
*
* @return void
*/
public function setReceiverEmails()
{
// get mails from FlexForm
$emailArray = $this->getEmailsFromFlexForm();
// get mails from fe_group
if ((int) $this->settings['receiver']['type'] === 1 && !empty($this->settings['receiver']['fe_group'])) {
$emailArray = $this->getEmailsFromFeGroup($this->settings['receiver']['fe_group']);
}
// get mails from predefined emailconfiguration
if ((int) $this->settings['receiver']['type'] === 2 && !empty($this->settings['receiver']['predefinedemail'])) {
$emailArray = $this->getEmailsFromPredefinedEmail($this->settings['receiver']['predefinedemail']);
}
// get mails from overwrite typoscript settings
$overwriteReceivers = $this->overWriteEmailsWithTypoScript();
if (!empty($overwriteReceivers)) {
$emailArray = $overwriteReceivers;
}
// get mail from development context
if (ConfigurationUtility::getDevelopmentContextEmail()) {
$emailArray = [ConfigurationUtility::getDevelopmentContextEmail()];
}
// overwrite with a signal if needed
$this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__, [&$emailArray, $this]);
$this->receiverEmails = $emailArray;
}
示例3: createEmailBody
/**
* Create Email Body
*
* @param array $email Array with all needed mail information
* @param \In2code\Powermail\Domain\Model\Mail $mail
* @param array $settings TypoScript Settings
* @return bool
*/
protected function createEmailBody($email, \In2code\Powermail\Domain\Model\Mail &$mail, $settings)
{
$emailBodyObject = $this->objectManager->get('\\TYPO3\\CMS\\Fluid\\View\\StandaloneView');
$emailBodyObject->getRequest()->setControllerExtensionName('Powermail');
$emailBodyObject->getRequest()->setPluginName('Pi1');
$emailBodyObject->getRequest()->setControllerName('Form');
$emailBodyObject->setFormat('html');
$templatePathAndFilename = $this->div->getTemplatePath() . $email['template'] . '.html';
$emailBodyObject->setTemplatePathAndFilename($templatePathAndFilename);
$emailBodyObject->setLayoutRootPath($this->div->getTemplatePath('layout'));
$emailBodyObject->setPartialRootPath($this->div->getTemplatePath('partial'));
// get variables
// additional variables
if (isset($email['variables']) && is_array($email['variables'])) {
$emailBodyObject->assignMultiple($email['variables']);
}
// markers in HTML Template
$variablesWithMarkers = $this->div->getVariablesWithMarkers($mail);
$emailBodyObject->assign('variablesWithMarkers', $this->div->htmlspecialcharsOnArray($variablesWithMarkers));
$emailBodyObject->assignMultiple($variablesWithMarkers);
$emailBodyObject->assignMultiple($this->div->getLabelsAttachedToMarkers($mail));
$emailBodyObject->assign('powermail_all', $this->div->powermailAll($mail, 'mail', $settings));
// from rte
$emailBodyObject->assign('powermail_rte', $email['rteBody']);
$emailBodyObject->assign('marketingInfos', Div::getMarketingInfos());
$emailBodyObject->assign('mail', $mail);
$this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforeRender', array($emailBodyObject, $email, $mail, $settings));
$body = $emailBodyObject->render();
$mail->setBody($body);
return $body;
}
示例4: dispatchThrowsInvalidSlotExceptionIfObjectManagerOfSignalSlotDispatcherIsNotSet
/**
* @test
* @expectedException \TYPO3\CMS\Extbase\SignalSlot\Exception\InvalidSlotException
*/
public function dispatchThrowsInvalidSlotExceptionIfObjectManagerOfSignalSlotDispatcherIsNotSet()
{
$this->signalSlotDispatcher->_set('isInitialized', true);
$this->signalSlotDispatcher->_set('objectManager', null);
$this->signalSlotDispatcher->_set('slots', array('ClassA' => array('emitSomeSignal' => array(array()))));
$this->assertSame(null, $this->signalSlotDispatcher->dispatch('ClassA', 'emitSomeSignal'));
}
示例5: finalCreate
/**
* Some additional actions after profile creation
*
* @param User $user
* @param string $action
* @param string $redirectByActionName Action to redirect
* @param bool $login Login after creation
* @param string $status
* @return void
*/
public function finalCreate($user, $action, $redirectByActionName, $login = TRUE, $status = '')
{
// persist user (otherwise login is not possible if user is still disabled)
$this->userRepository->update($user);
$this->persistenceManager->persistAll();
// login user
if ($login) {
$this->loginAfterCreate($user);
}
// send notify email to user
$this->sendMail->send('createUserNotify', Div::makeEmailArray($user->getEmail(), $user->getFirstName() . ' ' . $user->getLastName()), array($this->settings['new']['email']['createUserNotify']['sender']['email']['value'] => $this->settings['settings']['new']['email']['createUserNotify']['sender']['name']['value']), 'Profile creation', array('user' => $user, 'settings' => $this->settings), $this->config['new.']['email.']['createUserNotify.']);
// send notify email to admin
if ($this->settings['new']['notifyAdmin']) {
$this->sendMail->send('createNotify', Div::makeEmailArray($this->settings['new']['notifyAdmin'], $this->settings['new']['email']['createAdminNotify']['receiver']['name']['value']), Div::makeEmailArray($user->getEmail(), $user->getUsername()), 'Profile creation', array('user' => $user, 'settings' => $this->settings), $this->config['new.']['email.']['createAdminNotify.']);
}
// sendpost: send values via POST to any target
Div::sendPost($user, $this->config, $this->cObj);
// store in database: store values in any wanted table
Div::storeInDatabasePreflight($user, $this->config, $this->cObj, $this->objectManager);
// add signal after user generation
$this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'AfterPersist', array($user, $action, $this));
// frontend redirect (if activated via TypoScript)
$this->redirectByAction($action, $status ? $status . 'Redirect' : 'redirect');
// go to an action
$this->redirect($redirectByActionName);
}
示例6: initializeAction
/**
* Initialize all actions
*
* @see \TYPO3\CMS\Extbase\Mvc\Controller\ActionController::initializeAction()
* @return void
*/
protected function initializeAction()
{
$this->fileService = $this->objectManager->get(\Evoweb\SfRegister\Services\File::class);
if ($this->settings['processInitializeActionSignal']) {
$this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__, array('controller' => $this, 'settings' => $this->settings));
}
if ($this->request->getControllerActionName() != 'removeImage' && $this->request->hasArgument('removeImage') && $this->request->getArgument('removeImage')) {
$this->forward('removeImage');
}
}
示例7: createItemMetaForFile
/**
* Create meta data object for given fileName
*
* @param string $fileName Path to file
* @return Tx_Yag_Domain_Model_ItemMeta Meta Data object for file
*/
public function createItemMetaForFile($fileName)
{
$itemMeta = new Tx_Yag_Domain_Model_ItemMeta();
$this->setDefaults($itemMeta);
$this->processCoreData($fileName, $itemMeta);
$this->processExifData($fileName, $itemMeta);
$this->processIPTCData($fileName, $itemMeta);
$this->processXMPData($fileName, $itemMeta);
$this->signalSlotDispatcher->dispatch(__CLASS__, 'processMetaData', array('metaData' => &$itemMeta, 'fileName' => $fileName));
return $itemMeta;
}
示例8: authUser
/**
* Authenticate user
* @param $user array record
* @return int One of these values: 100 = Pass, 0 = Failed, 200 = Success
*/
public function authUser(&$user)
{
if (!$user['fromHybrid']) {
return self::STATUS_AUTHENTICATION_FAILURE_CONTINUE;
}
$result = self::STATUS_AUTHENTICATION_FAILURE_CONTINUE;
if ($user) {
$result = self::STATUS_AUTHENTICATION_SUCCESS_BREAK;
}
//signal slot authUser
$this->signalSlotDispatcher->dispatch(__CLASS__, 'authUser', array($user, &$result, $this));
return $result;
}
示例9: handleIncomingValues
/**
* Handles the incoming form data
*
* @param Element $element
* @param array $userConfiguredElementTypoScript
* @return array
*/
protected function handleIncomingValues(Element $element, array $userConfiguredElementTypoScript)
{
if (!$this->getIncomingData()) {
return;
}
$elementName = $element->getName();
if ($element->getHtmlAttribute('value') !== null) {
$modelValue = $element->getHtmlAttribute('value');
} else {
$modelValue = $element->getAdditionalArgument('value');
}
if ($this->getIncomingData()->getIncomingField($elementName) !== null) {
/* filter values and set it back to incoming fields */
/* remove xss every time */
$userConfiguredElementTypoScript['filters.'][-1] = 'removexss';
$keys = TemplateService::sortedKeyList($userConfiguredElementTypoScript['filters.']);
foreach ($keys as $key) {
$class = $userConfiguredElementTypoScript['filters.'][$key];
if ((int) $key && strpos($key, '.') === false) {
$filterArguments = $userConfiguredElementTypoScript['filters.'][$key . '.'];
$filterClassName = $this->typoScriptRepository->getRegisteredClassName((string) $class, 'registeredFilters');
if ($filterClassName !== null) {
// toDo: handel array values
if (is_string($this->getIncomingData()->getIncomingField($elementName))) {
if (is_null($filterArguments)) {
$filter = $this->objectManager->get($filterClassName);
} else {
$filter = $this->objectManager->get($filterClassName, $filterArguments);
}
if ($filter) {
$value = $filter->filter($this->getIncomingData()->getIncomingField($elementName));
$this->getIncomingData()->setIncomingField($elementName, $value);
} else {
throw new \RuntimeException('Class "' . $filterClassName . '" could not be loaded.');
}
}
} else {
throw new \RuntimeException('Class "' . $filterClassName . '" not registered via TypoScript.');
}
}
}
if ($element->getHtmlAttribute('value') !== null) {
$element->setHtmlAttribute('value', $this->getIncomingData()->getIncomingField($elementName));
} else {
$element->setAdditionalArgument('value', $this->getIncomingData()->getIncomingField($elementName));
}
}
$this->signalSlotDispatcher->dispatch(__CLASS__, 'txFormHandleIncomingValues', array($element, $this->getIncomingData(), $modelValue, $this));
}
示例10: indexAction
/**
* Displays teasers
*
* @return void
*/
public function indexAction()
{
$this->currentPageUid = $GLOBALS['TSFE']->id;
$this->performTemplatePathAndFilename();
$this->setOrderingAndLimitation();
$this->performPluginConfigurations();
switch ($this->settings['source']) {
default:
case 'thisChildren':
$rootPageUids = $this->currentPageUid;
$pages = $this->pageRepository->findByPid($this->currentPageUid);
break;
case 'thisChildrenRecursively':
$rootPageUids = $this->currentPageUid;
$pages = $this->pageRepository->findByPidRecursively($this->currentPageUid, (int) $this->settings['recursionDepthFrom'], (int) $this->settings['recursionDepth']);
break;
case 'custom':
$rootPageUids = $this->settings['customPages'];
$pages = $this->pageRepository->findByPidList($this->settings['customPages'], $this->settings['orderByPlugin']);
break;
case 'customChildren':
$rootPageUids = $this->settings['customPages'];
$pages = $this->pageRepository->findChildrenByPidList($this->settings['customPages']);
break;
case 'customChildrenRecursively':
$rootPageUids = $this->settings['customPages'];
$pages = $this->pageRepository->findChildrenRecursivelyByPidList($this->settings['customPages'], (int) $this->settings['recursionDepthFrom'], (int) $this->settings['recursionDepth']);
break;
}
if ($this->settings['pageMode'] !== 'nested') {
$pages = $this->performSpecialOrderings($pages);
}
/** @var $page \PwTeaserTeam\PwTeaser\Domain\Model\Page */
foreach ($pages as $page) {
if ($page->getUid() === $this->currentPageUid) {
$page->setIsCurrentPage(TRUE);
}
// Load contents if enabled in configuration
if ($this->settings['loadContents'] == '1') {
$page->setContents($this->contentRepository->findByPid($page->getUid()));
}
}
if ($this->settings['pageMode'] === 'nested') {
$pages = $this->convertFlatToNestedPagesArray($pages, $rootPageUids);
}
$this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'ModifyPages', array(&$pages, $this));
$this->view->assign('pages', $pages);
}
示例11: trackObjectOnPage
/**
* Tracks display of an object on a page
*
* @param \TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject $object Object to use
* @param mixed $hash Hash or page id (depending on the type) for which the object display will be associated
* @param string $type 'hash' (for only one hash) or 'id' (for complete page cache of a page, for all hash combinations)
* @return void
*/
public function trackObjectOnPage(\TYPO3\CMS\Extbase\DomainObject\AbstractDomainObject $object = NULL, $type = 'hash', $hash = false)
{
if ($object && !$this->ajaxDispatcher->getIsActive()) {
$this->signalSlotDispatcher->dispatch(__CLASS__, self::SIGNAL_PreTrackObjectOnPage, array('object' => $object, 'type' => $type, 'hash' => $hash));
if ($type) {
switch ($type) {
case 'id':
if (!$hash) {
$hash = intval($this->fe->id);
}
$pageHash = 'id-' . $hash;
break;
case 'hash':
default:
if (!$hash) {
$hash = $this->fe->getHash();
}
$pageHash = 'hash-' . $hash;
break;
}
$objectIdentifier = $this->getObjectIdentifierForObject($object);
$sharedLock = null;
$sharedLockAcquired = $this->acquireLock($sharedLock, $objectIdentifier, FALSE);
if ($sharedLockAcquired) {
if ($this->trackingCache->has($objectIdentifier)) {
$pageHashs = $this->trackingCache->get($objectIdentifier);
if (!in_array($pageHash, $pageHashs)) {
$exclusiveLock = null;
$exclusiveLockAcquired = $this->acquireLock($exclusiveLock, $objectIdentifier . '-e', TRUE);
if ($exclusiveLockAcquired) {
$pageHashs = $this->trackingCache->get($objectIdentifier);
if (!in_array($pageHash, $pageHashs)) {
$pageHashs[] = $pageHash;
$this->trackingCache->set($objectIdentifier, array_unique($pageHashs));
}
$this->releaseLock($exclusiveLock);
}
}
} else {
$this->trackingCache->set($objectIdentifier, array($pageHash));
}
$this->releaseLock($sharedLock);
}
}
}
return;
}
示例12: createEmailBody
/**
* Create Email Body
*
* @param array $email Array with all needed mail information
* @return bool
*/
protected function createEmailBody($email)
{
$standaloneView = TemplateUtility::getDefaultStandAloneView();
$standaloneView->getRequest()->setControllerName('Form');
$standaloneView->setTemplatePathAndFilename(TemplateUtility::getTemplatePath($email['template'] . '.html'));
// variables
$variablesWithMarkers = $this->mailRepository->getVariablesWithMarkersFromMail($this->mail);
$standaloneView->assignMultiple($variablesWithMarkers);
$standaloneView->assignMultiple($this->mailRepository->getLabelsWithMarkersFromMail($this->mail));
$standaloneView->assignMultiple(['variablesWithMarkers' => ArrayUtility::htmlspecialcharsOnArray($variablesWithMarkers), 'powermail_all' => TemplateUtility::powermailAll($this->mail, 'mail', $this->settings, $this->type), 'powermail_rte' => $email['rteBody'], 'marketingInfos' => SessionUtility::getMarketingInfos(), 'mail' => $this->mail, 'email' => $email, 'settings' => $this->settings]);
if (!empty($email['variables'])) {
$standaloneView->assignMultiple($email['variables']);
}
$this->signalSlotDispatcher->dispatch(__CLASS__, __FUNCTION__ . 'BeforeRender', [$standaloneView, $email, $this->mail, $this->settings]);
$body = $standaloneView->render();
$this->mail->setBody($body);
return $body;
}
示例13: commit
/**
* Commits the current persistence session.
*
* @return void
*/
public function commit()
{
$this->_addedObjects = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
$this->_removedObjects = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
$this->_changedObjects = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
parent::commit();
foreach ($this->_addedObjects as $object) {
$this->signalSlotDispatcher->dispatch('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', 'afterInsertCommitObjectHijax', array('object' => $object));
}
foreach ($this->_removedObjects as $object) {
$this->signalSlotDispatcher->dispatch('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', 'afterRemoveCommitObjectHijax', array('object' => $object));
}
foreach ($this->_changedObjects as $object) {
$this->signalSlotDispatcher->dispatch('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Backend', 'afterUpdateCommitObjectHijax', array('object' => $object));
}
$this->_addedObjects = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
$this->_removedObjects = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
$this->_changedObjects = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
}
示例14: ajaxAction
/**
* @param \Pluswerk\Simpleblog\Domain\Model\Post $post
* @param \Pluswerk\Simpleblog\Domain\Model\Comment $comment
*/
public function ajaxAction(\Pluswerk\Simpleblog\Domain\Model\Post $post, \Pluswerk\Simpleblog\Domain\Model\Comment $comment = NULL)
{
// Wenn der Kommentar leer ist, wird nicht persistiert
if ($comment->getComment() == "") {
return FALSE;
}
// Datum des Kommentars setzen und den Kommentar zum Post hinzufügen
$comment->setCommentdate(new \DateTime());
$post->addComment($comment);
// Signal for comment
$this->signalSlotDispatcher->dispatch(__CLASS__, 'beforeCommentCreation', array($comment, $post));
$this->postRepository->update($post);
$this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager')->persistAll();
$comments = $post->getComments();
foreach ($comments as $comment) {
$json[$comment->getUid()] = array('comment' => $comment->getComment(), 'commentdate' => $comment->getCommentdate());
}
return json_encode($json);
}
示例15: showAction
/**
* showAction function.
*
* @access public
* @return void
*/
public function showAction()
{
$pages = $this->getPagesWithoutExcludes();
/*
* Signal for other Extensions
*/
/**
* @var array $linksArr
*/
$linksArr = array();
$linksArr[] = array('uri' => 'http://google.de/', 'lastModified' => time());
$dataArr = array();
$dataArr[] = array('plugin' => 'Plugin', 'controller' => 'Controller', 'action' => 'Action', 'extension' => 'Extension', 'pageUid' => 1, 'lastModified' => time(), 'arguments' => array('key' => 'value'));
$this->signalSlotDispatcher->dispatch(__CLASS__, 'addExtensionLinks', array(&$linksArr, &$dataArr));
unset($linksArr[0]);
unset($dataArr[0]);
$this->view->assign('pages', $pages);
$this->view->assign('linkArr', $linksArr);
$this->view->assign('dataArr', $dataArr);
}