Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/660-task-custom-reports-tree-lis…
Browse files Browse the repository at this point in the history
…ting-endpoint' into 660-task-custom-reports-tree-listing-endpoint

# Conflicts:
#	src/CustomReport/Repository/CustomReportRepository.php
  • Loading branch information
mcop1 committed Jan 9, 2025
2 parents 5e71d40 + 7ca8fcf commit 8fa9354
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/CustomReport/Controller/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function getCustomReports(): JsonResponse
{
return $this->jsonResponse(
[
'items' => $this->customReportService->loadForCurrentUser()
'items' => $this->customReportService->loadForCurrentUser(),
]
);
}
Expand Down
8 changes: 2 additions & 6 deletions src/CustomReport/Hydrator/CustomReportHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@

namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Hydrator;

use Pimcore\Bundle\CustomReportsBundle\Tool\Config\Listing;
use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityService;
use Pimcore\Model\User;


/**
* @internal
*/
final readonly class CustomReportHydrator implements CustomReportHydratorInterface
{
public function hydrate(array $reports): array {
public function hydrate(array $reports): array
{
$hydratedReports = [];

foreach ($reports as $report) {
Expand Down
5 changes: 1 addition & 4 deletions src/CustomReport/Hydrator/CustomReportHydratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/


namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Hydrator;

use Pimcore\Model\User;

/**
* @internal
*/
interface CustomReportHydratorInterface
{
public function hydrate(array $reports): array;
}
}
9 changes: 4 additions & 5 deletions src/CustomReport/Repository/CustomReportRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,14 @@
use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityServiceInterface;
use Pimcore\Model\User;


/**
* @internal
*/
final readonly class CustomReportRepository implements CustomReportRepositoryInterface
{
public function __construct(
private SecurityServiceInterface $securityService
)
{
) {
}

public function loadForUser(User $user): array {
Expand All @@ -41,12 +39,13 @@ public function loadForUser(User $user): array {
);
}

public function loadForCurrentUser(): array {
public function loadForCurrentUser(): array
{
/** @var User $currentUser */
$currentUser = $this->securityService->getCurrentUser();

return $this->loadForUser(
$currentUser
$currentUser
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/


namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Repository;

use Pimcore\Model\User;
Expand All @@ -25,6 +24,6 @@
interface CustomReportRepositoryInterface
{
public function loadForUser(User $user): array;
public function loadForCurrentUser(): array;

}
public function loadForCurrentUser(): array;
}
2 changes: 1 addition & 1 deletion src/CustomReport/Schema/CustomReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Schema;

use OpenApi\Attributes\Items;
use OpenApi\Attributes\Property;
use OpenApi\Attributes\Schema;
use Pimcore\Bundle\StudioBackendBundle\Util\Schema\AdditionalAttributesInterface;
Expand Down Expand Up @@ -51,6 +50,7 @@ public function __construct(
) {

}

public function getName(): string
{
return $this->name;
Expand Down
11 changes: 3 additions & 8 deletions src/CustomReport/Service/CustomReportService.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,8 @@

namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Service;

use Pimcore\Bundle\CustomReportsBundle\Tool\Config\Listing;
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Hydrator\CustomReportHydrator;
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Hydrator\CustomReportHydratorInterface;
use Pimcore\Bundle\StudioBackendBundle\CustomReport\Repository\CustomReportRepositoryInterface;
use Pimcore\Bundle\StudioBackendBundle\Security\Service\SecurityService;
use Pimcore\Model\User;


/**
* @internal
Expand All @@ -32,11 +27,11 @@
public function __construct(
private CustomReportHydratorInterface $customReportHydrator,
private CustomReportRepositoryInterface $customReportRepository,
)
{
) {
}

public function loadForCurrentUser(): array {
public function loadForCurrentUser(): array
{
return $this->customReportHydrator->hydrate(
$this->customReportRepository->loadForCurrentUser()
);
Expand Down
5 changes: 1 addition & 4 deletions src/CustomReport/Service/CustomReportServiceInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,12 @@
* @license http://www.pimcore.org/license GPLv3 and PCL
*/


namespace Pimcore\Bundle\StudioBackendBundle\CustomReport\Service;

use Pimcore\Model\User;

/**
* @internal
*/
interface CustomReportServiceInterface
{
public function loadForCurrentUser(): array;
}
}

0 comments on commit 8fa9354

Please sign in to comment.