mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
move bundle to root dir for inclusion in packagist refs #259
This commit is contained in:
91
CustomFields/CustomFieldAddress.php
Normal file
91
CustomFields/CustomFieldAddress.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||
|
||||
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldDataTransformer;
|
||||
use Chill\CustomFieldsBundle\Form\AdressType;
|
||||
|
||||
/**
|
||||
* Description of CustomFieldAddress
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CustomFieldAddress implements CustomFieldInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
public $om;
|
||||
|
||||
public function __construct(EntityManagerInterface $om)
|
||||
{
|
||||
$this->om = $om;
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
||||
{
|
||||
$builder->add(
|
||||
$builder->create('address', 'entity', array(
|
||||
'class' => 'ChillCustomFieldsBundle:Adress',
|
||||
'multiple' => true,
|
||||
'expanded' => true
|
||||
)
|
||||
)->addModelTransformer(new CustomFieldDataTransformer(
|
||||
$this,
|
||||
$customField)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'CF address';
|
||||
}
|
||||
|
||||
public function render($value, CustomField $customField)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public function deserialize($serialized, CustomField $customField)
|
||||
{
|
||||
// if ($serialized === NULL) {
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// return $this->om->getRepository('ChillCustomFieldsBundle:Adress')
|
||||
// ->find($serialized);
|
||||
|
||||
return $this->om->getRepository('ChillCustomFieldsBundle:Adress')
|
||||
->findBy(array('id' => $serialized));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Chill\CustomFieldsBundle\Entity\Adress $value
|
||||
* @param CustomField $customField
|
||||
* @return type
|
||||
*/
|
||||
public function serialize($value, CustomField $customField)
|
||||
{
|
||||
$arrayId = array();
|
||||
|
||||
foreach($value as $address) {
|
||||
$arrayId[] = $address->getId();
|
||||
}
|
||||
|
||||
return $arrayId;
|
||||
}
|
||||
|
||||
}
|
19
CustomFields/CustomFieldChoiceWithOther.php
Normal file
19
CustomFields/CustomFieldChoiceWithOther.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
|
||||
namespace;
|
||||
|
||||
/**
|
||||
* Description of CustomFieldChoiceWithOther
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CustomFieldChoiceWithOther
|
||||
{
|
||||
//put your code here
|
||||
}
|
57
CustomFields/CustomFieldInterface.php
Normal file
57
CustomFields/CustomFieldInterface.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
interface CustomFieldInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder
|
||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||
* @return \Symfony\Component\Form\FormTypeInterface the form type
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, CustomField $customField);
|
||||
|
||||
/**
|
||||
* transform the value into a format that can be stored in DB
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||
*/
|
||||
public function serialize($value, CustomField $customField);
|
||||
|
||||
/**
|
||||
* Transform the representation of the value, stored in db, into the
|
||||
* value which may be used in the process.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||
*/
|
||||
public function deserialize($serialized, CustomField $customField);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $value
|
||||
* @param \Chill\CustomFieldsBundle\CustomField\CustomField $customField
|
||||
*/
|
||||
public function render($value, CustomField $customField);
|
||||
|
||||
public function getName();
|
||||
|
||||
/**
|
||||
* return a formType which allow to edit option for the custom type.
|
||||
* This FormType is shown in admin
|
||||
*
|
||||
* @param \Chill\CustomFieldsBundle\CustomField\FormBuilderInterface $builder
|
||||
* @return \Symfony\Component\Form\FormTypeInterface|null the form type
|
||||
*/
|
||||
public function buildOptionsForm(FormBuilderInterface $builder);
|
||||
}
|
49
CustomFields/CustomFieldText.php
Normal file
49
CustomFields/CustomFieldText.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
|
||||
|
||||
namespace Chill\CustomFieldsBundle\CustomFields;
|
||||
|
||||
use Chill\CustomFieldsBundle\CustomFields\CustomFieldInterface;
|
||||
use Chill\CustomFieldsBundle\Entity\CustomField;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CustomFieldText implements CustomFieldInterface
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, CustomField $customField)
|
||||
{
|
||||
$builder->add($customField->getSlug(), 'text', array(
|
||||
'label' => $customField->getLabel()
|
||||
));
|
||||
}
|
||||
|
||||
public function render($value, CustomField $customField)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function serialize($value, CustomField $customField)
|
||||
{
|
||||
return $value;
|
||||
}
|
||||
|
||||
public function deserialize($serialized, CustomField $customField)
|
||||
{
|
||||
return $serialized;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'text field';
|
||||
}
|
||||
|
||||
public function buildOptionsForm(FormBuilderInterface $builder)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user