Skip to content

Commit

Permalink
Fix config standard
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreGauthier committed Jan 22, 2024
1 parent 2fd51a7 commit 00f1bf5
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 12 deletions.
3 changes: 1 addition & 2 deletions src/Indexer/CategoryIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
use Sylius\Component\Taxonomy\Repository\TaxonRepositoryInterface;

/**
* Class CategoryIndexer
* Class CategoryIndexer.
*
* @package Gally
* @author Stephan Hochdörfer <S.Hochdoerfer@bitexpert.de>, Gally Team <elasticsuite@smile.fr>
* @copyright 2022-present Smile
* @license Open Software License v. 3.0 (OSL-3.0)
Expand Down
3 changes: 1 addition & 2 deletions src/Indexer/ProductIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
use Sylius\Component\Resource\Repository\RepositoryInterface;

/**
* Class ProductIndexer
* Class ProductIndexer.
*
* @package Gally
* @author Stephan Hochdörfer <S.Hochdoerfer@bitexpert.de>, Gally Team <elasticsuite@smile.fr>
* @copyright 2022-present Smile
* @license Open Software License v. 3.0 (OSL-3.0)
Expand Down
7 changes: 4 additions & 3 deletions src/Synchronizer/AbstractSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ protected function createOrUpdateEntity(ModelInterface $entity): ModelInterface
protected function getEntityFromApi(ModelInterface|string $entity): ?ModelInterface
{
if ($this->allEntityHasBeenFetch) {
return $this->entityByCode[is_string($entity) ? $entity : $this->getIdentity($entity)] ?? null;
return $this->entityByCode[\is_string($entity) ? $entity : $this->getIdentity($entity)] ?? null;
}

return $this->fetchEntity($entity);
Expand All @@ -152,12 +152,12 @@ protected function validateEntity(ModelInterface $entity): void

protected function addEntityToBulk(ModelInterface $entity): void
{
if ($this->bulkEntityMethod === null) {
if (null === $this->bulkEntityMethod) {
throw new \Exception(sprintf('The entity %s doesn\'t have a bulk method.', $this->getEntityClass()));
}

$this->currentBatch[] = $entity;
$this->currentBatchSize++;
++$this->currentBatchSize;
if ($this->currentBatchSize >= self::BATCH_SIZE) {
$this->runBulk();
}
Expand All @@ -178,6 +178,7 @@ protected function runBulk(): void
protected function getAllEntityCodes(): array
{
$this->fetchEntities();

return array_keys($this->entityByCode);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Synchronizer/CatalogSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function __construct(
public function getIdentity(ModelInterface $entity): string
{
/** @var Catalog $entity */
return "catalog" . $entity->getCode();
return 'catalog' . $entity->getCode();
}

public function synchronizeAll(): void
Expand All @@ -78,7 +78,7 @@ public function synchronizeAll(): void
foreach (array_flip($this->localizedCatalogCodes) as $localizedCatalogCode) {
/** @var LocalizedCatalogCatalogRead $localizedCatalog */
$localizedCatalog = $this->localizedCatalogSynchronizer->getEntityFromApi($localizedCatalogCode);
$this->localizedCatalogSynchronizer->deleteEntity($localizedCatalog->getId() );
$this->localizedCatalogSynchronizer->deleteEntity($localizedCatalog->getId());
}

foreach (array_flip($this->catalogCodes) as $catalogCode) {
Expand Down
1 change: 1 addition & 0 deletions src/Synchronizer/LocalizedCatalogSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public function getLocalizedCatalogByLocale(string $localeCode): array
public function getByIdentity(string $identifier): ?ModelInterface
{
$this->fetchEntities();

return $this->entityByCode[$identifier] ?? null;
}
}
4 changes: 2 additions & 2 deletions src/Synchronizer/MetadataSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

namespace Gally\SyliusPlugin\Synchronizer;

use Gally\Rest\Model\Metadata;
use Gally\Rest\Model\MetadataMetadataRead;
use Gally\Rest\Model\MetadataMetadataWrite;
use Gally\Rest\Model\ModelInterface;
Expand All @@ -28,12 +27,13 @@ public function synchronizeAll(): void
public function synchronizeItem(array $params): ?ModelInterface
{
$this->fetchEntities();

return $this->createOrUpdateEntity(new MetadataMetadataWrite(['entity' => $params['entity']]));
}

public function getIdentity(ModelInterface $entity): string
{
/** @var MetadataMetadataRead $entity */
/** @var MetadataMetadataRead $entity */
return $entity->getEntity();
}
}
2 changes: 1 addition & 1 deletion src/Synchronizer/SourceFieldSynchronizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

use Doctrine\Common\Collections\Collection;
use Gally\Rest\Model\LocalizedCatalog;
use Gally\Rest\Model\Metadata;
use Gally\Rest\Model\MetadataMetadataRead;
use Gally\Rest\Model\ModelInterface;
use Gally\Rest\Model\SourceFieldSourceFieldRead;
Expand Down Expand Up @@ -224,6 +223,7 @@ public static function getGallyType(string $type): string
public function getEntityByCode(MetadataMetadataRead $metadata, string $code): ?ModelInterface
{
$key = '/metadata/' . $metadata->getId() . $code;

return $this->entityByCode[$key] ?? null;
}

Expand Down

0 comments on commit 00f1bf5

Please sign in to comment.