mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-06-06 23:19:53 +00:00
Added Input objects
This commit is contained in:
parent
0dfe90ebf6
commit
ca0150ca0b
15
src/AdminPanel/Form/ChoiceInput.php
Normal file
15
src/AdminPanel/Form/ChoiceInput.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace AdminPanel\Form;
|
||||
|
||||
class ChoiceInput extends TextInput
|
||||
{
|
||||
public function getOptions(): array
|
||||
{
|
||||
return array(
|
||||
'label',
|
||||
'value',
|
||||
'choices'
|
||||
);
|
||||
}
|
||||
}
|
14
src/AdminPanel/Form/DateInput.php
Normal file
14
src/AdminPanel/Form/DateInput.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace AdminPanel\Form;
|
||||
|
||||
class DateInput extends TextInput
|
||||
{
|
||||
public function getOptions(): array
|
||||
{
|
||||
return array(
|
||||
'label',
|
||||
'value',
|
||||
);
|
||||
}
|
||||
}
|
33
src/AdminPanel/Form/EntityInput.php
Normal file
33
src/AdminPanel/Form/EntityInput.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace AdminPanel\Form;
|
||||
|
||||
use AdminPanel\AdminPanel;
|
||||
|
||||
class EntityInput implements Input
|
||||
{
|
||||
public function getOptions(): array
|
||||
{
|
||||
return array(
|
||||
'label',
|
||||
'entity'
|
||||
);
|
||||
}
|
||||
|
||||
public function processOption(string $optionName, $value): array
|
||||
{
|
||||
if ($optionName === 'entity') {
|
||||
return array(
|
||||
'entities' => AdminPanel::getInstance()->getEm()->getRepository($value)->findAll()
|
||||
);
|
||||
}
|
||||
return array(
|
||||
$optionName => $value
|
||||
);
|
||||
}
|
||||
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return "@AdminPanel/form/entity.twig";
|
||||
}
|
||||
}
|
32
src/AdminPanel/Form/Input.php
Normal file
32
src/AdminPanel/Form/Input.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace AdminPanel\Form;
|
||||
|
||||
interface Input
|
||||
{
|
||||
/**
|
||||
* get definable options in form
|
||||
* some are processed elsewhere like
|
||||
* name, value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getOptions(): array;
|
||||
|
||||
/**
|
||||
* run things when you got option
|
||||
*
|
||||
* @param string $optionName
|
||||
* @param mixed $value
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function processOption(string $optionName, $value): array;
|
||||
|
||||
/**
|
||||
* Get template file
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getTemplate(): string;
|
||||
}
|
23
src/AdminPanel/Form/TextInput.php
Normal file
23
src/AdminPanel/Form/TextInput.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace AdminPanel\Form;
|
||||
|
||||
class TextInput implements Input
|
||||
{
|
||||
|
||||
public function getOptions(): array
|
||||
{
|
||||
return array(
|
||||
);
|
||||
}
|
||||
|
||||
public function processOption(string $optionName, $value): array
|
||||
{
|
||||
return array($optionName => $value);
|
||||
}
|
||||
|
||||
public function getTemplate(): string
|
||||
{
|
||||
return "@AdminPanel/form/text.twig";
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user