-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
104 additions
and
18 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
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
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
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
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
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,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <info@thelia.net> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FlexyBundle\Twig\Layout; | ||
|
||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
use Symfony\UX\TwigComponent\Attribute\ExposeInTemplate; | ||
use TwigEngine\Service\DataAccess\DataAccessService; | ||
|
||
#[AsTwigComponent(template: 'components/Layout/CategoryProduct/CategoryProduct.html.twig')] | ||
class CategoryProduct | ||
{ | ||
private DataAccessService $dataAccessService; | ||
public string $categoryId; | ||
public string $page; | ||
|
||
#[ExposeInTemplate] | ||
private array $products; | ||
|
||
public function __construct(DataAccessService $dataAccessService) | ||
{ | ||
$this->dataAccessService = $dataAccessService; | ||
} | ||
|
||
public function getProducts(): array | ||
{ | ||
$this->products = $this->dataAccessService->resources('/api/front/products', [ | ||
'productCategories.category.id' => $this->categoryId, | ||
'itemsPerPage' => 9, | ||
'page' => $this->page, | ||
]); | ||
|
||
return $this->products; | ||
} | ||
} |
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,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Thelia package. | ||
* http://www.thelia.net | ||
* | ||
* (c) OpenStudio <info@thelia.net> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace FlexyBundle\Twig\Layout; | ||
|
||
use Symfony\UX\TwigComponent\Attribute\AsTwigComponent; | ||
use TwigEngine\Service\DataAccess\DataAccessService; | ||
|
||
#[AsTwigComponent(template: '@components/Layout/SimilarContent/SimilarContent.html.twig')] | ||
class SimilarContent | ||
{ | ||
public array $similarContents; | ||
|
||
public function __construct(private DataAccessService $dataAccessService) | ||
{ | ||
} | ||
|
||
public function mount(array $similarContents = []): void | ||
{ | ||
if (\count($similarContents) > 0) { | ||
$this->similarContents = $similarContents; | ||
} | ||
} | ||
|
||
public function similarContents(): array | ||
{ | ||
$contents = $this->dataAccessService->resources('/api/front/contents', [ | ||
'itemsPerPage' => 3, | ||
]); | ||
|
||
return array_map(function ($item) { | ||
return [ | ||
'title' => $item['i18ns']['title'], | ||
'date' => $item['createdAt'], | ||
'url' => '#', | ||
'img' => [ | ||
'url' => '/images/placeholder.webp', | ||
'alt' => $item['i18ns']['title'], | ||
], | ||
]; | ||
}, $contents); | ||
} | ||
} |