当前位置: 首页>>代码示例>>PHP>>正文


PHP Events::dispatch方法代码示例

本文整理汇总了PHP中Events::dispatch方法的典型用法代码示例。如果您正苦于以下问题:PHP Events::dispatch方法的具体用法?PHP Events::dispatch怎么用?PHP Events::dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Events的用法示例。


在下文中一共展示了Events::dispatch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: saveEntryAttributesForm

 public function saveEntryAttributesForm(Form $form, Entry $entry)
 {
     foreach ($form->getControls() as $control) {
         $type = $control->getControlType();
         $saver = $type->getSaveHandler($control);
         if ($saver instanceof SaveHandlerInterface) {
             $saver->saveFromRequest($control, $entry, $this->request);
         }
     }
     $this->entityManager->flush();
     $ev = new Event($entry);
     $ev->setEntityManager($this->entityManager);
     \Events::dispatch('on_express_entry_saved', $ev);
     return $ev->getEntry();
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:15,代码来源:Manager.php

示例2: testFire

 /**
  * @todo Implement testFire().
  */
 public function testFire()
 {
     $observer = new EventsTestObserver();
     $this->object->addListener('fire', array($observer, 'invoke'));
     $event = new GenericEvent('dontfire', array('a' => 1, 'b' => 2));
     $this->object->dispatch('dontfire');
     $this->assertEquals(0, $observer->invoked);
     $event = new GenericEvent('fire', array('a' => 18, 'b' => 81));
     $this->object->dispatch('fire', $event);
     $this->assertEquals(1, $observer->invoked);
     $this->assertEquals('81', $observer->event['b']);
 }
开发者ID:masteramuk,项目名称:concrete5,代码行数:15,代码来源:EventsTest.php

示例3: saveForm

 public function saveForm(Page $c)
 {
     $controls = Control::getList($this->type);
     $outputControls = array();
     foreach ($controls as $cn) {
         $data = $cn->getRequestValue();
         $cn->publishToPage($c, $data, $controls);
         $outputControls[] = $cn;
     }
     // set page name from controls
     // now we see if there's a page name field in there
     $containsPageNameControl = false;
     foreach ($outputControls as $cn) {
         if ($cn instanceof NameCorePageProperty) {
             $containsPageNameControl = true;
             break;
         }
     }
     if (!$containsPageNameControl) {
         foreach ($outputControls as $cn) {
             if ($cn->canPageTypeComposerControlSetPageName()) {
                 $pageName = $cn->getPageTypeComposerControlPageNameValue($c);
                 $c->updateCollectionName($pageName);
             }
         }
     }
     // remove all but the most recent X drafts.
     if ($c->isPageDraft()) {
         $vl = new VersionList($c);
         $vl->setItemsPerPage(-1);
         // this will ensure that we only ever keep X versions.
         $vArray = $vl->getPage();
         if (count($vArray) > $this->ptDraftVersionsToSave) {
             for ($i = $this->ptDraftVersionsToSave; $i < count($vArray); ++$i) {
                 $v = $vArray[$i];
                 @$v->delete();
             }
         }
     }
     $c = Page::getByID($c->getCollectionID(), 'RECENT');
     $controls = array();
     foreach ($outputControls as $oc) {
         $oc->setPageObject($c);
         $controls[] = $oc;
     }
     $ev = new Event($c);
     $ev->setPageType($this->type);
     $ev->setArgument('controls', $controls);
     \Events::dispatch('on_page_type_save_composer_form', $ev);
     return $controls;
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:51,代码来源:StandardSaver.php

示例4: notifyAdmin

 protected function notifyAdmin($offenderID)
 {
     $offender = UserInfo::getByID($offenderID);
     $ue = new \Concrete\Core\User\Event\UserInfo($offender);
     Events::dispatch('on_private_message_over_limit', $ue);
     $admin = UserInfo::getByID(USER_SUPER_ID);
     Log::addEntry(t("User: %s has tried to send more than %s private messages within %s minutes", $offender->getUserName(), \Config::get('concrete.user.private_messages.throttle_max'), \Config::get('concrete.user.private_messages.throttle_max_timespan')), t('warning'));
     Loader::helper('mail');
     $mh = new MailHelper();
     $mh->addParameter('offenderUname', $offender->getUserName());
     $mh->addParameter('profileURL', BASE_URL . View::url('/profile', 'view', $offender->getUserID()));
     $mh->addParameter('profilePreferencesURL', BASE_URL . View::url('/profile/edit'));
     $mh->to($admin->getUserEmail());
     $mh->load('private_message_admin_warning');
     $mh->sendMail();
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:16,代码来源:Limit.php

示例5: submit

 public function submit()
 {
     if ($this->validateAction()) {
         if ($this->permissions->canDeleteBlock()) {
             $b = $this->getBlockToEdit();
             $pr = $this->getEditResponse($b);
             // Since we have the OLD block ID in the DOM, we need to override that bID
             $pr->setAdditionalDataAttribute('bID', $this->block->getBlockID());
             $b->deleteBlock();
             $event = new BlockDelete($b, $this->page);
             \Events::dispatch('on_block_delete', $event);
             $b->getBlockCollectionObject()->rescanDisplayOrder($_REQUEST['arHandle']);
             $pr->setMessage(t('Block deleted successfully.'));
             $pr->outputJSON();
         }
     }
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:17,代码来源:delete.php

示例6: clearCaches

 /**
  * Utility method for clearing all application caches.
  */
 public function clearCaches()
 {
     \Events::dispatch('on_cache_flush');
     Core::make('cache')->flush();
     Core::make('cache/expensive')->flush();
     // flush the CSS cache
     if (is_dir(DIR_FILES_CACHE . '/' . DIRNAME_CSS)) {
         $fh = Loader::helper("file");
         $fh->removeAll(DIR_FILES_CACHE . '/' . DIRNAME_CSS);
     }
     $pageCache = PageCache::getLibrary();
     if (is_object($pageCache)) {
         $pageCache->flush();
     }
     // clear the environment overrides cache
     $env = \Environment::get();
     $env->clearOverrideCache();
     // Clear localization cache
     Localization::clearCache();
     // clear block type cache
     BlockType::clearCache();
 }
开发者ID:ngreimel,项目名称:kovent,代码行数:25,代码来源:Application.php

示例7: delete

 public function delete()
 {
     $db = Loader::db();
     if (!$this->uID) {
         return false;
     }
     $ue = new Event($this);
     $ue = Events::dispatch('on_private_message_delete', $ue);
     if (!$ue) {
         return;
     }
     $db->Execute('delete from UserPrivateMessagesTo where uID = ? and msgID = ?', array($this->uID, $this->msgID));
 }
开发者ID:meixelsberger,项目名称:concrete5-5.7.0,代码行数:13,代码来源:PrivateMessage.php

示例8: getOutput

 public function getOutput($request = null)
 {
     $pl = $this->getPageListObject();
     if ($this->cParentID) {
         $parent = Page::getByID($this->cParentID);
         $link = $parent->getCollectionLink();
     }
     $pagination = $pl->getPagination();
     if ($pagination->getTotalResults() > 0) {
         $writer = new \Zend\Feed\Writer\Feed();
         $writer->setTitle($this->getTitle());
         $writer->setDescription($this->getDescription());
         $writer->setLink((string) $link);
         foreach ($pagination->getCurrentPageResults() as $p) {
             $entry = $writer->createEntry();
             $entry->setTitle($p->getCollectionName());
             $entry->setDateCreated(strtotime($p->getCollectionDatePublic()));
             $content = $this->getPageFeedContent($p);
             if (!$content) {
                 $content = t('No Content.');
             }
             $entry->setDescription($content);
             $entry->setLink((string) $p->getCollectionLink(true));
             $writer->addEntry($entry);
         }
         $ev = new FeedEvent($parent);
         $ev->setFeedObject($this);
         $ev->setWriterObject($writer);
         $ev->setRequest($request);
         $ev = \Events::dispatch('on_page_feed_output', $ev);
         $writer = $ev->getWriterObject();
         return $writer->export('rss');
     }
 }
开发者ID:ngreimel,项目名称:kovent,代码行数:34,代码来源:Feed.php

示例9: clearCaches

 /**
  * Utility method for clearing all application caches.
  */
 public function clearCaches()
 {
     \Events::dispatch('on_cache_flush');
     $this['cache']->flush();
     $this['cache/expensive']->flush();
     $config = $this['config'];
     // Delete and re-create the cache directory
     $cacheDir = $config->get('concrete.cache.directory');
     if (is_dir($cacheDir)) {
         $fh = Core::make('helper/file');
         $fh->removeAll($cacheDir, true);
     }
     $this->setupFilesystem();
     $pageCache = PageCache::getLibrary();
     if (is_object($pageCache)) {
         $pageCache->flush();
     }
     // clear the environment overrides cache
     $env = \Environment::get();
     $env->clearOverrideCache();
     // Clear localization cache
     Localization::clearCache();
     // clear block type cache
     BlockType::clearCache();
     // Clear precompiled script bytecode caches
     OpCache::clear();
 }
开发者ID:bobzepplin,项目名称:dodgeball,代码行数:30,代码来源:Application.php

示例10: clearCaches

 /**
  * Utility method for clearing all application caches.
  */
 public function clearCaches()
 {
     \Events::dispatch('on_cache_flush');
     $this['cache']->flush();
     $this['cache/expensive']->flush();
     $config = $this['config'];
     // Delete and re-create the cache directory
     $cacheDir = $config->get('concrete.cache.directory');
     if (is_dir($cacheDir)) {
         $fh = Core::make('helper/file');
         $fh->removeAll($cacheDir, true);
     }
     $this->setupFilesystem();
     $pageCache = PageCache::getLibrary();
     if (is_object($pageCache)) {
         $pageCache->flush();
     }
     // Clear the file thumbnail path cache
     $connection = $this['database'];
     $sql = $connection->getDatabasePlatform()->getTruncateTableSQL('FileImageThumbnailPaths');
     try {
         $connection->executeUpdate($sql);
     } catch (\Exception $e) {
     }
     // clear the environment overrides cache
     $env = \Environment::get();
     $env->clearOverrideCache();
     // Clear localization cache
     Localization::clearCache();
     // clear block type cache
     BlockType::clearCache();
     // Clear precompiled script bytecode caches
     OpCache::clear();
     \Events::dispatch('on_cache_flush_end');
 }
开发者ID:WillemAnchor,项目名称:concrete5,代码行数:38,代码来源:Application.php

示例11: dirname

<?php

$DIR_BASE_CORE = dirname(__DIR__);
define('DIR_BASE', dirname($DIR_BASE_CORE));
require $DIR_BASE_CORE . '/bootstrap/configure.php';
require $DIR_BASE_CORE . '/bootstrap/autoload.php';
if (!\Concrete\Core\Application\Application::isRunThroughCommandLineInterface()) {
    return false;
}
$cms = (require $DIR_BASE_CORE . '/bootstrap/start.php');
$app = new \Concrete\Core\Console\Application();
$cms->instance('console', $app);
if ($cms->isInstalled()) {
    $cms->setupPackageAutoloaders();
    $cms->setupPackages();
}
$app->setupDefaultCommands();
\Events::dispatch('on_before_console_run');
$app->run();
\Events::dispatch('on_after_console_run');
开发者ID:ceko,项目名称:concrete5-1,代码行数:20,代码来源:concrete5.php

示例12: publish

 public function publish(Page $c, $requestOrDateTime = null)
 {
     $this->stripEmptyPageTypeComposerControls($c);
     $parent = Page::getByID($c->getPageDraftTargetParentPageID());
     if ($c->isPageDraft()) {
         // this is still a draft, which means it has never been properly published.
         // so we need to move it, check its permissions, etc...
         Section::registerPage($c);
         $c->move($parent);
         if (!$parent->overrideTemplatePermissions()) {
             // that means the permissions of pages added beneath here inherit from page type permissions
             // this is a very poorly named method. Template actually used to mean Type.
             // so this means we need to set the permissions of this current page to inherit from page types.
             $c->inheritPermissionsFromDefaults();
         }
         $c->activate();
     } else {
         $c->rescanCollectionPath();
     }
     $u = new User();
     if (!$requestOrDateTime instanceof ApprovePagePageWorkflowRequest) {
         $v = CollectionVersion::get($c, 'RECENT');
         $pkr = new ApprovePagePageWorkflowRequest();
         $pkr->setRequestedPage($c);
         $pkr->setRequestedVersionID($v->getVersionID());
         $pkr->setRequesterUserID($u->getUserID());
         if ($requestOrDateTime) {
             // That means it's a date time
             $pkr->scheduleVersion($requestOrDateTime);
         }
     } else {
         $pkr = $requestOrDateTime;
     }
     $pkr->trigger();
     $u->unloadCollectionEdit($c);
     CacheLocal::flush();
     $ev = new Event($c);
     $ev->setPageType($this);
     $ev->setUser($u);
     \Events::dispatch('on_page_type_publish', $ev);
 }
开发者ID:ppiedaderawnet,项目名称:concrete5,代码行数:41,代码来源:Type.php

示例13: array

$linkTags = array();
if (($favIconFID = intval(Config::get('concrete.misc.favicon_fid'))) && ($favIconFile = File::getByID($favIconFID)) && is_object($favIconFile)) {
    $favIconFileURL = $favIconFile->getURL();
    $linkTags['shortcut icon'] = sprintf('<link rel="shortcut icon" href="%s" type="image/x-icon"/>', $favIconFileURL);
    $linkTags['icon'] = sprintf('<link rel="icon" href="%s" type="image/x-icon"/>', $favIconFileURL);
}
if (($appleIconFID = intval(Config::get('concrete.misc.iphone_home_screen_thumbnail_fid'))) && ($appleIconFile = File::getByID($appleIconFID)) && is_object($appleIconFile)) {
    $linkTags['apple-touch-icon'] = sprintf('<link rel="apple-touch-icon" href="%s"/>', $appleIconFile->getURL());
}
// Generate and dispatch an event, to let other Add-Ons make use of the available (meta) tags/page title
$event = new \Symfony\Component\EventDispatcher\GenericEvent();
$event->setArgument('metaTags', $metaTags);
$event->setArgument('linkTags', $linkTags);
$event->setArgument('pageTitle', $pageTitle);
$event->setArgument('defaultPageTitle', $defaultPageTitle);
Events::dispatch('on_header_required_ready', $event);
$metaTags = $event->getArgument('metaTags');
$linkTags = $event->getArgument('linkTags');
$pageTitle = $event->getArgument('pageTitle');
?>

<title><?php 
echo htmlspecialchars($pageTitle, ENT_COMPAT, APP_CHARSET);
?>
</title>

<?php 
echo implode(PHP_EOL, $metaTags);
if (!empty($linkTags)) {
    echo implode(PHP_EOL, $linkTags);
}
开发者ID:WillemAnchor,项目名称:concrete5,代码行数:31,代码来源:header_required.php

示例14: Permissions

                }
                $b = Block::getByID($_REQUEST['bID'], $cx, $ax);
                $p = new Permissions($b);
                // might be block-level, or it might be area level
                // we're removing a particular block of content
                if ($p->canDeleteBlock()) {
                    $nvc = $cx->getVersionToModify();
                    if ($a->isGlobalArea()) {
                        $xvc = $c->getVersionToModify();
                        // we need to create a new version of THIS page as well.
                        $xvc->relateVersionEdits($nvc);
                    }
                    $b->loadNewCollection($nvc);
                    $b->deleteBlock();
                    $event = new BlockDelete($b, $c);
                    \Events::dispatch('on_block_delete', $event);
                    $nvc->rescanDisplayOrder($_REQUEST['arHandle']);
                    if (isset($_POST['isAjax'])) {
                        exit;
                    }
                    $cID = $securityHelper->sanitizeInt($_GET['cID']);
                    header('Location: ' . \Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=' . $cID . '&mode=edit' . $step);
                    exit;
                }
            }
            break;
    }
}
if (isset($_GET['atask']) && $_GET['atask'] && $valt->validate()) {
    switch ($_GET['atask']) {
        case 'add_stack':
开发者ID:WillemAnchor,项目名称:concrete5,代码行数:31,代码来源:process.php

示例15:

 * methods
 * ----------------------------------------------------------------------------
 */
$cms->setupPackages();
/**
 * ----------------------------------------------------------------------------
 * Load all permission keys into our local cache.
 * ----------------------------------------------------------------------------
 */
PermissionKey::loadAll();
/**
 * ----------------------------------------------------------------------------
 * Fire an event for intercepting the dispatch
 * ----------------------------------------------------------------------------
 */
\Events::dispatch('on_before_dispatch');
/**
 * ----------------------------------------------------------------------------
 * Get the response to the current request
 * ----------------------------------------------------------------------------
 */
$response = $cms->dispatch($request);
/**
 * ----------------------------------------------------------------------------
 * Send it to the user
 * ----------------------------------------------------------------------------
 */
$response->send();
/**
 * ----------------------------------------------------------------------------
 * Return the CMS object.
开发者ID:kreativmind,项目名称:concrete5-5.7.0,代码行数:31,代码来源:start.php


注:本文中的Events::dispatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。