Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.x' into change-doc-json-route
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Oct 17, 2024
2 parents 33f9a7e + 97eed10 commit d32c11d
Show file tree
Hide file tree
Showing 61 changed files with 3,712 additions and 11 deletions.
129 changes: 129 additions & 0 deletions config/data_objects.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,135 @@ services:
Pimcore\Bundle\StudioBackendBundle\DataObject\Service\ReplaceServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\DataObject\Service\ReplaceService

Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterService

Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface:
class: Pimcore\Bundle\StudioBackendBundle\DataObject\Service\Loader\TaggedIteratorDataAdapter

#
# Data Adapters
#

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\AdvancedManyToManyObjectRelationAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\AdvancedManyToManyRelationAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\BooleanAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\CalculatedValueAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\CheckboxAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ClassificationStoreAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\DateAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\DateRangeAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\GeoBoundsAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\GeoPointAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\GeoPointsAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ExternalImageAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\HotspotImageAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ImageAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ImageGalleryAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\LinkAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\LocalizedFieldsAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ManyToManyRelationAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ManyToManyObjectRelationAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ManyToOneRelationAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\MultiSelectAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\NumericAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\NumericRangeAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ObjectBricksAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ReverseObjectRelationAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\RgbaColorAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\SelectAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\SliderAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\StringAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\StructuredTableAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\TableAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\UrlSlugAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\VideoAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\QuantityValueAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\InputQuantityValueAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\QuantityValueRangeAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ConsentAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\EncryptedFieldAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\BlockAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]

Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\FieldCollectionsAdapter:
tags: [ 'pimcore.studio_backend.data_adapter' ]
#
# Handler
#
Expand Down
97 changes: 97 additions & 0 deletions config/pimcore/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,103 @@ pimcore_studio_backend:
document: ['content', 'seo', 'warning', 'notice']
data-object: ['content', 'seo', 'warning', 'notice']

data_object_data_adapter_mapping:
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\AdvancedManyToManyRelationAdapter:
- "advancedManyToManyRelation"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\AdvancedManyToManyObjectRelationAdapter:
- "advancedManyToManyObjectRelation"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\BooleanAdapter:
- "booleanSelect"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\CalculatedValueAdapter:
- "calculatedValue"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\CheckboxAdapter:
- "checkbox"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ClassificationStoreAdapter:
- "classificationstore"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\DateAdapter:
- "date"
- "datetime"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\DateRangeAdapter:
- "dateRange"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\GeoBoundsAdapter:
- "geobounds"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\GeoPointAdapter:
- "geopoint"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\GeoPointsAdapter:
- "geopolygon"
- "geopolyline"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ExternalImageAdapter:
- "externalImage"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\HotspotImageAdapter:
- "hotspotimage"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ImageAdapter:
- "image"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ImageGalleryAdapter:
- "imageGallery"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\LinkAdapter:
- "link"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\LocalizedFieldsAdapter:
- "localizedfields"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ManyToManyRelationAdapter:
- "manyToManyRelation"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ManyToManyObjectRelationAdapter:
- "manyToManyObjectRelation"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ManyToOneRelationAdapter:
- "manyToOneRelation"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\MultiSelectAdapter:
- "countrymultiselect"
- "languagemultiselect"
- "multiselect"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\NumericAdapter:
- "numeric"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\NumericRangeAdapter:
- "numericRange"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ObjectBricksAdapter:
- "objectbricks"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ReverseObjectRelationAdapter:
- "reverseObjectRelation"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\RgbaColorAdapter:
- "rgbaColor"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\SelectAdapter:
- "country"
- "gender"
- "language"
- "select"
- "user"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\SliderAdapter:
- "slider"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\StringAdapter:
- "email"
- "firstname"
- "input"
- "lastname"
- "password"
- "textarea"
- "time"
- "wysiwyg"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\StructuredTableAdapter:
- "structuredTable"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\TableAdapter:
- "table"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\UrlSlugAdapter:
- "urlSlug"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\QuantityValueAdapter:
- "quantityValue"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\InputQuantityValueAdapter:
- "inputQuantityValue"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\QuantityValueRangeAdapter:
- "quantityValueRange"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\VideoAdapter:
- "video"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\ConsentAdapter:
- "consent"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\EncryptedFieldAdapter:
- "encryptedField"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\BlockAdapter:
- "block"
Pimcore\Bundle\StudioBackendBundle\DataObject\Data\Adapter\FieldCollectionsAdapter:
- "fieldcollections"

mercure:
hubs:
studio_server:
Expand Down
3 changes: 3 additions & 0 deletions config/updater.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ services:
Pimcore\Bundle\StudioBackendBundle\Updater\Service\AdapterLoaderInterface:
class: Pimcore\Bundle\StudioBackendBundle\Updater\Service\Loader\TaggedIteratorAdapter

Pimcore\Bundle\StudioBackendBundle\Updater\Service\EditableAdapterLoaderInterface:
class: Pimcore\Bundle\StudioBackendBundle\Updater\Service\Loader\TaggedIteratorEditableAdapter

Pimcore\Bundle\StudioBackendBundle\Updater\Service\UpdateServiceInterface:
class: Pimcore\Bundle\StudioBackendBundle\Updater\Service\UpdateService

Expand Down
4 changes: 2 additions & 2 deletions doc/00_Installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ bin/console pimcore:bundle:install PimcoreStudioBackendBundle
The Studio Backend Bundle provides an OpenApi documentation for the API. To access the documentation, navigate to the following URL:

```
https://<your-pimcore-host>/studio/api/docs
https://<your-pimcore-host>/pimcore-studio/api/docs
```

You can also access the OpenApi documentation in JSON format by navigating to the following URL:
```
https://<your-pimcore-host>/studio/api/docs.json
https://<your-pimcore-host>/pimcore-studio/api/docs.json
```

It is also possible to export the OpenApi documentation as a JSON file by running the following command:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use OpenApi\Attributes\RequestBody;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\UpdateBooleanProperty;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\UpdateIntegerProperty;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\UpdateObjectProperty;
use Pimcore\Bundle\StudioBackendBundle\OpenApi\Attribute\Property\UpdateStringProperty;
use Pimcore\Bundle\StudioBackendBundle\Property\Attribute\Property\UpdateElementProperties;

Expand All @@ -48,6 +49,7 @@ public function __construct()
new UpdateStringProperty('childrenSortBy'),
new UpdateStringProperty('childrenSortOrder'),
new UpdateBooleanProperty('published'),
new UpdateObjectProperty('editableData'),
new UpdateElementProperties(),
],
type: 'object',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<?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\DataObject\Data\Adapter;

use Pimcore\Bundle\StaticResolverBundle\Models\DataObject\ConcreteObjectResolverInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\FieldContextData;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Data\SetterDataInterface;
use Pimcore\Bundle\StudioBackendBundle\DataObject\Service\DataAdapterLoaderInterface;
use Pimcore\Model\DataObject\ClassDefinition\Data;
use Pimcore\Model\DataObject\ClassDefinition\Data\AdvancedManyToManyObjectRelation;
use Pimcore\Model\DataObject\Concrete;
use Pimcore\Model\DataObject\Data\ObjectMetadata;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
use function is_array;

/**
* @internal
*/
#[AutoconfigureTag(DataAdapterLoaderInterface::ADAPTER_TAG)]
final readonly class AdvancedManyToManyObjectRelationAdapter implements SetterDataInterface
{
public function __construct(
private ConcreteObjectResolverInterface $concreteObjectResolver
) {
}

public function getDataForSetter(
Concrete $element,
Data $fieldDefinition,
string $key,
array $data,
?FieldContextData $contextData = null
): ?array {

$relationData = $data[$key];
if ($relationData === false || !is_array($relationData)) {
return null;
}

return $this->buildRelationsMetadata($relationData, $fieldDefinition);
}

private function buildRelationsMetadata(array $relationData, Data $fieldDefinition): array
{
if (!$fieldDefinition instanceof AdvancedManyToManyObjectRelation) {
return [];
}

$relationsMetadata = [];
foreach ($relationData as $relation) {
$object = $this->concreteObjectResolver->getById($relation['id']);
if ($object && $object->getClassName() === $fieldDefinition->getAllowedClassId()) {
$relationsMetadata[] = $this->createObjectMetadata($object, $fieldDefinition, $relation);
}
}

return $relationsMetadata;
}

private function createObjectMetadata(
Concrete $object,
AdvancedManyToManyObjectRelation $fieldDefinition,
array $relation,
): ObjectMetadata {
$metaData = new ObjectMetadata(
$fieldDefinition->getName(),
$fieldDefinition->getColumnKeys(),
$object
);
$metaData->_setOwner($object);
$metaData->_setOwnerFieldname($fieldDefinition->getName());

foreach ($fieldDefinition->getColumns() as $column) {
$setter = 'set' . ucfirst($column['key']);
$value = $relation[$column['key']] ?? null;

if ($column['type'] === 'multiselect' && is_array($value)) {
$value = implode(',', $value);
}

$metaData->$setter($value);
}

return $metaData;
}
}
Loading

0 comments on commit d32c11d

Please sign in to comment.