/** * Tests the getters and setters */ public function testGettersAndSetters() { $this->setting->setEditable(true); $this->assertTrue($this->setting->isEditable()); $this->setting->setName('name'); $this->assertEquals('name', $this->setting->getName()); $this->setting->setValue('value'); $this->assertEquals('value', $this->setting->getValue()); }
/** * Store a setting * * @param string $name * @param mixed $value * @param bool $isEditable * @return $this */ public function set($name, $value, $isEditable = false) { $this->isInitialized = false; if ($this->has($name)) { $setting = $this->settings[$name]; } else { $setting = new Setting(); $setting->setName($name); } $setting->setValue($value); $setting->setEditable($isEditable); // store and flush $this->entityManager->persist($setting); $this->entityManager->flush(); // reset it $this->settings[$name] = $setting; return $this; }