Skip to content

Commit

Permalink
Add setting as twig function
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisRAoW committed Jan 15, 2019
1 parent 7df91e6 commit e1514d2
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/Extensions/OffbeatWpExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

use Twig_Extension;
use Twig_Function;
use OffbeatWP\Contracts\SiteSettings;

class OffbeatWpExtension extends Twig_Extension
{
Expand All @@ -12,6 +13,7 @@ public function getFunctions()
new Twig_Function('config', array($this, 'getConfig')),
new Twig_Function('assetUrl', array($this, 'getAssetUrl')),
new Twig_Function('component', array($this, 'getComponent')),
new Twig_Function('setting', array($this, 'getSetting')),
);
}

Expand All @@ -29,4 +31,9 @@ public function getComponent($name, $args = [])
{
echo container('components')->render($name, $args);
}

public function getSetting($key)
{
return offbeat(SiteSettings::class)->get($key);
}
}

0 comments on commit e1514d2

Please sign in to comment.