ソースを参照

Merge branch 'develop' of https://gitea.laclic.fr/Laclic/SovBundle into develop

feature/ticket
Charly 3年前
コミット
623f2eca07
3個のファイルの変更51行の追加4行の削除
  1. +48
    -0
      Factory/AbstractFactory.php
  2. +1
    -2
      Field/ImageManagerField.php
  3. +2
    -2
      Resources/views/adminlte/crud/form_theme.html.twig

+ 48
- 0
Factory/AbstractFactory.php ファイルの表示

@@ -0,0 +1,48 @@
<?php

namespace Lc\SovBundle\Factory;

use Doctrine\ORM\EntityManagerInterface;

abstract class AbstractFactory
{
protected $em ;

public function __construct(EntityManagerInterface $em)
{
$this->em = $em ;
}

public function create($params = array())
{
$entityClass = $this->em->getEntityName($this->getEntityClass());

if ($entityClass && strlen($entityClass) > 0) {
$entity = new $entityClass();
$this->populate($entity, $params);

return $entity;
}
else {
throw new \ErrorException('La classe de l\'entité n\'est pas définie.');
}
}

public function populate($entity, $params = array())
{
$entityArray = (array)$entity;

foreach ($entityArray as $name => $value) {
$nameArray = explode("\x00", $name);
$name = $nameArray[2];

if ($name != 'id' && isset($params[$name])) {
$setter = 'set' . ucfirst($name);

if (method_exists($entity, $setter)) {
$entity->$setter($params[$name]);
}
}
}
}
}

+ 1
- 2
Field/ImageManagerField.php ファイルの表示

@@ -5,7 +5,6 @@ namespace Lc\SovBundle\Field;
use EasyCorp\Bundle\EasyAdminBundle\Contracts\Field\FieldInterface;
use EasyCorp\Bundle\EasyAdminBundle\Field\FieldTrait;
use Lc\SovBundle\Form\Common\FileManagerType;
use Symfony\Component\Form\Extension\Core\Type\TextType;

/**
* @author La clic ! <contact@laclic.fr>
@@ -23,7 +22,7 @@ final class ImageManagerField implements FieldInterface
->setProperty($propertyName)
->setLabel($label)
->setTemplatePath('@LcSov/adminlte/crud/field/image.html.twig')
->addWebpackEncoreEntries('adminlte-field-filemanager')
//->addWebpackEncoreEntries('adminlte-field-filemanager')
->setFormType(FileManagerType::class)
->setCustomOption('managerDir', 'image')
->setCustomOption('type', 'image')

+ 2
- 2
Resources/views/adminlte/crud/form_theme.html.twig ファイルの表示

@@ -150,8 +150,8 @@
{% set managerDir = form.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %}
{% set type = form.vars.ea_crud_form.ea_field.customOptions.get('type') %}
{% else %}
{% set managerDir = form.parent.vars.ea_crud_form.ea_field.customOptions.get('managerDir') %}
{% set type = form.parent.vars.ea_crud_form.ea_field.customOptions.get('type') %}
{% set managerDir = form.vars.attr.type %}
{% set type = form.vars.attr.type %}
{% endif %}

<div class="lc-filemanager row">

読み込み中…
キャンセル
保存