Skip to content
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

Overriding Object Datatypes #4679

Open
bebuecherl opened this issue Jul 12, 2019 · 0 comments

Comments

Projects
None yet
1 participant
@bebuecherl
Copy link
Contributor

commented Jul 12, 2019

Bug Report / Discussion

I'm currently working on overriding a Pimcore default Object Datatype (Localizedfields), as a customer of ours needs #2958 and we wanted to have it configurable (which Languages are mandatory and which are not). So I followed the instructions in the docs to override the Datatype.

Expected behavior

Using either

pimcore:
    objects:
        class_definitions:
            data:
                map:
                    localizedfields: \AppBundle\Model\DataObject\ClassDefinition\Data\Localizedfields

or

pimcore:
    objects:
        class_definitions:
            data:
                prefixes:
                    - \AppBundle\Model\DataObject\ClassDefinition\Data\

results in registering/overriding the Datatype.

Actual behavior

Still uses the Pimcore Datatype when editing/saving ClassDefinitions in the backend.

As it looks to me, in PimcoreCoreExtension the prefixes are added as second loader to the ImplementationLoader. Since ImplementationLoader does reverse the array of loaders, it will start by using the PrefixLoader. This loads the prefixes in order. This means he will load all classes from \Pimcore\Model\DataObject\ClassDefinition\Data\ (config/default.yml) first; no matter what is defined in pimcore.objects.class_definitions.data.map.

I think this should be the other way arround, so the direkt mapping (pimcore.objects.class_definitions.data.map) is loaded before the glob mapping (pimcore.objects.class_definitions.data.prefixes). And maybe additionally reverse the prefixes, so custom configuration will be used before default (Pimcore) configuration

Steps to reproduce

(see description & expected behavior)

Current workaround

Inside my \AppBundle\DependencyInjection\AppExtension load-Method:

$prefixes = [ '\\AppBundle\\Model\\DataObject\\ClassDefinition\\Data\\' ];

$container->setDefinition(
    'pimcore.implementation_loader.object.data.prefix_loader',
    new Definition(PrefixLoader::class, [ $prefixes ])
);

$config = $container->getParameter('pimcore.config');

$config['objects']['class_definitions']['data']['prefixes'] = $prefixes;

$container->setParameter('pimcore.config', $config);

this will override the internal PrefixLoader when Containers are merged. (Also ensuring that the container configuration is correct).


P.S.: not quite sure if this is a bug

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.