mirror of
https://github.com/Aviortheking/DeltaCMS.git
synced 2025-04-23 03:12:14 +00:00
Extends classes to Abstract Input
This commit is contained in:
parent
00b1b4cff2
commit
616d1a15b5
30
src/AdminPanel/Form/AbstractInput.php
Normal file
30
src/AdminPanel/Form/AbstractInput.php
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace AdminPanel\Form;
|
||||||
|
|
||||||
|
class AbstractInput implements Input
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getOptions(): array
|
||||||
|
{
|
||||||
|
return array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function processOption(string $optionName, $value): array
|
||||||
|
{
|
||||||
|
return array($optionName => $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getTemplate(): string
|
||||||
|
{
|
||||||
|
$arr = explode('\\', get_class($this));
|
||||||
|
$tpName = strtolower(
|
||||||
|
str_replace(
|
||||||
|
"Input",
|
||||||
|
"",
|
||||||
|
$arr[count($arr) - 1]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return "@AdminPanel/form/" . $tpName . ".twig";
|
||||||
|
}
|
||||||
|
}
|
@ -2,19 +2,12 @@
|
|||||||
|
|
||||||
namespace AdminPanel\Form;
|
namespace AdminPanel\Form;
|
||||||
|
|
||||||
class ChoiceInput extends TextInput
|
class ChoiceInput extends AbstractInput
|
||||||
{
|
{
|
||||||
public function getOptions(): array
|
public function getOptions(): array
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'label',
|
|
||||||
'value',
|
|
||||||
'choices'
|
'choices'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplate(): string
|
|
||||||
{
|
|
||||||
return "@AdminPanel/form/choice.twig";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -2,18 +2,6 @@
|
|||||||
|
|
||||||
namespace AdminPanel\Form;
|
namespace AdminPanel\Form;
|
||||||
|
|
||||||
class DateInput extends TextInput
|
class DateInput extends AbstractInput
|
||||||
{
|
{
|
||||||
public function getOptions(): array
|
|
||||||
{
|
|
||||||
return array(
|
|
||||||
'label',
|
|
||||||
'value',
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getTemplate(): string
|
|
||||||
{
|
|
||||||
return "@AdminPanel/form/date.twig";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,11 @@ namespace AdminPanel\Form;
|
|||||||
|
|
||||||
use AdminPanel\AdminPanel;
|
use AdminPanel\AdminPanel;
|
||||||
|
|
||||||
class EntityInput implements Input
|
class EntityInput extends AbstractInput
|
||||||
{
|
{
|
||||||
public function getOptions(): array
|
public function getOptions(): array
|
||||||
{
|
{
|
||||||
return array(
|
return array(
|
||||||
'label',
|
|
||||||
'entity'
|
'entity'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -25,9 +24,4 @@ class EntityInput implements Input
|
|||||||
$optionName => $value
|
$optionName => $value
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplate(): string
|
|
||||||
{
|
|
||||||
return "@AdminPanel/form/entity.twig";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -18,11 +18,12 @@ class TextInput implements Input
|
|||||||
|
|
||||||
public function getTemplate(): string
|
public function getTemplate(): string
|
||||||
{
|
{
|
||||||
|
$arr = explode('\\', self::class);
|
||||||
$tpName = strtolower(
|
$tpName = strtolower(
|
||||||
str_replace(
|
str_replace(
|
||||||
"Input",
|
"Input",
|
||||||
"",
|
"",
|
||||||
str_split('\\', self::class)[1]
|
$arr[count($arr) - 1]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
return "@AdminPanel/form/" . $tpName . ".twig";
|
return "@AdminPanel/form/" . $tpName . ".twig";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user