public function init(array $filters = array()) { foreach ($filters as $filter) { $this->addFilter($filter); } $this->_filters->rewind(); }
public function onEventProcessingFailed(array $eventMessages, \Exception $cause = null) { $this->delegates->rewind(); while ($this->delegates->valid()) { $delegate = $this->delegates->current(); $delegate->onEventProcessingFailed($eventMessages, $cause); $this->delegates->next(); } }
/** * * Registers all the image sizes added * * @author Tim Perry * */ public function registerImageSizes() { $this->sizes->rewind(); while ($this->sizes->valid()) { $imageSize = $this->sizes->current(); add_image_size($imageSize->getName(), $imageSize->getWidth(), $imageSize->getHeight(), $imageSize->getCrop()); $this->sizes->next(); } }
/** * Registers all the field groups added * @author Tim Perry */ public function hookUp() { $this->hookables->rewind(); while ($this->hookables->valid()) { $hookable = $this->hookables->current(); $hookable->hookUp(); $this->hookables->next(); } }
/** * 刷新监听者队列 */ protected function refreshQueue() { $this->storage->rewind(); $this->queue = new \SplPriorityQueue(); foreach ($this->storage as $listener) { $priority = $this->storage->getInfo(); $this->queue->insert($listener, $priority); } }
/** * Adds all the functions into the twig environment * * @param \Twig_Environment $twig * @return \Twig_Environment * @author Tim Perry */ public function getTwig(\Twig_Environment $twig) { $this->functions->rewind(); while ($this->functions->valid()) { $function = $this->functions->current(); $twig->addFunction(new \Twig_SimpleFunction($function->getFunctionName(), array($function, 'getFunctionBody'))); $this->functions->next(); } return $twig; }
/** * @return RangeFile[] */ private function getAllFiles() { $all = []; $this->map->rewind(); while ($this->map->valid() === true) { array_push($all, $this->map->getInfo()); $this->map->next(); } return $all; }
/** * Iterates through user storage until certain $id is found. * * @param $id * * @return User * * @throws UserNotFoundException */ public function find(UserId $id) { $this->users->rewind(); while ($this->users->valid()) { $user = $this->users->current(); if ($user->getId()->equals($id)) { return $user; } $this->users->next(); } throw new UserNotFoundException(sprintf('User with id %d not found.', $id->id())); }
/** * Registers all the taxonomies added */ public function registerTaxonomies() { if (!function_exists('register_taxonomy')) { return; } $this->taxonomies->rewind(); while ($this->taxonomies->valid()) { $taxonomy = $this->taxonomies->current(); register_taxonomy($taxonomy->getName(), $taxonomy->getSupportedPostTypes(), $taxonomy->getArgs()); $this->taxonomies->next(); } }
/** * Registers all the post types added * @author Tim Perry */ public function registerPostTypes() { if (!function_exists('register_post_type')) { return; } $this->postTypes->rewind(); while ($this->postTypes->valid()) { $postType = $this->postTypes->current(); register_post_type($postType->getName(), $postType->getArgs()); $this->postTypes->next(); } }
/** * Registers all shortcodes added * @author Tim Perry */ public function registerShortcodes() { if (!function_exists('add_shortcode')) { return; } $this->shortcodes->rewind(); while ($this->shortcodes->valid()) { $shortcode = $this->shortcodes->current(); add_shortcode($shortcode->getName(), array($shortcode, 'getCallback')); $this->shortcodes->next(); } }
/** * Registers all the meta boxes added * @author Tim Perry */ public function addMetaBoxes() { $this->metaBoxes->rewind(); while ($this->metaBoxes->valid()) { $metaBox = $this->metaBoxes->current(); foreach ($metaBox->getSupportedPostTypes() as $postType) { add_meta_box($metaBox->getID(), $metaBox->getTitle(), array($metaBox, 'getCallback'), $postType, $metaBox->getContext(), $metaBox->getPriority(), $metaBox->getCallbackArgs()); add_action('save_post', array($metaBox, 'savePostCallback')); } $this->metaBoxes->next(); } }
/** * Registers all the field groups added * * @author Tim Perry */ public function registerFieldGroups() { if (!function_exists('register_field_group')) { return; } $this->fieldGroups->rewind(); while ($this->fieldGroups->valid()) { $field = $this->fieldGroups->current(); register_field_group($field->getConfig()); $this->fieldGroups->next(); } }
/** * @param $pos * * @return null|AbstractSQLConnection */ public function getConnectionByPosition($pos) { $pos = (int) $pos; $this->storage->rewind(); for ($i = 0; $this->storage->count() > $i; $i++) { if ($i === $pos) { return $this->storage->current(); } $this->storage->next(); } return null; }
/** * @return int */ public function getNumberOfAdvancedCourses() : int { $advancedCourses = 0; $this->courses->rewind(); while ($this->courses->valid()) { $course = $this->courses->current(); if ($course->isAdvanced()) { $advancedCourses++; } $this->courses->next(); } return $advancedCourses; }
/** * 删除一个监听器 * @param $listener * @return $this */ public function remove($listener) { if ($this->has($listener)) { $this->store->detach($listener); $this->store->rewind(); $queue = new \SplPriorityQueue(); foreach ($this->store as $listener) { // 优先级 $priority = $this->store->getInfo(); $queue->insert($listener, $priority); } $this->queue = $queue; } return $this; }
/** * Initialize the filter with the given comparisons * * @param $comparisons * @return \SplObjectStorage */ public function initWithComparisons($comparisons) { $tempComparisons = new \SplObjectStorage(); foreach ($comparisons as $comparison) { $tempComparisons->attach($comparison); } $tempComparisons->rewind(); $this->comparisons = $tempComparisons; }
public static function clearAllCaches() { self::clearCache(); self::$__caches->rewind(); while (self::$__caches->valid()) { self::$__caches->setInfo([]); self::$__caches->next(); } }
private function eventsToPublish() { $events = array(); $this->eventsToPublish->rewind(); while ($this->eventsToPublish->valid()) { $events = array_merge($events, $this->eventsToPublish->getInfo()); $this->eventsToPublish->next(); } return $events; }
/** * Runs after all steps have been processed bay calling post process method on all steps. * * @param \WCM\WPStarter\Setup\IO $io */ public function postProcess(IO $io) { $this->postProcessSteps->rewind(); while ($this->postProcessSteps->valid()) { /** @var \WCM\WPStarter\Setup\Steps\PostProcessStepInterface $step */ $step = $this->postProcessSteps->current(); $step->postProcess($io); $this->postProcessSteps->next(); } }
/** * {@inheritdoc} */ public function getNonIndexableRules() { $this->loadRules(); $storage = new \SplObjectStorage(); foreach ($this->rules['nonindexable'] as $rule) { $storage->attach($rule); } $storage->rewind(); return $storage; }
/** * @param null|mixed|array $models (optional) */ public function commit($models = null) { $pool = $this->manager->getPool(); /** @var ObjectManager[] $managers */ $managers = $pool->getIterator(); if (null === $models) { foreach ($managers as $manager) { $manager->flush(); } if (!$this->models->count()) { return; } $this->models->rewind(); while ($this->models->valid()) { $model = $this->models->current(); $class = $this->manager->getClassMetadata(get_class($model)); $managerName = $class->getManagerReferenceGenerator(); $ref = call_user_func(array($model, 'get' . ucfirst($managerName))); $id = call_user_func(array($ref, 'get' . ucfirst($class->getIdentifierReference($managerName)->referenceField))); foreach ($this->models->getInfo() as $managerName) { $this->saveSpecificModel($model, $managerName, $id); } $this->models->next(); } // clear list $this->models = new \SplObjectStorage(); } else { if (!is_array($models)) { $models = array($models); } foreach ($models as $model) { $class = $this->manager->getClassMetadata(get_class($model)); $managerName = $class->getManagerReferenceGenerator(); $ref = call_user_func(array($model, 'get' . ucfirst($managerName))); $pool->getManager($managerName)->flush($ref); $id = call_user_func(array($ref, 'get' . ucfirst($class->getIdentifierReference($managerName)->referenceField))); foreach ($class->getFieldManagerNames() as $managerName) { $this->saveSpecificModel($model, $managerName, $id); } } } }
/** * @param \Toobo\PipePie\DTO|null $dto * @param mixed $initial * @return \Toobo\PipePie\DTO */ private function init(DTO $dto = null, $initial = null) { if (is_null($dto)) { $dto = new DTO($this, $initial, $this->context); } elseif (!$dto->acceptInput($initial)) { throw new LogicException('Custom DTO need to be instantiated with proper initial value.'); } $this->working = true; $this->locked = true; $this->pipeline->rewind(); return $dto; }
/** * @param string $wizardName * @return WizardInterface|FALSE */ public function remove($wizardName) { foreach ($this->wizards as $wizard) { if ($wizardName === $wizard->getName()) { $this->wizards->detach($wizard); $this->wizards->rewind(); $wizard->setParent(NULL); return $wizard; } } return FALSE; }
/** * Remove a listener from the queue. * * @param \Closure|object $listener The listener. * * @return ListenersQueue This method is chainable. * * @since 2.0 */ public function remove($listener) { if ($this->storage->contains($listener)) { $this->storage->detach($listener); $this->storage->rewind(); $this->queue = new \SplPriorityQueue(); foreach ($this->storage as $listener) { $priority = $this->storage->getInfo(); $this->queue->insert($listener, $priority); } } return $this; }
public function terminate($message, $timeout = 5, $signal = null) { $this->message($message); while ($this->readyPool->count() > 0) { $this->readyPool->dequeue(); } $this->pool->rewind(); while ($this->pool->count() > 0) { $messenger = $this->pool->current(); $this->pool->detach($messenger); $messenger->terminate($signal); } }
/** * @param Session $session */ public function leave(Session $session) { $this->registrations->rewind(); while ($this->registrations->valid()) { /* @var $registration Registration */ $registration = $this->registrations->current(); $this->registrations->next(); if ($registration->getSession() == $session) { $this->manager->debug("Leaving and unegistering: {$registration->getProcedureName()}"); $this->registrations->detach($registration); } } }
public function saveDirtyModels() { $this->_dirtyModels->rewind(); while ($this->_dirtyModels->valid()) { /* @var $model \yii\db\ActiveRecord */ $model = $this->_dirtyModels->current(); $model->save(); $this->_dirtyModels->next(); } // SplObjectStorage doesn't have a clear() method?! $this->_dirtyModels = new \SplObjectStorage(); $this->_dirtyModelsInfo = []; }
/** * Get session by session ID * * @param int $sessionId * @return \Thruway\Session|boolean */ public function getSessionBySessionId($sessionId) { /** @var Session $session */ $this->sessions->rewind(); while ($this->sessions->valid()) { $session = $this->sessions->getInfo(); if ($session->getSessionId() == $sessionId) { return $session; } $this->sessions->next(); } return false; }
/** * @param string $childName * @return FormInterface|FALSE */ public function remove($childName) { foreach ($this->children as $child) { $isMatchingInstance = TRUE === $childName instanceof FormInterface && $childName->getName() === $child->getName(); $isMatchingName = $childName === $child->getName(); if (TRUE === $isMatchingName || TRUE === $isMatchingInstance) { $this->children->detach($child); $this->children->rewind(); $child->setParent(NULL); return $child; } } return FALSE; }