batchUpdate example

$this->getContainer()
            ->get(DefinitionInstanceRegistry::class)
            ->register($definition);

        $treeUpdater = new TreeUpdater(
            $this->getContainer()->get(DefinitionInstanceRegistry::class),
            $this->getContainer()->get(Connection::class)
        );

        $context = Context::createDefaultContext();

        $treeUpdater->batchUpdate($ids->getList(['r', 'a', 'b', 'aa', 'ab']), 'test_tree', $context);

        $r = $this->fetch($ids->getBytes('r'), 'test_tree');
        static::assertSame('1', $r['test_level']);
        static::assertNull($r['test_path']);

        $a = $this->fetch($ids->getBytes('a'), 'test_tree');
        static::assertSame('2', $a['test_level']);
        static::assertSame('|' . $ids->get('r') . '|', $a['test_path']);

        $b = $this->fetch($ids->getBytes('b'), 'test_tree');
        static::assertSame('2', $b['test_level']);
        

        $pluginManager = $this->container->get(InstallerService::class);
        if (!$input->getOption('no-refresh')) {
            $pluginManager->refreshPluginList();
            $output->writeln('Successfully refreshed');
        }

        $pluginNames = $input->getArgument('plugin');

        $batchUpdate = $input->getOption('batch');
        if (!empty($batchUpdate)) {
            return $this->batchUpdate($pluginManager$batchUpdate$output);
        }

        if (!empty($pluginNames)) {
            foreach ($pluginNames as $pluginName) {
                $this->updatePlugin($pluginManager$pluginName$input$output);
            }

            return 0;
        }

        $output->writeln(sprintf('Specify either a plugin name or use the --batch option to update several plugins at once'));

        
$ids[] = $payload['parentId'];
                }
                $idsWithChangedParentIds[] = $payload['id'];
            }
        }

        if (empty($ids)) {
            return null;
        }

        if ($idsWithChangedParentIds !== []) {
            $this->treeUpdater->batchUpdate(
                $idsWithChangedParentIds,
                CategoryDefinition::ENTITY_NAME,
                $event->getContext()
            );
        }

        $children = $this->fetchChildren($ids$event->getContext()->getVersionId());

        $ids = array_unique(array_merge($ids$children));

        return new CategoryIndexingMessage(array_values($ids), null, $event->getContext(), \count($ids) > 20);
    }


        $idsWithChangedParentIds = [];
        foreach ($mediaFolderEvent->getWriteResults() as $result) {
            $payload = $result->getPayload();
            if (\array_key_exists('parentId', $payload)) {
                $idsWithChangedParentIds[] = $payload['id'];
            }
        }

        if ($idsWithChangedParentIds !== []) {
            $this->treeUpdater->batchUpdate(
                $idsWithChangedParentIds,
                MediaFolderDefinition::ENTITY_NAME,
                $event->getContext()
            );
        }

        $updates = array_values(array_merge($updates$this->fetchChildren($updates)$this->getParentIds($updates)));

        return new MediaIndexingMessage($updates, null, $event->getContext());
    }

    
Home | Imprint | This part of the site doesn't use cookies.