-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/1.x' into 160-tags-in-element-editor
# Conflicts: # src/DependencyInjection/PimcoreStudioBackendExtension.php
- Loading branch information
Showing
12 changed files
with
448 additions
and
1 deletion.
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,22 @@ | ||
services: | ||
_defaults: | ||
autowire: true | ||
autoconfigure: true | ||
public: false | ||
|
||
# controllers are imported separately to make sure they're public | ||
# and have a tag that allows actions to type-hint services | ||
Pimcore\Bundle\StudioBackendBundle\Schedule\Controller\: | ||
resource: '../src/Schedule/Controller' | ||
public: true | ||
tags: [ 'controller.service_arguments' ] | ||
|
||
Pimcore\Bundle\StudioBackendBundle\Schedule\Service\ScheduleServiceInterface: | ||
class: Pimcore\Bundle\StudioBackendBundle\Schedule\Service\ScheduleService | ||
|
||
Pimcore\Bundle\StudioBackendBundle\Schedule\Repository\ScheduleRepositoryInterface: | ||
class: Pimcore\Bundle\StudioBackendBundle\Schedule\Repository\ScheduleRepository | ||
|
||
Pimcore\Bundle\StudioBackendBundle\Schedule\Hydrator\ScheduleHydratorInterface: | ||
class: Pimcore\Bundle\StudioBackendBundle\Schedule\Hydrator\ScheduleHydrator | ||
|
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,79 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\Schedule\Controller\Element; | ||
|
||
use OpenApi\Attributes\Get; | ||
use Pimcore\Bundle\StudioBackendBundle\Controller\AbstractApiController; | ||
use Pimcore\Bundle\StudioBackendBundle\Note\Attributes\Response\Property\NoteCollection; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Content\ItemsJson; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\ElementTypeParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Parameters\Path\IdParameter; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\Content\CollectionJson; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\DefaultResponses; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attributes\Response\SuccessResponse; | ||
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Config\Tags; | ||
use Pimcore\Bundle\StudioBackendBundle\Schedule\Schema\Schedule; | ||
use Pimcore\Bundle\StudioBackendBundle\Schedule\Service\ScheduleServiceInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Constants\HttpResponseCodes; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\PaginatedResponseTrait; | ||
use Symfony\Component\HttpFoundation\JsonResponse; | ||
use Symfony\Component\Routing\Attribute\Route; | ||
use Symfony\Component\Serializer\SerializerInterface; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class CollectionController extends AbstractApiController | ||
{ | ||
use PaginatedResponseTrait; | ||
|
||
public function __construct( | ||
SerializerInterface $serializer, | ||
private readonly ScheduleServiceInterface $scheduleService | ||
) | ||
{ | ||
parent::__construct($serializer); | ||
} | ||
|
||
#[Route('/schedules/{elementType}/{id}', name: 'pimcore_studio_api_get_element_schedules', methods: ['GET'])] | ||
#[Get( | ||
path: self::API_PATH . '/schedules/{elementType}/{id}', | ||
operationId: 'getSchedulesForElementByTypeAndId', | ||
summary: 'Get schedules for an element', | ||
security: self::SECURITY_SCHEME, | ||
tags: [Tags::Schedule->name] | ||
)] | ||
#[ElementTypeParameter] | ||
#[IdParameter(type: 'element')] | ||
#[SuccessResponse( | ||
description: 'Paginated schedules', | ||
content: new ItemsJson(Schedule::class) | ||
)] | ||
#[DefaultResponses([ | ||
HttpResponseCodes::UNAUTHORIZED, | ||
HttpResponseCodes::NOT_FOUND | ||
])] | ||
public function getSchedules( | ||
string $elementType, | ||
int $id | ||
): JsonResponse | ||
{ | ||
$tasks = $this->scheduleService->listSchedules($elementType, $id); | ||
|
||
return $this->jsonResponse(['items' => $tasks]); | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\Schedule\Event; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\Event\AbstractPreResponseEvent; | ||
use Pimcore\Bundle\StudioBackendBundle\Schedule\Schema\Schedule; | ||
|
||
final class ScheduleEvent extends AbstractPreResponseEvent | ||
{ | ||
public const EVENT_NAME = 'pre_response.schedule'; | ||
public function __construct( | ||
private readonly Schedule $schedule | ||
) | ||
{ | ||
parent::__construct($schedule); | ||
} | ||
|
||
/** | ||
* Use this to get additional infos out of the response object | ||
*/ | ||
public function getSchedule(): Schedule | ||
{ | ||
return $this->schedule; | ||
} | ||
} |
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,39 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\Schedule\Hydrator; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\Schedule\Schema\Schedule; | ||
use Pimcore\Model\Schedule\Task; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class ScheduleHydrator implements ScheduleHydratorInterface | ||
{ | ||
public function hydrate(Task $task): Schedule | ||
{ | ||
return new Schedule( | ||
$task->getId(), | ||
$task->getCtype(), | ||
$task->getDate(), | ||
$task->getAction(), | ||
$task->getVersion(), | ||
$task->getActive(), | ||
$task->getUserId() | ||
); | ||
} | ||
} |
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,28 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\Schedule\Hydrator; | ||
|
||
use Pimcore\Bundle\StudioBackendBundle\Schedule\Schema\Schedule; | ||
use Pimcore\Model\Schedule\Task; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
interface ScheduleHydratorInterface | ||
{ | ||
public function hydrate(Task $task): Schedule; | ||
} |
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,40 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\Schedule\Repository; | ||
|
||
use Pimcore\Bundle\StaticResolverBundle\Models\Element\ServiceResolverInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\Exception\ElementNotFoundException; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\ElementProviderTrait; | ||
use Pimcore\Model\Schedule\Task; | ||
|
||
final readonly class ScheduleRepository implements ScheduleRepositoryInterface | ||
{ | ||
use ElementProviderTrait; | ||
|
||
public function __construct(private ServiceResolverInterface $serviceResolver) | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @return array<int, Task> | ||
*/ | ||
public function listSchedules(string $elementType, int $id): array | ||
{ | ||
return $this->getElement($this->serviceResolver, $elementType, $id)->getScheduledTasks(); | ||
} | ||
} |
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,22 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\Schedule\Repository; | ||
|
||
interface ScheduleRepositoryInterface | ||
{ | ||
public function listSchedules(string $elementType, int $id): array; | ||
} |
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,88 @@ | ||
<?php | ||
declare(strict_types=1); | ||
|
||
/** | ||
* Pimcore | ||
* | ||
* This source file is available under two different licenses: | ||
* - GNU General Public License version 3 (GPLv3) | ||
* - Pimcore Commercial License (PCL) | ||
* Full copyright and license information is available in | ||
* LICENSE.md which is distributed with this source code. | ||
* | ||
* @copyright Copyright (c) Pimcore GmbH (http://www.pimcore.org) | ||
* @license http://www.pimcore.org/license GPLv3 and PCL | ||
*/ | ||
|
||
namespace Pimcore\Bundle\StudioBackendBundle\Schedule\Schema; | ||
|
||
use OpenApi\Attributes\Property; | ||
use OpenApi\Attributes\Schema; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Schema\AdditionalAttributesInterface; | ||
use Pimcore\Bundle\StudioBackendBundle\Util\Traits\AdditionalAttributesTrait; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
#[Schema( | ||
title: 'Schedule', | ||
type: 'object' | ||
)] | ||
final class Schedule implements AdditionalAttributesInterface | ||
{ | ||
use AdditionalAttributesTrait; | ||
|
||
public function __construct( | ||
#[Property(description: 'id', type: 'integer', example: 666)] | ||
private readonly int $id, | ||
#[Property(description: 'ctype', type: 'string', example: 'Type of element')] | ||
private readonly string $ctype, | ||
#[Property(description: 'Date of schedule', type: 'integer', example: 1634025600)] | ||
private readonly int $date, | ||
#[Property(description: 'Action', type: 'string', enum: ['publish-version', 'delete'])] | ||
private readonly ?string $action, | ||
#[Property(description: 'Version ID', type: 'integer', example: 987)] | ||
private readonly ?int $version, | ||
#[Property(description: 'Active', type: 'boolean', example: true)] | ||
private readonly bool $active, | ||
#[Property(description: 'User ID', type: 'integer', example: 999)] | ||
private readonly int $userId | ||
) { | ||
|
||
} | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getCtype(): string | ||
{ | ||
return $this->ctype; | ||
} | ||
|
||
public function getDate(): int | ||
{ | ||
return $this->date; | ||
} | ||
|
||
public function getAction(): string | ||
{ | ||
return $this->action; | ||
} | ||
|
||
public function getVersion(): int | ||
{ | ||
return $this->version; | ||
} | ||
|
||
public function isActive(): bool | ||
{ | ||
return $this->active; | ||
} | ||
|
||
public function getUserId(): int | ||
{ | ||
return $this->userId; | ||
} | ||
} |
Oops, something went wrong.