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


PHP HookRegistry::getCalledHooks方法代码示例

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


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

示例1: resetCalledHooks

 /**
  * Switch off the function to store hooks and delete all stored hooks.
  * Always call this after using otherwise we get a severe memory.
  * @param $leaveAlive boolean Set this to true if you only want to
  *   delete hooks stored so far but if you want to record future
  *   hook calls, too.
  */
 function resetCalledHooks($leaveAlive = false)
 {
     if (!$leaveAlive) {
         HookRegistry::rememberCalledHooks(false, false);
     }
     $calledHooks =& HookRegistry::getCalledHooks();
     $calledHooks = array();
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:15,代码来源:HookRegistry.inc.php

示例2: testIndexSubmissionFilesViaPluginHook

 /**
  * @covers ArticleSearchIndex
  */
 public function testIndexSubmissionFilesViaPluginHook()
 {
     // Diverting to the search plugin hook.
     HookRegistry::register('ArticleSearchIndex::submissionFilesChanged', array($this, 'callbackIndexSubmissionFiles'));
     // The file DAOs should not be called.
     $this->registerFileDAOs(false);
     // Simulate indexing via hook.
     $article = new Article();
     $articleSearchIndex = new ArticleSearchIndex();
     $articleSearchIndex->submissionFilesChanged($article);
     // Test whether the hook was called.
     $calledHooks = HookRegistry::getCalledHooks();
     $lastHook = array_pop($calledHooks);
     self::assertEquals('ArticleSearchIndex::submissionFilesChanged', $lastHook[0]);
     // Remove the test hook.
     HookRegistry::clear('ArticleSearchIndex::submissionFilesChanged');
 }
开发者ID:mosvits,项目名称:ojs,代码行数:20,代码来源:ArticleSearchIndexTest.php

示例3: testGetProtocolNoHttpsVariable

 /**
  * @covers PKPRequest::getProtocol
  */
 public function testGetProtocolNoHttpsVariable()
 {
     $_SERVER = array();
     self::assertEquals('http', $this->request->getProtocol());
     // The hook should have been triggered once.
     self::assertEquals(array(array('Request::getProtocol', array('http'))), HookRegistry::getCalledHooks());
     // Calling getProtocol() twice should return the same
     // result without triggering the hook again.
     HookRegistry::resetCalledHooks();
     self::assertEquals('http', $this->request->getProtocol());
     self::assertEquals(array(), HookRegistry::getCalledHooks());
 }
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:15,代码来源:PKPRequestTest.php

示例4: testRetrieveResultsViaPluginHook

 /**
  * @covers ArticleSearch
  */
 public function testRetrieveResultsViaPluginHook()
 {
     // Diverting a search to the search plugin hook.
     HookRegistry::register('SubmissionSearch::retrieveResults', array($this, 'callbackRetrieveResults'));
     $testCases = array(array(null => 'query'), array('1' => 'author'), array('2' => 'title'), array(null => 'query', 1 => 'author', 2 => 'title'));
     $testFromDate = date('Y-m-d H:i:s', strtotime('2011-03-15 00:00:00'));
     $testToDate = date('Y-m-d H:i:s', strtotime('2012-03-15 18:30:00'));
     $error = '';
     foreach ($testCases as $testCase) {
         // Test a simple search with the simulated callback.
         $journal = new Journal();
         $keywords = $testCase;
         $articleSearch = new ArticleSearch();
         $searchResult = $articleSearch->retrieveResults($journal, $keywords, $error, $testFromDate, $testToDate);
         // Check the parameters passed into the callback.
         $expectedPage = 1;
         $expectedItemsPerPage = 20;
         $expectedTotalResults = 3;
         $expectedError = '';
         $expectedParams = array($journal, $testCase, $testFromDate, $testToDate, $expectedPage, $expectedItemsPerPage, $expectedTotalResults, $expectedError);
         self::assertEquals($expectedParams, $this->_retrieveResultsParams);
         // Test and clear the call history of the hook registry.
         $calledHooks = HookRegistry::getCalledHooks();
         self::assertEquals('SubmissionSearch::retrieveResults', $calledHooks[0][0]);
         HookRegistry::resetCalledHooks(true);
         // Test whether the result from the hook is being returned.
         self::assertInstanceOf('VirtualArrayIterator', $searchResult);
         // Test the total count.
         self::assertEquals(3, $searchResult->getCount());
         // Test the search result.
         $firstResult = $searchResult->next();
         self::assertArrayHasKey('article', $firstResult);
         self::assertEquals(SUBMISSION_SEARCH_TEST_ARTICLE_FROM_PLUGIN, $firstResult['article']->getId());
         self::assertEquals('', $error);
     }
     // Remove the test hook.
     HookRegistry::clear('SubmissionSearch::retrieveResults');
 }
开发者ID:jalperin,项目名称:ojs,代码行数:41,代码来源:ArticleSearchTest.php

示例5: testGetIndexUrl

 /**
  * @covers PKPRouter::getIndexUrl
  */
 public function testGetIndexUrl()
 {
     $this->_setUpMockEnvironment();
     $this->setTestConfiguration('request1', 'classes/core/config', false);
     // no restful URLs
     $_SERVER = array('HOSTNAME' => 'mydomain.org', 'SCRIPT_NAME' => '/base/index.php');
     HookRegistry::resetCalledHooks();
     self::assertEquals('http://mydomain.org/base/index.php', $this->router->getIndexUrl($this->request));
     // Several hooks should have been triggered.
     self::assertEquals(array(array('Request::getServerHost', array('mydomain.org')), array('Request::getProtocol', array('http')), array('Request::getBasePath', array('/base')), array('Request::getBaseUrl', array('http://mydomain.org/base')), array('Router::getIndexUrl', array('http://mydomain.org/base/index.php'))), HookRegistry::getCalledHooks());
     // Calling getIndexUrl() twice should return the same
     // result without triggering the hooks again.
     HookRegistry::resetCalledHooks();
     self::assertEquals('http://mydomain.org/base/index.php', $this->router->getIndexUrl($this->request));
     self::assertEquals(array(), HookRegistry::getCalledHooks());
 }
开发者ID:anorton,项目名称:pkp-lib,代码行数:19,代码来源:PKPRouterTest.inc.php


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