Esempio n. 1
0
 /**
  * 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();
     }
 }
Esempio n. 2
0
 public function execute(&$request, &$response)
 {
     if ($this->_filters->valid()) {
         /* @var $current Filter */
         $current = $this->_filters->current();
         $this->_filters->next();
         $current->execute($request, $response, $this);
     }
 }
Esempio n. 3
0
 /**
  *
  * 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();
     }
 }
 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();
     }
 }
 /**
  * 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;
 }
Esempio n. 6
0
 /**
  * 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();
     }
 }
Esempio n. 7
0
 /**
  * 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()));
 }
Esempio n. 8
0
 /**
  * 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();
     }
 }
Esempio n. 9
0
 /**
  * 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();
     }
 }
 /**
  * @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;
 }
Esempio n. 11
0
 /**
  * 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();
     }
 }
Esempio n. 12
0
 /**
  * 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();
     }
 }
 /**
  * @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;
 }
Esempio n. 14
0
 /**
  * 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();
     }
 }
Esempio n. 15
0
 /**
  * @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);
             }
         }
     }
 }
Esempio n. 16
0
 /**
  * Run current callback in the pipeline.
  *
  * @param $initial
  * @param $carry
  * @return mixed
  */
 private function run($initial, $carry)
 {
     /** @var callable $callback */
     $callback = $this->pipeline->current();
     /** @var array $args */
     $args = $this->pipeline->getInfo();
     array_unshift($args, $this->DTOs->top());
     array_unshift($args, $initial);
     array_unshift($args, $carry);
     return $this->maybeCast(call_user_func_array($callback, $args));
 }
 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);
     }
 }
Esempio n. 18
0
 /**
  * @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);
         }
     }
 }
Esempio n. 19
0
 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 = [];
 }
Esempio n. 20
0
 /**
  * @return RequestHandler
  */
 protected function nextRequest()
 {
     if ($this->pendingRequests->count() > 0) {
         $this->pendingRequests->rewind();
         $handler = $this->pendingRequests->current();
         $handler->incrementAttempts();
         $this->pendingRequests->detach($handler);
     } else {
         $request = $this->requestProvider->nextRequest();
         if ($request instanceof Request) {
             $handler = new RequestHandler($request);
         } else {
             $this->requestProviderEmpty = true;
             $handler = null;
         }
     }
     return $handler;
 }
Esempio n. 21
0
 /**
  * Completes all the named entities' data accumulated before (plus some
  * additional data, such as some context string) to the database.
  */
 protected function save()
 {
     $this->entities->rewind();
     while ($this->entities->valid()) {
         $entity = $this->entities->current();
         $containerindex = $this->entities->getInfo();
         // Get the text context.
         list($entity->contextstart, $entity->notation, $entity->contextend) = $this->extractText($entity->xmlid, $containerindex);
         foreach (explode(' ', $entity->identifier) as $identifier) {
             // Each entry in array $tag['key'] points to a different target. If
             // there are multiple entries, we have to add multiple records to
             // support links with multiple targets. Note: save() below will
             // always insert a new record, therefore it doesn't matter that
             // we pass the same object several times.
             $entity->identifier = $identifier;
             $this->entityGateway->save($entity);
         }
         $this->entities->detach($entity);
         unset($entity);
     }
 }
Esempio n. 22
0
 /**
  * //@todo make this better
  * @param Session $session
  */
 public function leave(Session $session)
 {
     $this->subscriptions->rewind();
     while ($this->subscriptions->valid()) {
         /* @var $subscription Subscription */
         $subscription = $this->subscriptions->current();
         $this->subscriptions->next();
         if ($subscription->getSession() == $session) {
             $this->manager->debug("Leaving and unsubscribing: {$subscription->getTopic()}");
             $this->subscriptions->detach($subscription);
         }
     }
     foreach ($this->topics as $topicName => $subscribers) {
         foreach ($subscribers as $key => $subscriber) {
             if ($session == $subscriber) {
                 unset($subscribers[$key]);
                 $this->manager->debug("Removing session from topic list: {$topicName}");
             }
         }
     }
 }
Esempio n. 23
0
 public function __construct($dom)
 {
     $this->alreadyMatched = new SplObjectStorage();
     $matches = new SplObjectStorage();
     if (is_array($dom) || $dom instanceof SplObjectStorage) {
         foreach ($dom as $item) {
             if ($item instanceof DOMNode && $item->nodeType == XML_ELEMENT_NODE) {
                 $matches->attach($item);
             }
         }
         if ($matches->count() > 0) {
             $matches->rewind();
             $this->dom = $matches->current();
         } else {
             $this->dom = NULL;
         }
         $this->matches = $matches;
     } elseif ($dom instanceof DOMDocument) {
         $this->dom = $dom->documentElement;
         $matches->attach($dom->documentElement);
     } elseif ($dom instanceof DOMElement) {
         $this->dom = $dom;
         $matches->attach($dom);
     } elseif ($dom instanceof DOMNodeList) {
         $a = array();
         foreach ($dom as $item) {
             if ($item->nodeType == XML_ELEMENT_NODE) {
                 $matches->attach($item);
                 $a[] = $item;
             }
         }
         $this->dom = $a;
     } else {
         throw new Exception("Unhandled type: " . get_class($dom));
     }
     $this->matches = $matches;
 }
Esempio n. 24
0
 /**
  * Publishes all registered events to their respective event bus.
  */
 protected function publishEvents()
 {
     $this->logger->debug("Publishing events to the event bus");
     if ($this->dispatcherStatus == self::STATUS_DISPATCHING) {
         // this prevents events from overtaking each other
         $this->logger->debug("UnitOfWork is already in the dispatch process. " . "That process will publish events instead. Aborting...");
         return;
     }
     $this->dispatcherStatus = self::STATUS_DISPATCHING;
     $this->eventsToPublish->rewind();
     while ($this->eventsToPublish->valid()) {
         $bus = $this->eventsToPublish->current();
         $events = $this->eventsToPublish->getInfo();
         foreach ($events as $event) {
             $this->logger->debug("Publishing event [{event}] to event bus [{bus}]", array('event' => $event->getPayloadType(), 'bus' => get_class($bus)));
         }
         // clear and send
         $this->eventsToPublish->setInfo(array());
         $bus->publish($events);
         $this->eventsToPublish->next();
     }
     $this->logger->debug("All events successfully published.");
     $this->dispatcherStatus = self::STATUS_READY;
 }
 function current()
 {
     echo __METHOD__ . "(" . parent::current()->getName() . ")\n";
     return parent::current();
 }
Esempio n. 26
0
 /**
  * @return self
  */
 public function current()
 {
     return parent::current();
 }
 public function current()
 {
     $this->initialize();
     return parent::current();
 }
 /**
  * Return the current element
  *
  * @link http://php.net/manual/en/iterator.current.php
  * @return ResourceInterface
  * @since 5.0.0
  */
 public function current()
 {
     return $this->collection->current();
 }
 /**
  * Create a new event handler.
  */
 public function __construct($dom)
 {
     $this->alreadyMatched = new \SplObjectStorage();
     $matches = new \SplObjectStorage();
     // Array of DOMElements
     if (is_array($dom) || $dom instanceof \SplObjectStorage) {
         //$matches = array();
         foreach ($dom as $item) {
             if ($item instanceof \DOMNode && $item->nodeType == XML_ELEMENT_NODE) {
                 //$matches[] = $item;
                 $matches->attach($item);
             }
         }
         //$this->dom = count($matches) > 0 ? $matches[0] : NULL;
         if ($matches->count() > 0) {
             $matches->rewind();
             $this->dom = $matches->current();
         } else {
             //throw new Exception("Setting DOM to Null");
             $this->dom = NULL;
         }
         $this->matches = $matches;
     } elseif ($dom instanceof \DOMDocument) {
         $this->dom = $dom->documentElement;
         $matches->attach($dom->documentElement);
     } elseif ($dom instanceof \DOMElement) {
         $this->dom = $dom;
         $matches->attach($dom);
     } elseif ($dom instanceof \DOMNodeList) {
         $a = array();
         // Not sure why we are doing this....
         foreach ($dom as $item) {
             if ($item->nodeType == XML_ELEMENT_NODE) {
                 $matches->attach($item);
                 $a[] = $item;
             }
         }
         $this->dom = $a;
     } else {
         throw new \QueryPath\Exception("Unhandled type: " . get_class($dom));
     }
     $this->matches = $matches;
 }
Esempio n. 30
0
File: Map.php Progetto: ablyler/phan
 /**
  * We redefine the current value to the current value rather
  * than the current key
  */
 public function current()
 {
     return $this->offsetGet(parent::current());
 }