Skip to content

Commit

Permalink
Get setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Thompson committed Dec 8, 2015
1 parent 80f23e4 commit 86e96bf
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
44 changes: 44 additions & 0 deletions src/Setting/Command/GetSetting.php
@@ -0,0 +1,44 @@
<?php namespace Anomaly\SettingsModule\Setting\Command;

use Anomaly\SettingsModule\Setting\Contract\SettingRepositoryInterface;
use Illuminate\Contracts\Bus\SelfHandling;

/**
* Class GetSetting
*
* @link http://anomaly.is/streams-platform
* @author AnomalyLabs, Inc. <hello@anomaly.is>
* @author Ryan Thompson <ryan@anomaly.is>
* @package Anomaly\SettingsModule\Setting\Plugin\Command
*/
class GetSetting implements SelfHandling
{

/**
* The setting key.
*
* @var string
*/
protected $key;

/**
* Create a new GetSetting instance.
*
* @param $key
*/
public function __construct($key)
{
$this->key = $key;
}

/**
* Handle the command.
*
* @param SettingRepositoryInterface $settings
* @return \Anomaly\SettingsModule\Setting\Contract\SettingInterface|null
*/
public function handle(SettingRepositoryInterface $settings)
{
return $settings->get($this->key);
}
}
5 changes: 3 additions & 2 deletions src/SettingsModulePlugin.php
@@ -1,7 +1,8 @@
<?php namespace Anomaly\SettingsModule;

use Anomaly\SettingsModule\Setting\Command\GetSetting;
use Anomaly\SettingsModule\Setting\Command\GetSettingValue;
use Anomaly\SettingsModule\Setting\Command\GetValueFieldType;
use Anomaly\SettingsModule\Setting\Command\GetValuePresenter;
use Anomaly\Streams\Platform\Addon\Plugin\Plugin;

/**
Expand All @@ -26,7 +27,7 @@ public function getFunctions()
new \Twig_SimpleFunction(
'setting',
function ($key) {
return $this->dispatch(new GetValueFieldType($key));
return $this->dispatch(new GetValuePresenter($this->dispatch(new GetSetting($key))));
}
),
new \Twig_SimpleFunction(
Expand Down

0 comments on commit 86e96bf

Please sign in to comment.