mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-07-03 10:09:19 +00:00
Changed whole Input Objects
they now lives by themselves when before they where highly connected to Form.php
This commit is contained in:
@ -6,22 +6,40 @@ use AdminPanel\AdminPanel;
|
||||
|
||||
class EntityInput extends AbstractInput
|
||||
{
|
||||
public function getOptions(): array
|
||||
public function __construct()
|
||||
{
|
||||
return array(
|
||||
'entity'
|
||||
$this->setOption("type", "text");
|
||||
}
|
||||
|
||||
public function getOptionsList(): array
|
||||
{
|
||||
return array_merge(
|
||||
parent::getOptionsList(),
|
||||
array(
|
||||
'entity'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function processOption(string $optionName, $value): array
|
||||
public function setOption(string $name, $value)
|
||||
{
|
||||
if ($optionName === 'entity') {
|
||||
return array(
|
||||
'entities' => AdminPanel::getInstance()->getEm()->getRepository($value)->findAll()
|
||||
);
|
||||
if ($name === 'entity') {
|
||||
$this->options["entities"] = AdminPanel::getInstance()->getEm()->getRepository($value)->findAll();
|
||||
} elseif ($name === "name") {
|
||||
$this->attributes["list"] = $value . "_list";
|
||||
}
|
||||
parent::setOption($name, $value);
|
||||
}
|
||||
|
||||
public function getOption($name)
|
||||
{
|
||||
if ($name === "value") {
|
||||
$repo = AdminPanel::getInstance()->getEm()->getRepository($this->options["entity"]);
|
||||
return $repo->findOneBy(array(
|
||||
'name' => $this->options["value"]
|
||||
));
|
||||
} else {
|
||||
return parent::getOption($name);
|
||||
}
|
||||
return array(
|
||||
$optionName => $value
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user