-
Notifications
You must be signed in to change notification settings - Fork 3
[GDPR Data Extractor] DataobjectProvider and Asset Provider #1563
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
stunnerparas
wants to merge
40
commits into
1.x
Choose a base branch
from
840_dataproviders
base: 1.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 36 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
e15b038
type fix, add pagination and new data object provider
stunnerparas 54314c4
Apply php-cs-fixer changes
stunnerparas d79721c
changes
stunnerparas a41bbfa
Apply php-cs-fixer changes
stunnerparas 097e403
Also add pagination in Pimcore Users
stunnerparas 5f86dbe
Apply php-cs-fixer changes
stunnerparas c50f9c4
ci issue fix
stunnerparas 5692ef6
ci issue fix
stunnerparas 0054400
changes in export of data object and some code improvement
stunnerparas 6476a45
Data object provider fix issues and rephase and add interface
stunnerparas cdff53f
Apply php-cs-fixer changes
stunnerparas dd91417
ci fix
stunnerparas 812764e
Apply php-cs-fixer changes
stunnerparas b642e54
Fix the review issue and some changes
stunnerparas 8c469a8
Apply php-cs-fixer changes
stunnerparas ef73aae
ci issue fix
stunnerparas d82d6da
Apply php-cs-fixer changes
stunnerparas 3a348bc
filter in data object
stunnerparas 9f05de2
Apply php-cs-fixer changes
stunnerparas 361b923
rephase
stunnerparas 503a7f3
Apply php-cs-fixer changes
stunnerparas 41d7791
change delete option
stunnerparas d722961
Merge branch '1.x' into 840_dataobject
stunnerparas 01bde69
Add assets and pagination
stunnerparas e8f3dc3
Apply php-cs-fixer changes
stunnerparas 0418b49
Update export of asset
stunnerparas 7b9037b
Apply php-cs-fixer changes
stunnerparas b287105
sonar issue fix
stunnerparas cd21709
changes
stunnerparas d46e66f
Change the assets to zip and some improvements
stunnerparas 5b5b859
Apply php-cs-fixer changes
stunnerparas 28ec677
Ci issue fix
stunnerparas 44e14c9
Apply php-cs-fixer changes
stunnerparas 5b99772
fix
stunnerparas 1c8e506
ci issue fix
stunnerparas fdd93ec
ci issue fix
stunnerparas 378d169
review fixes
stunnerparas cf9f3fa
Apply php-cs-fixer changes
stunnerparas d7a499d
handle for both array and Response
stunnerparas c3cdf6e
Apply php-cs-fixer changes
stunnerparas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -29,21 +29,41 @@ | |
| final readonly class SearchTerms | ||
| { | ||
| public function __construct( | ||
| #[Property(description: 'The ID to search for.', type: 'string', nullable: true)] | ||
| #[Type('string')] | ||
| public ?string $id = null, | ||
| #[Property( | ||
| description: 'The ID to search for.', | ||
| type: 'int', | ||
| nullable: true, | ||
| example: 3 | ||
| )] | ||
| #[Type('int')] | ||
| private ?int $id = null, | ||
|
|
||
| #[Property(description: 'The first name to search for.', type: 'string', nullable: true)] | ||
| #[Property( | ||
| description: 'The first name to search for.', | ||
| type: 'string', | ||
| nullable: true, | ||
| example: 'John' | ||
| )] | ||
| #[Type('string')] | ||
| public ?string $firstname = null, | ||
| private ?string $firstname = null, | ||
|
|
||
| #[Property(description: 'The last name to search for.', type: 'string', nullable: true)] | ||
| #[Property( | ||
| description: 'The last name to search for.', | ||
| type: 'string', | ||
| nullable: true, | ||
| example: 'Doe' | ||
| )] | ||
| #[Type('string')] | ||
| public ?string $lastname = null, | ||
| private ?string $lastname = null, | ||
|
|
||
| #[Property(description: 'The email address to search for.', type: 'string', nullable: true)] | ||
| #[Property( | ||
| description: 'The email address to search for.', | ||
| type: 'string', | ||
| nullable: true, | ||
| example: '[email protected]' | ||
| )] | ||
| #[Type('string')] | ||
| public ?string $email = null, | ||
| private ?string $email = null, | ||
| ) { | ||
| if ($this->id === null && | ||
| $this->firstname === null && | ||
|
|
@@ -54,7 +74,7 @@ public function __construct( | |
| } | ||
| } | ||
|
|
||
| public function getId(): ?string | ||
| public function getId(): ?int | ||
| { | ||
| return $this->id; | ||
| } | ||
|
|
||
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,165 @@ | ||
| <?php | ||
| declare(strict_types=1); | ||
|
|
||
| /** | ||
| * This source file is available under the terms of the | ||
| * Pimcore Open Core License (POCL) | ||
| * Full copyright and license information is available in | ||
| * LICENSE.md which is distributed with this source code. | ||
| * | ||
| * @copyright Copyright (c) Pimcore GmbH (https://www.pimcore.com) | ||
| * @license Pimcore Open Core License (POCL) | ||
| */ | ||
|
|
||
| namespace Pimcore\Bundle\StudioBackendBundle\Gdpr\Provider; | ||
|
|
||
| use Pimcore\Bundle\GenericDataIndexBundle\Enum\Search\SortDirection; | ||
| use Pimcore\Bundle\StudioBackendBundle\DataIndex\Provider\AssetQueryProviderInterface; | ||
| use Pimcore\Bundle\StudioBackendBundle\DataIndex\Query\QueryInterface; | ||
| use Pimcore\Bundle\StudioBackendBundle\DataIndex\Service\AssetSearchServiceInterface; | ||
| use Pimcore\Bundle\StudioBackendBundle\Exception\Api\NotFoundException; | ||
| use Pimcore\Bundle\StudioBackendBundle\Filter\MappedParameter\FilterParameter; | ||
| use Pimcore\Bundle\StudioBackendBundle\Gdpr\Attribute\Request\SearchTerms; | ||
| use Pimcore\Bundle\StudioBackendBundle\Gdpr\Provider\Legacy\AssetExporterInterface; | ||
| use Pimcore\Bundle\StudioBackendBundle\Gdpr\Schema\GdprDataColumn; | ||
| use Pimcore\Bundle\StudioBackendBundle\Gdpr\Schema\GdprDataRow; | ||
| use Pimcore\Bundle\StudioBackendBundle\Util\Constant\UserPermissions; | ||
| use Pimcore\Model\Asset; | ||
| use Symfony\Component\HttpFoundation\Response; | ||
|
|
||
| /** | ||
| * @internal | ||
| */ | ||
| final readonly class AssetsProvider implements DataProviderInterface | ||
| { | ||
| public function __construct( | ||
| private AssetQueryProviderInterface $query, | ||
| private AssetSearchServiceInterface $searchService, | ||
| private AssetExporterInterface $assetExporter | ||
| ) { | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function findData(SearchTerms $terms, FilterParameter $options): array | ||
| { | ||
| $query = $this->query->createAssetQuery(); | ||
|
|
||
| $query->excludeFolders(); | ||
|
|
||
| if ($terms->getId() !== null) { | ||
| $query->filterInteger('id', $terms->getId()); | ||
| } | ||
|
|
||
| $texts = [ | ||
| $terms->getFirstname(), | ||
| $terms->getLastname(), | ||
| $terms->getEmail(), | ||
| ]; | ||
|
|
||
| foreach ($texts as $value) { | ||
| $value = trim((string)$value); | ||
| if ($value !== '') { | ||
| $query->filterFullText($value); | ||
| } | ||
| } | ||
|
|
||
| $this->applySearchOptions($query, $options); | ||
|
|
||
| $searchResult = $this->searchService->searchAssets($query); | ||
|
|
||
| $columns = $this->getAvailableColumns(); | ||
|
|
||
| $items = $searchResult->getItems(); | ||
|
|
||
| $rows = array_map( | ||
| fn ($item) => new GdprDataRow([ | ||
| 'type' => $item->getType(), | ||
| 'id' => $item->getId(), | ||
| 'fullPath' => $item->getFullPath(), | ||
| 'subType' => $item->getMimeType(), | ||
| ], $columns), | ||
| $items | ||
| ); | ||
|
|
||
| return [ | ||
| 'totalSubItems' => $searchResult->getTotalItems(), | ||
| 'rows' => $rows, | ||
| ]; | ||
| } | ||
|
|
||
| private function applySearchOptions(QueryInterface $query, FilterParameter $options): void | ||
| { | ||
| $query->setPage($options->getPage()); | ||
| $query->setPageSize($options->getPageSize()); | ||
|
|
||
| $sortFilter = $options->getSortFilter(); | ||
|
|
||
| if ($sortFilter->getKey() && $sortFilter->getDirection()) { | ||
| $directionEnum = strtolower($sortFilter->getDirection()) === SortDirection::DESC->value | ||
| ? SortDirection::DESC | ||
| : SortDirection::ASC; | ||
|
|
||
| $query->orderByField($sortFilter->getKey(), $directionEnum); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| public function getDeleteSwaggerOperationId(): string | ||
| { | ||
| return 'pimcore_studio_api_assets_batch_delete'; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function getSingleItemForDownload(int $id): Response | ||
| { | ||
| try { | ||
| $asset = Asset::getById((int)$id); | ||
|
|
||
| } catch (NotFoundException) { | ||
| throw new NotFoundException('Asset Not Found', $id); | ||
| } | ||
|
|
||
| return $this->assetExporter->doExportData($asset); | ||
|
|
||
| } | ||
|
|
||
| public function getName(): string | ||
| { | ||
| return 'Assets'; | ||
| } | ||
|
|
||
| public function getKey(): string | ||
| { | ||
| return 'assets'; | ||
| } | ||
|
|
||
| public function getSortPriority(): int | ||
| { | ||
| return 8; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function getRequiredPermissions(): array | ||
| { | ||
| return [UserPermissions::ASSETS->value]; | ||
| } | ||
|
|
||
| /** | ||
| * {@inheritdoc} | ||
| */ | ||
| public function getAvailableColumns(): array | ||
| { | ||
| return [ | ||
| new GdprDataColumn('type', 'Type'), | ||
| new GdprDataColumn('id', 'ID'), | ||
| new GdprDataColumn('fullPath', 'Full Path'), | ||
| new GdprDataColumn('subType', 'Type'), | ||
| ]; | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.