support theme options via user preferences #89 (#91)

This commit is contained in:
Kevin Papst
2018-01-15 22:58:07 +01:00
committed by GitHub
parent 827b1ae9ad
commit 3f221fcdb8
14 changed files with 289 additions and 113 deletions

View File

@@ -3,7 +3,8 @@
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\IntegerType;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Constraints as Assert;
@@ -59,7 +60,7 @@ class UserPreference
/**
* @var string
*/
protected $type = TextType::class;
protected $type;
/**
* @var Constraint[]
@@ -121,18 +122,25 @@ class UserPreference
}
/**
* @return string
* @return string|int|bool
*/
public function getValue()
{
switch ($this->type) {
case CheckboxType::class:
return (bool) $this->value;
case IntegerType::class:
return (int) $this->value;
}
return $this->value;
}
/**
* @param string $value
* @param string|int|bool $value
* @return UserPreference
*/
public function setValue(string $value): UserPreference
public function setValue($value): UserPreference
{
$this->value = $value;
return $this;