Skip to content

[DependencyInjection] ArrayNodeDefinition::canBeEnabled() doesn't make the configuration disabled by default #25760

@jakzal

Description

@jakzal
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 2.7

Consider the following configuration:

$builder = new TreeBuilder();
$root = $builder->root('acme_foo');
$root->canBeEnabled();

Expected behaviour

If the section wasn't provided in configuration, it will be disabled.

Actual Behaviour

The section is enabled unless it was explicitly disabled.

Supporting information

It only seems to be an issue for root nodes. Any child nodes work as expected (i.e. $root->children()->arrayNode('foo')->canBeEnabled()).

The docblock for canBeEnabled() says that the section should be disabled by default (which is also what I expected):

    /**
     * Adds an "enabled" boolean to enable the current section.
     *
     * By default, the section is disabled. If any configuration is specified then
     * the node will be automatically enabled:
     *
     * enableableArrayNode: {enabled: true, ...}   # The config is enabled & default values get overridden
     * enableableArrayNode: ~                      # The config is enabled & use the default values
     * enableableArrayNode: true                   # The config is enabled & use the default values
     * enableableArrayNode: {other: value, ...}    # The config is enabled & default values get overridden
     * enableableArrayNode: {enabled: false, ...}  # The config is disabled
     * enableableArrayNode: false                  # The config is disabled
     */

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy