Skip to content

Commit

Permalink
Changed way to enable twig functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Coureau committed Jun 30, 2014
1 parent 1b4b8bf commit 828a917
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 16 deletions.
1 change: 1 addition & 0 deletions DependencyInjection/Configuration.php
Expand Up @@ -37,6 +37,7 @@ public function getConfigTreeBuilder()
->scalarNode('table_prefix')->end()
->scalarNode('wordpress_directory')->end()
->scalarNode('entity_manager')->end()
->booleanNode('load_twig_extension')->defaultFalse()->end()
->end()
;

Expand Down
16 changes: 3 additions & 13 deletions DependencyInjection/EkinoWordpressExtension.php
Expand Up @@ -52,7 +52,9 @@ public function load(array $configs, ContainerBuilder $container)
$this->loadEntityManager($container, $config['entity_manager']);
}

$this->loadTwigExtensions($loader);
if ($config['load_twig_extension']) {
$loader->load('twig.xml');
}
}

/**
Expand Down Expand Up @@ -104,18 +106,6 @@ protected function loadEntityManager(ContainerBuilder $container, $em)
$container->getDefinition('ekino.wordpress.manager.user_meta')->replaceArgument(0, $reference);
}

/**
* Will load twig extensions if enabled
*
* @param XmlFileLoader $loader
*/
protected function loadTwigExtensions(XmlFileLoader $loader)
{
if (class_exists('\Twig_Extension')) {
$loader->load('twig.xml');
}
}

/**
* Returns bundle alias name
*
Expand Down
3 changes: 2 additions & 1 deletion README.md
Expand Up @@ -67,9 +67,10 @@ Optionnally, you can specify the following options in your `app/config.yml`:
ekino_wordpress:
table_prefix: wp_ # If you have a specific Wordpress table prefix
wordpress_directory: /my/wordpress/directory # If you have a specific Wordpress directory structure
load_twig_extension: true # If you want to enable native WordPress functions (ie : get_option() => wp_get_option())
```

Also optionnally, if you want to use `UserHook` to authenticate on Symfony, you should add this configuration to your `app/security.yml`:
Also optionally, if you want to use `UserHook` to authenticate on Symfony, you should add this configuration to your `app/security.yml`:

```yml
security:
Expand Down
4 changes: 2 additions & 2 deletions Twig/Extension/OptionExtension.php
Expand Up @@ -22,7 +22,7 @@ public function getName()
/**
* @param OptionManager $optionManager
*/
public function __contruct(OptionManager $optionManager)
public function __construct(OptionManager $optionManager)
{
$this->optionManager = $optionManager;
}
Expand All @@ -33,7 +33,7 @@ public function __contruct(OptionManager $optionManager)
public function getFunctions()
{
return array(
new \Twig_SimpleFunction('get_option', array($this, 'getOption')),
new \Twig_SimpleFunction('wp_get_option', array($this, 'getOption')),
);
}

Expand Down

0 comments on commit 828a917

Please sign in to comment.