0

I'm trying to create this configuration on Symfony

media:
    medias:
        category.type.subtype:
            reference : "UUID" # What is used to identify object in DB (needed)
            service : ~ # Service name "bundle.service.name"

            identifiers: # If empty, no generator can be created for this media
                channelId: # Example
                    label: ~ # Label for front
                    key: "channel_id" # Identifier in bdd (default : the name of identifier)
                channelTitle: ~
                # Other identifier....

            api: # Api configuration (can be null if no API)
                consumer_key: ~
                consumer_secret: ~
                # Others parameters...

            parameters:
                label: "Media 1" # Label in the front Default : generated with the name
                page:
                    factor: 50 # Factor (default 20)
                    styles:
                        style1:
                            css_class: class1
                        style2:
                            css_class: class2
                        # Other styles...
        category.type.subtype2: #parameters.....

I've written this code :

    $rootNode = $treeBuilder->root('media');

    $rootNode
        ->children()
            ->arrayNode("medias")
                ->prototype('array')
                    ->children()
                        ->scalarNode('reference')
                            ->isRequired()
                        ->end()

                        ->scalarNode('service')->end()

                        ->arrayNode("identifiers")
                            ->prototype('array')
                                ->children()
                                    ->scalarNode("label")->end()
                                    ->scalarNode("key")->end()
                                ->end()
                            ->end()
                        ->end()

                        ->arrayNode("api")
                            ->prototype('scalar')->end()
                        ->end()

                        ->arrayNode("parameters")
                            ->scalarNode("label")->end()

                            ->arrayNode("page")
                                ->children()
                                    ->integerNode("factor")->end()

                                    ->arrayNode("styles")
                                        ->prototype('array')
                                            ->children()
                                                ->scalarNode("css_class")->end()
                                            ->end()
                                        ->end()
                                    ->end()

                                ->end()
                            ->end()

                        ->end()

                    ->end()
                ->end()
            ->end()
        ->end()
    ;

But I've the error :

Call to undefined method Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::scalarNode()

And I've absolutly no idea where this error come from :/

2
  • Which line is the issue? You've removed that information from the error. Commented May 29, 2017 at 8:23
  • The CLI doesn't indicate me the line :/ Commented May 29, 2017 at 8:53

1 Answer 1

1

You didn't specified which line of code is the issue, but for me it looks like you forgot to call children() method after parameters node definition:

->arrayNode("parameters")
    ->scalarNode("label")->end()

It should be something like:

->arrayNode("parameters")
    ->children()
        ->scalarNode("label")->end()
        // other nodes
    ->end()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.