本文整理汇总了PHP中Akeneo\Bundle\BatchBundle\Entity\StepExecution::incrementSummaryInfo方法的典型用法代码示例。如果您正苦于以下问题:PHP StepExecution::incrementSummaryInfo方法的具体用法?PHP StepExecution::incrementSummaryInfo怎么用?PHP StepExecution::incrementSummaryInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Akeneo\Bundle\BatchBundle\Entity\StepExecution
的用法示例。
在下文中一共展示了StepExecution::incrementSummaryInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: write
public function write(array $items)
{
foreach ($items as $product) {
$this->productManager->save($product);
$this->stepExecution->incrementSummaryInfo('save');
}
}
示例2: process
public function process($item)
{
$sku = (string) $item['sku'];
$attribute = $this->productManager->getIdentifierAttribute();
$product = $this->productManager->findByIdentifier($sku);
// if (!$product) {
// $product = $this->productManager->createProduct();
// $value = $this->productManager->createProductValue();
// $value->setAttribute($attribute);
// $value->setData($sku);
// $product->addValue($value);
// $this->stepExecution->incrementSummaryInfo('create');
// return $product;
// } else {
if (!$product) {
$data = current((array) $item);
$this->stepExecution->incrementSummaryInfo('skip');
throw new InvalidItemException(sprintf('Skip the existing %s product', $sku), $data);
} else {
$product_tab = array();
$product_tab[] = $product;
$this->productUpdater->setValue($product_tab, 'price', [['data' => (string) $item['price'], 'currency' => (string) $item['currency']]]);
return $product;
}
// }
}
示例3: incrementCount
/**
* @param object $item
*/
protected function incrementCount($item)
{
if ($item->getId()) {
$this->stepExecution->incrementSummaryInfo('update');
} else {
$this->stepExecution->incrementSummaryInfo('create');
}
}
示例4:
function it_increments_summary_info(StepExecution $stepExecution, ProductInterface $product1, ProductInterface $product2)
{
$product1->getId()->willReturn('45');
$product2->getId()->willReturn(null);
$stepExecution->incrementSummaryInfo('update')->shouldBeCalled();
$stepExecution->incrementSummaryInfo('create')->shouldBeCalled();
$this->setStepExecution($stepExecution);
$this->write([$product1, $product2]);
}
示例5: write
public function write(array $items)
{
if (null === $this->file) {
$this->file = new \SplFileObject($this->filePath, "w");
}
foreach ($items as $product) {
$this->file->fputcsv($product);
$this->stepExecution->incrementSummaryInfo('write');
}
}
示例6: incrementCount
/**
* @param array $objects
*/
protected function incrementCount(array $objects)
{
foreach ($objects as $object) {
if ($object->getId()) {
$this->stepExecution->incrementSummaryInfo('process');
} else {
$this->stepExecution->incrementSummaryInfo('create');
}
}
}
示例7: read
/**
* {@inheritdoc}
*/
public function read()
{
if (!$this->cursor) {
$this->cursor = $this->getQuery()->iterate();
}
if ($data = $this->cursor->next()) {
$this->stepExecution->incrementSummaryInfo('read');
return $data;
}
}
示例8: read
/**
* {@inheritdoc}
*/
public function read()
{
if (null === $this->results) {
$items = $this->readItems();
$this->results = new \ArrayIterator($items);
}
if (null !== ($result = $this->results->current())) {
$this->results->next();
$this->stepExecution->incrementSummaryInfo('read');
}
return $result;
}
示例9: read
/**
* {@inheritdoc}
*/
public function read()
{
if (!$this->isExecuted) {
$this->isExecuted = true;
$this->results = $this->getResults();
}
if (null !== ($result = $this->results->current())) {
$this->results->next();
$this->stepExecution->incrementSummaryInfo('read');
}
return $result;
}
示例10: read
public function read()
{
if (!isset($this->iterator)) {
$this->initializeIterator();
}
if (!$this->iterator->valid()) {
return null;
}
$current = $this->iterator->current();
if ($this->stepExecution) {
$this->stepExecution->incrementSummaryInfo('read');
}
$this->iterator->next();
return $current;
}
示例11: read
public function read()
{
if (!isset($this->iterator)) {
$this->initializeIterator();
}
if (!$this->iterator->valid()) {
return null;
}
$current = $this->iterator->current();
if ($this->stepExecution) {
$this->stepExecution->incrementSummaryInfo('read');
}
$this->iterator->next();
return $this->convertNumericIdentifierToString($current);
}
示例12: read
/**
* {@inheritdoc}
*/
public function read()
{
if (null === $this->csv) {
if (mime_content_type($this->filePath) === 'application/zip') {
$this->extractZipArchive();
}
$this->csv = new \SplFileObject($this->filePath);
$this->csv->setFlags(\SplFileObject::READ_CSV | \SplFileObject::READ_AHEAD | \SplFileObject::SKIP_EMPTY | \SplFileObject::DROP_NEW_LINE);
$this->csv->setCsvControl($this->delimiter, $this->enclosure, $this->escape);
$this->fieldNames = $this->csv->fgetcsv();
}
$data = $this->csv->fgetcsv();
if (false !== $data) {
if ($data === array(null) || $data === null) {
return null;
}
if ($this->stepExecution) {
$this->stepExecution->incrementSummaryInfo('read');
}
if (count($this->fieldNames) !== count($data)) {
throw new InvalidItemException('pim_base_connector.steps.csv_reader.invalid_item_columns_count', $data, array('%totalColumnsCount%' => count($this->fieldNames), '%itemColumnsCount%' => count($data), '%csvPath%' => $this->csv->getRealPath(), '%lineno%' => $this->csv->key()));
}
$data = array_combine($this->fieldNames, $data);
} else {
throw new \RuntimeException('An error occured while reading the csv.');
}
return $data;
}
示例13: read
/**
* {@inheritdoc}
*/
public function read()
{
$configuration = $this->getJobConfiguration();
if (!$this->isExecuted) {
$this->isExecuted = true;
$this->families = $this->getFamilies($configuration['filters']);
}
$result = $this->families->current();
if (!empty($result)) {
$this->stepExecution->incrementSummaryInfo('read');
$this->families->next();
} else {
$result = null;
}
return $result;
}
示例14: setItemErrors
/**
* Sets errors on items
*
* @param array $item
* @param array $errors
*
* @throws InvalidItemException
*/
protected function setItemErrors(array $item, array $errors)
{
if ($this->stepExecution) {
$this->stepExecution->incrementSummaryInfo('skip');
}
throw new InvalidItemException(implode("\n", $this->getErrorMessages($errors)), $item);
}
示例15: incrementSkippedProductsCount
/**
* @param int $nbSkippedProducts
* @param array $skippedMessages
*/
protected function incrementSkippedProductsCount($nbSkippedProducts, $skippedMessages)
{
$this->stepExecution->incrementSummaryInfo('skip_products', $nbSkippedProducts);
foreach ($skippedMessages as $productIdentifier => $messages) {
$this->stepExecution->addWarning($this->getName(), sprintf('Copy of values to product "%s" skipped.', $productIdentifier), [], $messages);
}
}