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


PHP Registry::clear方法代码示例

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


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

示例1: testClearClears

 /**
  * @covers Monolog\Registry::clear
  */
 public function testClearClears()
 {
     Registry::addLogger(new Logger('test1'), 'log');
     Registry::clear();
     $this->setExpectedException('\\InvalidArgumentException');
     Registry::getInstance('log');
 }
开发者ID:qasem2rubik,项目名称:laravel,代码行数:10,代码来源:RegistryTest.php

示例2: cleanUpUnassignedTokens

 /**
  * Removes the not assigned tokens.
  *
  * @param Token[] $tokens
  */
 public function cleanUpUnassignedTokens(array $tokens)
 {
     $this->em->clear();
     foreach ($tokens as $token) {
         $token = $this->em->merge($token);
         $this->em->remove($token);
     }
     $this->em->flush();
 }
开发者ID:campaignchain,项目名称:security-authentication-client-oauth,代码行数:14,代码来源:TokenService.php

示例3: executeJobs

 /**
  * Search for open jobs and executes them
  * then show a report about the done job.
  */
 protected function executeJobs()
 {
     // Get the Jobs to be processed.
     $jobsInQueue = $this->em->getRepository('CampaignChainCoreBundle:Job')->getOpenJobsForScheduler($this->scheduler);
     if (empty($jobsInQueue)) {
         return;
     }
     $this->io->section('Executing jobs now:');
     $this->logger->info('Executing {counter} jobs now:', ['counter' => count($jobsInQueue)]);
     $this->io->progressStart(count($jobsInQueue));
     foreach ($jobsInQueue as $jobInQueue) {
         // Execute job.
         $this->executeJob($jobInQueue);
         $this->io->progressAdvance();
     }
     // ensure that the progress bar is at 100%
     $this->io->progressFinish();
     $this->em->clear();
     // Get the processed jobs.
     $jobsProcessed = $this->em->getRepository('CampaignChainCoreBundle:Job')->getProcessedJobsForScheduler($this->scheduler);
     if (empty($jobsProcessed)) {
         return;
     }
     // Display the results of the execution.
     $tableHeader = ['Job ID', 'Operation ID', 'Process ID', 'Job Name', 'Job Start Date', 'Job End Date', 'Duration', 'Status', 'Message'];
     $outputTableRows = [];
     foreach ($jobsProcessed as $jobProcessed) {
         $startDate = null;
         $endDate = null;
         if ($jobProcessed->getStartDate()) {
             $startDate = $jobProcessed->getStartDate()->format('Y-m-d H:i:s');
         }
         if ($jobProcessed->getEndDate()) {
             $endDate = $jobProcessed->getEndDate()->format('Y-m-d H:i:s');
         }
         $jobData = [$jobProcessed->getId(), $jobProcessed->getActionId(), $jobProcessed->getPid(), $jobProcessed->getName(), $startDate, $endDate, $jobProcessed->getDuration() . ' ms', $jobProcessed->getStatus(), $jobProcessed->getMessage()];
         $outputTableRows[] = $jobData;
         if (Job::STATUS_ERROR === $jobProcessed->getStatus()) {
             $context = array_combine($tableHeader, $jobData);
             $this->logger->error($jobProcessed->getMessage(), $context);
         }
     }
     $this->io->text('Results of executed actions:');
     $this->io->table($tableHeader, $outputTableRows);
 }
开发者ID:CampaignChain,项目名称:core,代码行数:49,代码来源:SchedulerCommand.php

示例4: downloadFile

 /**
  * Download a file.
  * Outputs HTTP headers and file content for download
  * @param $filePath string the location of the file to be sent
  * @param $mediaType string the MIME type of the file, optional
  * @param $inline print file as inline instead of attachment, optional
  * @return boolean
  */
 function downloadFile($filePath, $mediaType = null, $inline = false, $fileName = null)
 {
     $result = null;
     if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result, &$fileName))) {
         return $result;
     }
     if (is_readable($filePath)) {
         if ($mediaType === null) {
             // If the media type wasn't specified, try to detect.
             $mediaType = String::mime_content_type($filePath);
             if (empty($mediaType)) {
                 $mediaType = 'application/octet-stream';
             }
         }
         if ($fileName === null) {
             // If the filename wasn't specified, use the server-side.
             $fileName = basename($filePath);
         }
         Registry::clear();
         // Free some memory
         header("Content-Type: {$mediaType}");
         header('Content-Length: ' . filesize($filePath));
         header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename=\"{$fileName}\"");
         header('Cache-Control: private');
         // Workarounds for IE weirdness
         header('Pragma: public');
         // Beware of converting to instance call
         // https://github.com/pkp/pkp-lib/commit/82f4a36db406ecac3eb88875541a74123e455713#commitcomment-1459396
         FileManager::readFile($filePath, true);
         return true;
     } else {
         return false;
     }
 }
开发者ID:yuricampos,项目名称:ojs,代码行数:42,代码来源:FileManager.inc.php

示例5: downloadFile

 /**
  * Download a file.
  * Outputs HTTP headers and file content for download
  * @param $filePath string the location of the file to be sent
  * @param $mediaType string the MIME type of the file, optional
  * @param $inline print file as inline instead of attachment, optional
  * @return boolean
  */
 function downloadFile($filePath, $mediaType = null, $inline = false, $fileName = null)
 {
     $result = null;
     if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result, &$fileName))) {
         return $result;
     }
     $postDownloadHookList = array('FileManager::downloadFileFinished', 'UsageEventPlugin::getUsageEvent');
     if (is_readable($filePath)) {
         if ($mediaType === null) {
             // If the media type wasn't specified, try to detect.
             $mediaType = String::mime_content_type($filePath);
             if (empty($mediaType)) {
                 $mediaType = 'application/octet-stream';
             }
         }
         if ($fileName === null) {
             // If the filename wasn't specified, use the server-side.
             $fileName = basename($filePath);
         }
         $postDownloadHooks = null;
         $hooks = HookRegistry::getHooks();
         foreach ($postDownloadHookList as $hookName) {
             if (isset($hooks[$hookName])) {
                 $postDownloadHooks[$hookName] = $hooks[$hookName];
             }
         }
         unset($hooks);
         Registry::clear();
         // Stream the file to the end user.
         header("Content-Type: {$mediaType}");
         header('Content-Length: ' . filesize($filePath));
         header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename=\"{$fileName}\"");
         header('Cache-Control: private');
         // Workarounds for IE weirdness
         header('Pragma: public');
         // Beware of converting to instance call
         // https://github.com/pkp/pkp-lib/commit/82f4a36db406ecac3eb88875541a74123e455713#commitcomment-1459396
         FileManager::readFile($filePath, true);
         if ($postDownloadHooks) {
             foreach ($postDownloadHooks as $hookName => $hooks) {
                 HookRegistry::setHooks($hookName, $hooks);
             }
         }
         $returner = true;
     } else {
         $returner = false;
     }
     HookRegistry::call('FileManager::downloadFileFinished', array(&$returner));
     return $returner;
 }
开发者ID:farhanabbas1983,项目名称:ojs-1,代码行数:58,代码来源:FileManager.inc.php

示例6: downloadFile

 /**
  * Download a file.
  * Outputs HTTP headers and file content for download
  * @param $filePath string the location of the file to be sent
  * @param $mediaType string the MIME type of the file, optional
  * @param $inline print file as inline instead of attachment, optional
  * @return boolean
  */
 function downloadFile($filePath, $mediaType = null, $inline = false)
 {
     $result = null;
     if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result))) {
         return $result;
     }
     if (is_readable($filePath)) {
         if ($mediaType == null) {
             $mediaType = String::mime_content_type($filePath);
             if (empty($mediaType)) {
                 $mediaType = 'application/octet-stream';
             }
         }
         Registry::clear();
         // Free some memory
         header("Content-Type: {$mediaType}");
         header("Content-Length: " . filesize($filePath));
         header("Content-Disposition: " . ($inline ? 'inline' : 'attachment') . "; filename=\"" . basename($filePath) . "\"");
         header("Cache-Control: private");
         // Workarounds for IE weirdness
         header("Pragma: public");
         import('lib.pkp.classes.file.FileManager');
         FileManager::readFile($filePath, true);
         return true;
     } else {
         return false;
     }
 }
开发者ID:ramonsodoma,项目名称:pkp-lib,代码行数:36,代码来源:FileManager.inc.php

示例7: setUp

 protected function setUp()
 {
     Registry::clear();
 }
开发者ID:scrobot,项目名称:Lumen,代码行数:4,代码来源:RegistryTest.php

示例8: run

 function run($f3)
 {
     $test = new \Test();
     Registry::clear('Cron');
     //plugin config
     $f3->config('tests/jobs.ini');
     $f3->mset(array('log' => FALSE, 'cli' => TRUE, 'web' => FALSE, 'clipath' => 'index.php'), 'CRON.');
     $cron = Cron::instance();
     $test->expect(!$cron->log && $cron->cli && !$cron->web && count($cron->jobs) == 3 && $cron->clipath == 'index.php', 'Initial config');
     $test->expect($cron->jobs['JobC'][1] === '*/2 0-23 1-3,4-5 4,5,6 *', 'Expression containing commas correctly restored');
     $test->expect(isset($f3->ROUTES['/cron']), 'Route automatically defined');
     //async auto-detection
     $async = function_exists('exec') && exec('php -r "echo 1+3;"') == '4';
     $test->expect($cron->async === $async, 'Async auto-detection: ' . ($async ? 'ON' : 'OFF'));
     //expression parsing
     $test->expect($cron->parseExpr('1 2 3,9 4 5') === array(array(1), array(2), array(3, 9), array(4), array(5)), 'parseExpr(): single values');
     $test->expect($cron->parseExpr('1-3 2-5 3-2,1 4 *') === array(array(1, 2, 3), array(2, 3, 4, 5), array(3, 2, 1), array(4), range(0, 6)), 'parseExpr(): ranges and wildcards');
     $test->expect($cron->parseExpr('0,1-6/2,10 2 0-10/3 4 */3') === array(array(0, 1, 3, 5, 10), array(2), array(0, 3, 6, 9), array(4), array(0, 3, 6)), 'parseExpr(): step values on ranges and wildcards');
     $test->expect($cron->parseExpr('@yearly') === $cron->parseExpr('0 0 1 1 *') && $cron->parseExpr('@annually') === $cron->parseExpr('0 0 1 1 *') && $cron->parseExpr('@monthly') === $cron->parseExpr('0 0 1 * *') && $cron->parseExpr('@weekly') === $cron->parseExpr('0 0 * * 0') && $cron->parseExpr('@daily') === $cron->parseExpr('0 0 * * *') && $cron->parseExpr('@hourly') === $cron->parseExpr('0 * * * *') && $cron->parseExpr('@weekend') === $cron->parseExpr('0 8 * * 6') && $cron->parseExpr('@lunch') === $cron->parseExpr('0 12 * * *'), 'parseExpr(): schedule presets');
     $test->expect($cron->parseExpr('1 2 3 4') === FALSE && $cron->parseExpr('*-2 2 3 4 5') === FALSE && $cron->parseExpr('1 2 3-5/4 4 5') === FALSE && $cron->parseExpr('1 2 3 4 sun') === FALSE && $cron->parseExpr('@dinner') === FALSE, 'parseExpr(): invalid expressions or presets return FALSE');
     //timestamp parsing
     $time = mktime(1, 2, 3, 4, 5, 2015);
     // 2015-04-05 01:02:03 (Saturday)
     $test->expect($cron->parseTimestamp($time) == array(2, 1, 5, 4, 0), 'parseTimestamp()');
     //due check
     $test->expect($cron->isDue('JobA', $time) && $cron->isDue('JobB', $time) && $cron->isDue('JobC', $time), 'isDue() returns TRUE if the requested job is due at the given time');
     $test->expect($cron->isDue('Foo', $time) === FALSE || $cron->isDue('joba', $time) === FALSE, 'isDue() returns FALSE if the requested job doesn\'t exist or if the case doesn\'t match');
     $cron->set('JobD', function () use($f3) {
         $f3->job .= 'D';
     }, '* * 4 * *');
     $cron->set('JobE', 'Jobs->jobE', '2 1 5 4 1');
     $cron->set('JobF', 'Jobs->jobF', '*/3 * * * *');
     $test->expect(!$cron->isDue('JobD', $time) && !$cron->isDue('JobE', $time) && !$cron->isDue('JobF', $time), 'isDue() returns FALSE if the requested job is not due at the given time');
     //job execution
     $f3->job = '';
     $cron->execute('JobA', FALSE);
     $cron->execute('JobD', FALSE);
     $test->expect($f3->job === 'AD', 'Serial job execution');
     $cron->execute('JobC', FALSE);
     $test->expect(TRUE, 'Silently fail on a non-existing job handler');
     //logging
     @unlink($logfile = $f3->LOGS . 'cron.log');
     $cron->log = TRUE;
     $cron->execute('JobA', FALSE);
     $cron->log = FALSE;
     $test->expect(file_exists($logfile) && count(file($logfile)) == 1, 'Logging to file');
     //schedule running
     $f3->job = '';
     $cron->run($time, FALSE);
     $test->expect($f3->job = 'AB', 'Run scheduler, i.e executes all due jobs');
     //async job execution
     if ($async) {
         $cron->set('test1', 'Jobs->test1', '* * * * *');
         $cron->set('test2', 'Jobs->test2', '* * * * *');
         @unlink($testfile = $f3->TEMP . 'cron-test.txt');
         $cron->execute('test1', TRUE);
         $cron->execute('test2', TRUE);
         $async_ok = FALSE;
         //wait for async processes to complete
         $start = microtime(TRUE);
         $loop = array(0.1, 4);
         //loop (step=0.1s / max=4s)
         while (microtime(TRUE) - $start < $loop[1]) {
             usleep($loop[0] * 1000000);
             if (file_exists($testfile) && preg_match('/([ABCD]){4}/', file_get_contents($testfile), $m) && array_unique($m) === $m) {
                 $async_ok = TRUE;
                 break;
             }
         }
         $test->expect($async_ok, 'Parallel job execution');
     }
     //web access forbidden by default
     $f3->HALT = FALSE;
     $f3->clear('ERROR');
     $f3->ONERROR = function () {
     };
     $f3->mock('GET /cron');
     $test->expect(isset($f3->ERROR['code']) && $f3->ERROR['code'] === 404, 'Web access forbidden by default');
     $f3->set('results', $test->results());
 }
开发者ID:binarygeotech,项目名称:f3-cron,代码行数:80,代码来源:tests.php

示例9: downloadFile

 /**
  * Download a file.
  * Outputs HTTP headers and file content for download
  * @param $filePath string the location of the file to be sent
  * @param $type string the MIME type of the file, optional
  * @param $inline print file as inline instead of attachment, optional
  * @return boolean
  */
 function downloadFile($filePath, $type = null, $inline = false, $filename = null)
 {
     if (is_null($filename)) {
         $filename = basename($filePath);
     }
     $u_agent = $_SERVER['HTTP_USER_AGENT'];
     if (preg_match('/MSIE/i', $u_agent) && !preg_match('/Opera/i', $u_agent) || strpos($_SERVER['HTTP_USER_AGENT'], 'Trident/7.0; rv:11.0') !== false) {
         $filename = iconv('utf8', 'big5', $filename);
     }
     //$filename = basename($filePath);
     $result = null;
     if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$type, &$inline, &$result))) {
         return $result;
     }
     if (is_readable($filePath)) {
         if ($type == null) {
             $type = String::mime_content_type($filePath);
             if (empty($type)) {
                 $type = 'application/octet-stream';
             }
         }
         Registry::clear();
         // Free some memory
         header("Content-Type: {$type}");
         header("Content-Length: " . filesize($filePath));
         header("Content-Disposition: " . ($inline ? 'inline' : 'attachment') . "; filename=\"" . $filename . "\"");
         header("Cache-Control: private");
         // Workarounds for IE weirdness
         header("Pragma: public");
         import('file.FileManager');
         FileManager::readFile($filePath, true);
         return true;
     } else {
         return false;
     }
 }
开发者ID:pulipulichen,项目名称:ocs,代码行数:44,代码来源:FileManager.inc.php

示例10: __destruct

 /**
 		Wrap-up
 		@return NULL
 	**/
 function __destruct()
 {
     Registry::clear(get_called_class());
 }
开发者ID:adentes-org,项目名称:preums,代码行数:8,代码来源:base.php

示例11: downloadFile

 /**
  * Download a file.
  * Outputs HTTP headers and file content for download
  * @param $filePath string the location of the file to be sent
  * @param $mediaType string the MIME type of the file, optional
  * @param $inline print file as inline instead of attachment, optional
  * @return boolean
  */
 function downloadFile($filePath, $mediaType = null, $inline = false, $fileName = null)
 {
     $result = null;
     if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$mediaType, &$inline, &$result, &$fileName))) {
         return $result;
     }
     $postDownloadHookList = array('FileManager::downloadFileFinished', 'UsageEventPlugin::getUsageEvent');
     if (is_readable($filePath)) {
         if ($mediaType === null) {
             // If the media type wasn't specified, try to detect.
             $mediaType = PKPString::mime_content_type($filePath);
             if (empty($mediaType)) {
                 $mediaType = 'application/octet-stream';
             }
         }
         if ($fileName === null) {
             // If the filename wasn't specified, use the server-side.
             $fileName = basename($filePath);
         }
         // Free some memory
         $postDownloadHooks = null;
         $hooks = HookRegistry::getHooks();
         foreach ($postDownloadHookList as $hookName) {
             if (isset($hooks[$hookName])) {
                 $postDownloadHooks[$hookName] = $hooks[$hookName];
             }
         }
         unset($hooks);
         Registry::clear();
         // Stream the file to the end user.
         header("Content-Type: {$mediaType}");
         header('Content-Length: ' . filesize($filePath));
         header('Content-Disposition: ' . ($inline ? 'inline' : 'attachment') . "; filename=\"{$fileName}\"");
         header('Cache-Control: private');
         // Workarounds for IE weirdness
         header('Pragma: public');
         $this->readFileFromPath($filePath, true);
         if ($postDownloadHooks) {
             foreach ($postDownloadHooks as $hookName => $hooks) {
                 HookRegistry::setHooks($hookName, $hooks);
             }
         }
         $returner = true;
     } else {
         $returner = false;
     }
     HookRegistry::call('FileManager::downloadFileFinished', array(&$returner));
     return $returner;
 }
开发者ID:PublishingWithoutWalls,项目名称:pkp-lib,代码行数:57,代码来源:FileManager.inc.php

示例12: downloadFile

 /**
  * Download a file.
  * Outputs HTTP headers and file content for download
  * @param $filePath string the location of the file to be sent
  * @param $type string the MIME type of the file, optional
  * @param $inline print file as inline instead of attachment, optional
  * @return boolean
  */
 function downloadFile($filePath, $type = null, $inline = false, $label = null, $repo = false)
 {
     if ($repo == false) {
         if (HookRegistry::call('FileManager::downloadFile', array(&$filePath, &$type, &$inline, &$result))) {
             return $result;
         }
         if (is_readable($filePath)) {
             if ($type == null) {
                 $type = String::mime_content_type($filePath);
                 if (empty($type)) {
                     $type = 'application/octet-stream';
                 }
             }
             Registry::clear();
             // Free some memory
             header("Content-Type: {$type}");
             header("Content-Length: " . filesize($filePath));
             header("Content-Disposition: " . ($inline ? 'inline' : 'attachment') . "; filename=\"" . basename($filePath) . "\"");
             header("Cache-Control: private");
             header("Pragma: public");
             import('lib.pkp.classes.file.FileManager');
             FileManager::readFile($filePath, true);
             return true;
         } else {
             return false;
         }
     } else {
         //return file from repository
         $ch = curl_init($filePath);
         curl_setopt($ch, CURLOPT_HEADER, 1);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $c = curl_exec($ch);
         $info = curl_getinfo($ch);
         curl_close($ch);
         if ($label == null) {
             $filename = str_replace("/content", "", $filePath);
             $filename = substr($filename, strrpos($filename, "/") + 1);
         }
         header("Etag: " . md5($filename));
         header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
         header("Content-Type:" . $info['content_type']);
         header("Content-Disposition: " . ($inline ? 'inline' : 'attachment') . "; filename=\"" . $label . "\"");
         header("Cache-Control: private");
         header("Pragma: public");
         ob_clean();
         flush();
         readfile($filePath);
     }
 }
开发者ID:master3395,项目名称:CBPPlatform,代码行数:58,代码来源:FileManager.inc.php

示例13: __destruct

 public function __destruct()
 {
     // free embedded relation cache from memory
     \Registry::clear($this->cid);
 }
开发者ID:binarygeotech,项目名称:burgers,代码行数:5,代码来源:cortex.php


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