/** * {@inheritdoc} */ public function execute(StepExecutionWarningHandlerInterface $warningHandler = null) { $itemsToWrite = []; $writeCount = 0; $scheduleWrite = false; try { $stopExecution = false; while (!$stopExecution) { try { $readItem = $this->reader->read(); if (null === $readItem) { $stopExecution = true; continue; } } catch (InvalidItemException $e) { $this->handleStepExecutionWarning($this->reader, $e, $warningHandler); continue; } $processedItem = $this->process($readItem, $warningHandler); if (null !== $processedItem) { $itemsToWrite[] = $processedItem; $writeCount++; if (0 === $writeCount % $this->batchSize || $scheduleWrite) { $this->write($itemsToWrite, $warningHandler); $itemsToWrite = []; $scheduleWrite = false; } } if ($this->reader instanceof IteratorBasedReader) { $sourceIterator = $this->reader->getSourceIterator(); if ($sourceIterator instanceof SubordinateReaderInterface && $sourceIterator->writeRequired()) { $scheduleWrite = true; } } } if (count($itemsToWrite) > 0) { $this->write($itemsToWrite, $warningHandler); } $this->ensureResourcesReleased($warningHandler); } catch (\Exception $error) { $this->ensureResourcesReleased($warningHandler); throw $error; } }
/** * @param ContextRegistry $contextRegistry * @param ManagerRegistry $registry * @param OwnershipMetadataProvider $ownershipMetadata */ public function __construct(ContextRegistry $contextRegistry, ManagerRegistry $registry, OwnershipMetadataProvider $ownershipMetadata) { parent::__construct($contextRegistry); $this->ownershipMetadata = $ownershipMetadata; $this->registry = $registry; }
/** * @param ContextRegistry $contextRegistry * @param LoggerStrategy $logger * @param ConnectorContextMediator $contextMediator */ public function __construct(ContextRegistry $contextRegistry, LoggerStrategy $logger, ConnectorContextMediator $contextMediator) { parent::__construct($contextRegistry); $this->logger = $logger; $this->contextMediator = $contextMediator; }
/** * @param ContextRegistry $contextRegistry * @param DoctrineHelper $doctrineHelper * @param string $channelClassName */ public function __construct(ContextRegistry $contextRegistry, DoctrineHelper $doctrineHelper, $channelClassName) { parent::__construct($contextRegistry); $this->doctrineHelper = $doctrineHelper; $this->channelClassName = $channelClassName; }
/** * @param ContextRegistry $contextRegistry * @param TemplateManager $templateManager */ public function __construct(ContextRegistry $contextRegistry, TemplateManager $templateManager) { parent::__construct($contextRegistry); $this->templateManager = $templateManager; }