DependencyInjection/WikiTagExtension.php
author cavaliet
Tue, 15 Nov 2011 12:27:02 +0100
changeset 33 6c87166b819c
parent 23 b435f8055cb4
child 46 6f643fc1de26
permissions -rwxr-xr-x
First step to add context search to a page. Works fine but needs to be improved with several list of selectors.
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\DependencyInjection\ContainerBuilder;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     6
use Symfony\Component\Config\FileLocator;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     7
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     8
use Symfony\Component\DependencyInjection\Loader;
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
     9
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
 * This is the class that loads and manages your bundle configuration
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
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
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
class WikiTagExtension extends Extension
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    16
{
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
     * {@inheritDoc}
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
    public function load(array $configs, ContainerBuilder $container)
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    21
    {
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    22
        $configuration = new Configuration();
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    23
        $config = $this->processConfiguration($configuration, $configs);
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    24
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    25
        $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    26
        $loader->load('services.yml');
17
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    27
        
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    28
        if(isset($config['document_class']))
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    29
        {
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    30
            $container->setParameter("wiki_tag.document_class", $config['document_class']);
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    31
        }
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    32
        
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    33
        if(isset($config['document_id_column']))
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    34
        {
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    35
            $document_id = $config['document_id_column'];
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    36
        }
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    37
        
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    38
        if(!isset($document_id) || is_null($document_id) || strlen($document_id) == 0) {
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    39
            $document_id = "id";
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    40
        }
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    41
        $container->setParameter("wiki_tag.document_id_column", $document_id);
81962874e172 First implementation of dynamic fields
ymh <ymh.work@gmail.com>
parents: 1
diff changeset
    42
        
23
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    43
        $fields = $config['fields'];
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    44
        $container->setParameter("wiki_tag.fields", $fields);
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    45
        $fields['tagsStr'] = array("type"=>"text");
b435f8055cb4 improve dynamic docs. create and lad class dynamically
ymh <ymh.work@gmail.com>
parents: 21
diff changeset
    46
        $container->setParameter("wiki_tag.fields_all", $fields);
21
780ef37e63b9 add route parameter
ymh <ymh.work@gmail.com>
parents: 17
diff changeset
    47
        $container->setParameter("wiki_tag.route_for_documents_by_tag", $config['route_for_documents_by_tag']);
33
6c87166b819c First step to add context search to a page. Works fine but needs to be improved with several list of selectors.
cavaliet
parents: 23
diff changeset
    48
        $container->setParameter("wiki_tag.reactive_selectors", $config['reactive_selectors']);
1
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    49
    }
06a22ff5d58d first commit forminimal bundle structure
ymh <ymh.work@gmail.com>
parents:
diff changeset
    50
}