-
Notifications
You must be signed in to change notification settings - Fork 5
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
17 changed files
with
96 additions
and
60 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
23 changes: 23 additions & 0 deletions
23
databox/api/src/Api/InputTransformer/MoveAssetInputTransformer.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,23 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Api\InputTransformer; | ||
|
||
use App\Api\Model\Input\MoveAssetInput; | ||
|
||
class MoveAssetInputTransformer extends AbstractFileInputTransformer | ||
{ | ||
public function supports(string $resourceClass, object $data): bool | ||
{ | ||
return $data instanceof MoveAssetInput; | ||
} | ||
|
||
/** | ||
* @param MoveAssetInput $data | ||
*/ | ||
public function transform(object $data, string $resourceClass, array $context = []): object|iterable | ||
{ | ||
return $data; | ||
} | ||
} |
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,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Api\Processor; | ||
|
||
use ApiPlatform\Api\IriConverterInterface; | ||
use ApiPlatform\Metadata\Operation; | ||
use ApiPlatform\State\ProcessorInterface; | ||
use App\Entity\Core\Collection; | ||
use App\Security\Voter\AbstractVoter; | ||
use App\Util\SecurityAwareTrait; | ||
use Arthem\Bundle\RabbitBundle\Producer\EventProducer; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; | ||
|
||
class MoveCollectionProcessor implements ProcessorInterface | ||
{ | ||
use SecurityAwareTrait; | ||
|
||
public function __construct( | ||
private readonly EventProducer $eventProducer, | ||
private readonly EntityManagerInterface $em, | ||
private readonly IriConverterInterface $iriConverter | ||
) { | ||
} | ||
|
||
/** | ||
* @param Collection $data | ||
*/ | ||
public function process($data, Operation $operation, array $uriVariables = [], array $context = []): Response | ||
{ | ||
$this->denyAccessUnlessGranted(AbstractVoter::EDIT, $data); | ||
$dest = $uriVariables['dest']; | ||
$isRoot = 'root' === $dest; | ||
|
||
if ($isRoot) { | ||
$destination = null; | ||
} else { | ||
$destination = $this->em->find(Collection::class, $dest); | ||
if (!$destination instanceof Collection) { | ||
throw new NotFoundHttpException(sprintf('Collection destination "%s" not found', $dest)); | ||
} | ||
$this->denyAccessUnlessGranted(AbstractVoter::EDIT, $destination); | ||
} | ||
|
||
if ($destination === $data) { | ||
throw new \InvalidArgumentException('Cannot reference parent to itself!'); | ||
} | ||
|
||
$data->setParent($destination); | ||
|
||
$this->em->persist($data); | ||
$this->em->flush(); | ||
|
||
return new Response('', 204); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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
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
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