Dot Notation for Field Definitions
Studio provides a Dot Notation to resolve the field defintion of an object.
Here are some examples for the Car Object:
carClassGet the Standard fields.localizedfields.nameGet Localized Fieldsattributes.Bodywork.numberOfDoorsGet Field from a Brick
Here are some complex examples using the News Object:
content.NewsCars.relatedCarsGet Field from Field Collectioncontent.NewsCars.localizedfields.titleGet Localized Field from Field Collectioncontent.NewsLinks.links.linkGet Field from a Block in a Field Collection
Custom Data Types
When you have custom Container Data Type and would like to support the Dot Notation you can implement your own Resolver.
You need to Extend Pimcore\Bundle\StudioBackendBundle\FieldDefinition\Parser\Resolver\AbstractResolver
Here is a simple Example:
<?php
declare(strict_types=1);
namespace App\Resolver;
use Pimcore\Bundle\StudioBackendBundle\Exception\ParseException;
use Pimcore\Bundle\StudioBackendBundle\FieldDefinition\FieldDefinitionWrapper;
/**
* @internal
*/
final class DefaultResolver extends AbstractResolver
{
public function getResolverName(): string
{
return 'my_resolver';
}
public function canResolve(array $dotNotationParts): bool
{
if (count($dotNotationParts) === 1) {
return true;
}
return false;
}
public function resolve(array $dotNotationParts): FieldDefinitionWrapper
{
$key = $dotNotationParts[0];
return $this->wrapFieldDefinition(
fieldDefinition: $this->getFieldDefinition($key),
containerType: 'my_container',
fieldname: $key,
);
}
}