-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[shopsys] move ready category seo mix from project-base to packages (…
…#3494)
- Loading branch information
Showing
24 changed files
with
1,467 additions
and
191 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrontendApiBundle\Model\Brand; | ||
|
||
use GraphQL\Executor\Promise\Promise; | ||
use GraphQL\Executor\Promise\PromiseAdapter; | ||
use Shopsys\FrameworkBundle\Component\Domain\Domain; | ||
use Shopsys\FrameworkBundle\Model\Product\Brand\BrandFacade; | ||
|
||
class BrandsBatchLoader | ||
{ | ||
/** | ||
* @param \GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter | ||
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain | ||
* @param \Shopsys\FrameworkBundle\Model\Product\Brand\BrandFacade $brandFacade | ||
*/ | ||
public function __construct( | ||
protected readonly PromiseAdapter $promiseAdapter, | ||
protected readonly Domain $domain, | ||
protected readonly BrandFacade $brandFacade, | ||
) { | ||
} | ||
|
||
/** | ||
* @param int[] $brandIds | ||
* @return \GraphQL\Executor\Promise\Promise | ||
*/ | ||
public function loadByIds(array $brandIds): Promise | ||
{ | ||
return $this->promiseAdapter->all($this->brandFacade->getByIds($brandIds, $this->domain->getCurrentDomainConfig())); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrontendApiBundle\Model\Category; | ||
|
||
use GraphQL\Executor\Promise\Promise; | ||
use GraphQL\Executor\Promise\PromiseAdapter; | ||
use Shopsys\FrameworkBundle\Component\Domain\Domain; | ||
use Shopsys\FrameworkBundle\Component\Router\FriendlyUrl\FriendlyUrlFacade; | ||
use Shopsys\FrameworkBundle\Model\CategorySeo\ReadyCategorySeoMix; | ||
use Shopsys\FrameworkBundle\Model\CategorySeo\ReadyCategorySeoMixFacade; | ||
|
||
class ReadyCategorySeoMixBatchLoader | ||
{ | ||
/** | ||
* @param \GraphQL\Executor\Promise\PromiseAdapter $promiseAdapter | ||
* @param \Shopsys\FrameworkBundle\Model\CategorySeo\ReadyCategorySeoMixFacade $readyCategorySeoMixFacade | ||
* @param \Shopsys\FrameworkBundle\Component\Domain\Domain $domain | ||
* @param \Shopsys\FrameworkBundle\Component\Router\FriendlyUrl\FriendlyUrlFacade $friendlyUrlFacade | ||
*/ | ||
public function __construct( | ||
protected readonly PromiseAdapter $promiseAdapter, | ||
protected readonly ReadyCategorySeoMixFacade $readyCategorySeoMixFacade, | ||
protected readonly Domain $domain, | ||
protected readonly FriendlyUrlFacade $friendlyUrlFacade, | ||
) { | ||
} | ||
|
||
/** | ||
* @param int[] $categoryIds | ||
* @return \GraphQL\Executor\Promise\Promise | ||
*/ | ||
public function loadByCategoryIds(array $categoryIds): Promise | ||
{ | ||
$allReadyCategorySeoMixes = $this->readyCategorySeoMixFacade->getAllIndexedByCategoryId($categoryIds, $this->domain->getCurrentDomainConfig()); | ||
|
||
$result = []; | ||
|
||
foreach ($allReadyCategorySeoMixes as $readyCategorySeoMixes) { | ||
$result[] = array_map( | ||
fn (ReadyCategorySeoMix $readyCategorySeoMix) => [ | ||
'name' => $readyCategorySeoMix->getH1(), | ||
'slug' => '/' . $this->friendlyUrlFacade->getMainFriendlyUrlSlug( | ||
$this->domain->getId(), | ||
'front_category_seo', | ||
$readyCategorySeoMix->getId(), | ||
), | ||
], | ||
$readyCategorySeoMixes, | ||
); | ||
} | ||
|
||
return $this->promiseAdapter->all($result); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
src/Model/Product/BatchLoad/ProductBatchLoadByEntityData.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrontendApiBundle\Model\Product\BatchLoad; | ||
|
||
use Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterData; | ||
|
||
class ProductBatchLoadByEntityData | ||
{ | ||
/** | ||
* @param string $id | ||
* @param int $entityId | ||
* @param string $entityClass | ||
* @param int $limit | ||
* @param int $offset | ||
* @param string $orderingModeId | ||
* @param \Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterData $productFilterData | ||
* @param string $search | ||
*/ | ||
public function __construct( | ||
protected readonly string $id, | ||
protected readonly int $entityId, | ||
protected readonly string $entityClass, | ||
protected readonly int $limit, | ||
protected readonly int $offset, | ||
protected readonly string $orderingModeId, | ||
protected readonly ProductFilterData $productFilterData, | ||
protected readonly string $search = '', | ||
) { | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getEntityId(): int | ||
{ | ||
return $this->entityId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getEntityClass(): string | ||
{ | ||
return $this->entityClass; | ||
} | ||
|
||
/** | ||
* @return \Shopsys\FrameworkBundle\Model\Product\Filter\ProductFilterData | ||
*/ | ||
public function getProductFilterData(): ProductFilterData | ||
{ | ||
return $this->productFilterData; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getLimit(): int | ||
{ | ||
return $this->limit; | ||
} | ||
|
||
/** | ||
* @return int | ||
*/ | ||
public function getOffset(): int | ||
{ | ||
return $this->offset; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getOrderingModeId(): string | ||
{ | ||
return $this->orderingModeId; | ||
} | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getSearch(): string | ||
{ | ||
return $this->search; | ||
} | ||
} |
Oops, something went wrong.