mirror of
https://github.com/jbcr/core.git
synced 2026-04-23 08:38:04 +02:00
Fix fixtures to create correct fields.
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Bolt\Content;
|
||||
|
||||
use Bolt\Entity\Field;
|
||||
|
||||
final class FieldFactory
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $name
|
||||
* @return Field
|
||||
*/
|
||||
public static function get(string $name)
|
||||
{
|
||||
$classname = '\\Bolt\\Entity\\Field\\'. $name .'Field';
|
||||
if (class_exists($classname)) {
|
||||
$field = new $classname;
|
||||
} else {
|
||||
$field = new Field();
|
||||
}
|
||||
|
||||
return $field;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ declare(strict_types=1);
|
||||
namespace Bolt\DataFixtures;
|
||||
|
||||
use Bolt\Configuration\Config;
|
||||
use Bolt\Content\FieldFactory;
|
||||
use Bolt\Entity\Content;
|
||||
use Bolt\Entity\Field;
|
||||
use Bolt\Entity\User;
|
||||
@@ -86,9 +87,8 @@ class ContentFixtures extends Fixture
|
||||
|
||||
$sortorder = 1;
|
||||
foreach ($contentType->fields as $name => $fieldType) {
|
||||
$field = new Field();
|
||||
$field = FieldFactory::get($fieldType['type']);
|
||||
$field->setName($name);
|
||||
$field->setType($fieldType['type']);
|
||||
$field->setValue($this->getValuesforFieldType($fieldType));
|
||||
$field->setSortorder($sortorder++ * 5);
|
||||
|
||||
|
||||
+4
-11
@@ -14,7 +14,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* @ORM\InheritanceType("SINGLE_TABLE")
|
||||
* @ORM\DiscriminatorColumn(name="type", type="string")
|
||||
* @ORM\DiscriminatorMap({
|
||||
* "text" = "Bolt\Entity\Field\TextField",
|
||||
* "generic" = "field",
|
||||
* "block" = "Bolt\Entity\Field\BlockField",
|
||||
* "checkbox" = "Bolt\Entity\Field\CheckboxField",
|
||||
* "date" = "Bolt\Entity\Field\DateField",
|
||||
@@ -24,6 +24,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* "filelist" = "Bolt\Entity\Field\FilelistField",
|
||||
* "float" = "Bolt\Entity\Field\FloatField",
|
||||
* "geolocation" = "Bolt\Entity\Field\GeolocationField",
|
||||
* "hidden" = "Bolt\Entity\Field\HiddenField",
|
||||
* "html" = "Bolt\Entity\Field\HtmlField",
|
||||
* "image" = "Bolt\Entity\Field\ImageField",
|
||||
* "imagelist" = "Bolt\Entity\Field\ImagelistField",
|
||||
@@ -33,10 +34,9 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* "select" = "Bolt\Entity\Field\SelectField",
|
||||
* "slug" = "Bolt\Entity\Field\SlugField",
|
||||
* "templateselect" = "Bolt\Entity\Field\TemplateselectField",
|
||||
* "text" = "Bolt\Entity\Field\TextField",
|
||||
* "textarea" = "Bolt\Entity\Field\TextareaField",
|
||||
* "video" = "Bolt\Entity\Field\VideoField",
|
||||
* "hidden" = "Bolt\Entity\Field\HiddenField",
|
||||
* "generic" = "field"
|
||||
* "video" = "Bolt\Entity\Field\VideoField"
|
||||
* })
|
||||
*/
|
||||
class Field
|
||||
@@ -143,13 +143,6 @@ class Field
|
||||
return $this->getDefinition()->type;
|
||||
}
|
||||
|
||||
public function setType(string $type): self
|
||||
{
|
||||
$this->type = $type;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get($key)
|
||||
{
|
||||
return $this->value[$key];
|
||||
|
||||
Reference in New Issue
Block a user