I want to have string type column (for bit manipulations) with two or more getter / setter, f. ex:
const STATUS_NEW = 0b00001000;
const STATUS_NEW2 = 0b00000010;
/**
* @var String
*
* @ORM\Column(name="modelStatus", type="string", length=1, nullable=true)
*/
private $status;
public function getNew()
{
return ($this->status and $this::NEW);
}
public function setNew(bool $set)
{
if ($set) {
$this->status = ($this->status | $this::STATUS_NEW);
} else {
$this->status = ($this->status & ~$this::STATUS_NEW);
}
return $this;
}
public function getNew2()
{
return ($this->status and $this::NEW2);
}
public function setNew2(bool $set)
{
if ($set) {
$this->status = ($this->status | $this::NEW2);
} else {
$this->status = ($this->status & ~$this::NEW2);
}
return $this;
}
with form:
$builder->add('new', CheckboxType::class, [
'required' => false,
->add('new2', CheckboxType::class, [
'required' => false,
])
When I check checkboxes, it "enter" only the last setter, not in all:(
Sorry for my english