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


PHP SplPriorityQueue::next方法代码示例

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


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

示例1: trigger

 /**
  * @param string $event
  * @param array  $params
  * @param string $context
  */
 public function trigger($event, $params = [], $context = '')
 {
     if (empty($this->events[$event])) {
         return;
     }
     $queue = new \SplPriorityQueue();
     foreach ($this->events[$event] as $index => $action) {
         $queue->insert($index, $action['prio']);
     }
     $queue->top();
     while ($queue->valid()) {
         $index = $queue->current();
         if (!empty($context)) {
             $contexts = explode(',', $this->events[$event][$index]['contexts']);
             $current_context = false;
             foreach ($contexts as $route) {
                 if (fnmatch(trim($route), $context)) {
                     $current_context = true;
                     break;
                 }
             }
         } else {
             $current_context = true;
         }
         if ($current_context && is_callable($this->events[$event][$index]['fn'])) {
             if (call_user_func_array($this->events[$event][$index]['fn'], $params) === false) {
                 break;
             }
         }
         $queue->next();
     }
 }
开发者ID:sydes,项目名称:sydes,代码行数:37,代码来源:Event.php

示例2: __construct

 /**
  * Method to instantiate the view.
  *
  * @param   JModel            $model  The model object.
  * @param   SplPriorityQueue  $paths  The paths queue.
  *
  * @since   12.1
  */
 public function __construct(JModel $model, SplPriorityQueue $paths = null)
 {
     parent::__construct($model);
     // Setup dependencies.
     $this->paths = isset($paths) ? $paths : $this->loadPaths();
     /* T3: Add T3 html path to the priority paths of component view */
     // T3 html path
     $component = JApplicationHelper::getComponentName();
     $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $component);
     $t3Path = T3_PATH . '/html/' . $component . '/' . $this->getName();
     // Setup the template path
     $this->paths->top();
     $defaultPath = $this->paths->current();
     $this->paths->next();
     $templatePath = $this->paths->current();
     // add t3 path
     $this->paths->insert($t3Path, 3);
     $this->_path['template'] = array($defaultPath, $t3Path, $templatePath);
     /* //T3 */
 }
开发者ID:grlf,项目名称:eyedock,代码行数:28,代码来源:viewhtml.php

示例3: apply

 public function apply($filter, $value, $args = [])
 {
     if (!isset($this->filters[$filter])) {
         return $value;
     }
     if (!count($this->filters[$filter])) {
         return $this;
     }
     $queue = new \SplPriorityQueue();
     foreach ($this->filters[$filter] as $index => $action) {
         $queue->insert($index, $action["prio"]);
     }
     $queue->top();
     while ($queue->valid()) {
         $index = $queue->current();
         if (is_callable($this->filters[$filter][$index]["fn"])) {
             $value = call_user_func_array($this->filters[$filter][$index]["fn"], [$value, $args]);
         }
         $queue->next();
     }
     return $value;
 }
开发者ID:arshanam,项目名称:Autopilot,代码行数:22,代码来源:Filters.php

示例4: cleanup

 protected function cleanup(OutputInterface $output)
 {
     // Recursive directory iterator
     $dir_it = function ($dir) {
         return new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir, \RecursiveDirectoryIterator::SKIP_DOTS), \RecursiveIteratorIterator::CHILD_FIRST);
     };
     // Recursive directory deletion
     $rmdir = function ($dir) use(&$dir_it) {
         foreach ($dir_it($dir) as $file) {
             if ($file->isLink()) {
                 unlink($file->getPathname());
             } elseif ($file->isDir()) {
                 rmdir($file->getPathname());
             } else {
                 unlink($file->getPathname());
             }
         }
         rmdir($dir);
     };
     $further_cleanup_required = FALSE;
     $release_folder = $this->getReleaseDirectory();
     $distributions = array_keys($this->getConfig('distribution_info'));
     // First, release directory cleanup
     foreach (new \DirectoryIterator($release_folder) as $file) {
         if ($file->isDot() || !$file->isDir() || $file->isLink()) {
             continue;
         }
         // Remove distributions which no longer exist (have been removed from the config file).
         if (!in_array($file->getBasename(), $distributions)) {
             $rmdir($file->getPathname());
             $further_cleanup_required = TRUE;
         } else {
             // Clean up timestamped release directories within each distribution.
             // The number to keep is specified by --dirs
             $directories = new \SplPriorityQueue();
             foreach (new \DirectoryIterator($file->getPathname()) as $dir) {
                 if ($dir->isDot() || !$dir->isDir() || $dir->isLink()) {
                     continue;
                 }
                 // Store directories keeping the last modified at the top.
                 $directories->insert($dir->getPathname(), $dir->getCTime());
             }
             // No further action is required for this directory.
             if ($directories->count() <= $this->dirs) {
                 continue;
             }
             $further_cleanup_required = TRUE;
             // Timestamped release directories we want to keep
             for ($i = 0; $i < $this->dirs; $i++) {
                 $directories->extract();
             }
             // Delete all the others
             $directories->top();
             while ($directories->valid()) {
                 $dir = $directories->current();
                 $rmdir($dir);
                 $directories->next();
             }
         }
     }
     // No release directories were removed so no need to do any further cleanup.
     // (all other assets should be in use)
     if (FALSE == $further_cleanup_required) {
         return FALSE;
     }
     // Get a list of all assets that are in use (in use counts as being linked to
     // from a releases directory).
     $find_symlinks = function ($dir) use(&$dir_it) {
         $active_symlinks = [];
         foreach ($dir_it($dir) as $file) {
             // Ignore latest folder symlink
             if ($file->getBasename() != 'latest' && $file->isLink()) {
                 $active_symlinks[] = basename($file->getRealPath());
             }
         }
         return array_unique($active_symlinks);
     };
     // Find all assets that are in use
     $active_symlinks = $find_symlinks($release_folder);
     // Get a list of all assets that are downloaded
     $downloads = [];
     $base_download_dir = $this->getBaseDownloadDirectory();
     $d_it = new \DirectoryIterator($base_download_dir);
     foreach ($d_it as $file) {
         if (!$file->isDot() && $file->isDir()) {
             $downloads[] = $file->getBasename();
         }
     }
     // Calculate which asset folders need to be removed from the downloads directory.
     $to_delete = array_diff($downloads, $active_symlinks);
     if (!empty($to_delete)) {
         $assets = [];
         foreach ($to_delete as $dir) {
             $rmdir($base_download_dir . '/' . $dir);
             $parts = explode('-', $dir);
             if (count($parts) == 5) {
                 $assets[] = $parts[1] . '-' . $parts[2] . '-' . $parts[3];
             } else {
                 $assets[] = $parts[1] . '-' . $parts[2];
             }
//.........这里部分代码省略.........
开发者ID:JustAdam,项目名称:drupal-platform-manager,代码行数:101,代码来源:CleanUp.php

示例5: trigger

 /**
  * Trigger event.
  * @param  String $event
  * @param  Array  $params
  * @return Boolean
  */
 public function trigger($event, $params = [])
 {
     if (!isset($this->events[$event])) {
         return $this;
     }
     if (!count($this->events[$event])) {
         return $this;
     }
     $queue = new \SplPriorityQueue();
     foreach ($this->events[$event] as $index => $action) {
         $queue->insert($index, $action["prio"]);
     }
     $queue->top();
     while ($queue->valid()) {
         $index = $queue->current();
         if (is_callable($this->events[$event][$index]["fn"])) {
             if (call_user_func_array($this->events[$event][$index]["fn"], $params) === false) {
                 break;
                 // stop Propagation
             }
         }
         $queue->next();
     }
     return $this;
 }
开发者ID:nanigashi,项目名称:lime,代码行数:31,代码来源:App.php

示例6: next

 /**
  * {@inheritdoc}
  */
 public function next()
 {
     $this->queue->next();
 }
开发者ID:runopencode,项目名称:twig-bufferized-template,代码行数:7,代码来源:BufferQueue.php


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