DependencyInjection/Configuration.php
author ymh <ymh.work@gmail.com>
Fri, 04 Nov 2011 11:56:59 +0100
changeset 23 b435f8055cb4
parent 21 780ef37e63b9
child 33 6c87166b819c
permissions -rwxr-xr-x
improve dynamic docs. create and lad class dynamically
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     1
<?php
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     2
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     3
namespace IRI\Bundle\WikiTagBundle\DependencyInjection;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     4
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
use Symfony\Component\Config\Definition\ConfigurationInterface;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
/**
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
 * This is the class that validates and merges configuration from your app/config files
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    10
 *
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    11
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    12
 */
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    13
class Configuration implements ConfigurationInterface
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    14
{
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    15
    /**
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
     * {@inheritDoc}
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    17
     */
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    18
    public function getConfigTreeBuilder()
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    19
    {
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    20
        $treeBuilder = new TreeBuilder();
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
        $rootNode = $treeBuilder->root('wiki_tag');
17
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    22
        
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    23
        $rootNode
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    24
            ->children()
21
780ef37e63b9 add route parameter
ymh <ymh.work@gmail.com>
parents: 17
diff changeset
    25
                ->scalarNode('route_for_documents_by_tag')->defaultNull()->end()
780ef37e63b9 add route parameter
ymh <ymh.work@gmail.com>
parents: 17
diff changeset
    26
                ->scalarNode('document_class')->isRequired()->end()
17
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    27
                ->scalarNode('document_id_column')->defaultValue('id')->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    28
            ->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    29
            ->fixXmlConfig('field')
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    30
            ->children()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    31
                ->arrayNode('fields')
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    32
                    ->treatNullLike(array())
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    33
                    ->useAttributeAsKey('name')
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    34
                    ->prototype('array')
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    35
                        ->performNoDeepMerging()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    36
                        ->children()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    37
                            ->scalarNode('type')->defaultValue('text')->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    38
                            ->scalarNode('length')
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    39
                                ->beforeNormalization()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    40
                                    ->ifString()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    41
                                    ->then(function($v) { return intval($v); })
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    42
                                ->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    43
                            ->end()
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    44
                            ->scalarNode('weight')->defaultValue(1.0)
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    45
                                ->beforeNormalization()
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    46
                                    ->ifString()
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    47
                                    ->then(function($v) { return floatval($v); })
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    48
                                ->end()
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    49
                            ->end()
17
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    50
                            ->scalarNode('accessor')->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    51
                        ->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    52
                    ->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    53
                ->end()
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    54
            ->end();
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    55
        
1
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    56
        return $treeBuilder;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    57
    }
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    58
}