/** * buildOperations * * @param BasicOperationCollection $operationCollection * @param array $operationServiceNames * @param Options $operationOptions * @param Options $operationPriorities * * @return void */ protected function buildOperations(BasicOperationCollection $operationCollection, array $operationServiceNames, Options $operationOptions, Options $operationPriorities) { $queue = new \SplPriorityQueue(); $defaultPriority = count($operationServiceNames); foreach ($operationServiceNames as $name => $middlewareService) { // Allows over-riding with nulls if (empty($middlewareService)) { continue; } $priority = $operationPriorities->get($name); if (empty($priority)) { $priority = $defaultPriority; $defaultPriority--; } $queue->insert($name, $priority); } foreach ($queue as $name) { $operationCollection->addOperation($this->buildOperation($name, $this->serviceManager->get($operationServiceNames[$name]), $operationOptions->getOptions($name), $operationPriorities->get($name, 0))); } }