2017 © Pedro Peláez
 

symfony-bundle simple-metadata-bundle

Symfony SimpleMetadataBundle

image

idci/simple-metadata-bundle

Symfony SimpleMetadataBundle

  • Tuesday, June 26, 2018
  • by idciconsulting
  • Repository
  • 9 Watchers
  • 3 Stars
  • 14,922 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 28 Versions
  • 5 % Grown

The README.md

SimpleMetadataBundle

Symfony2 simple metadata bundle, (*1)

Installation

To install this bundle please follow the next steps:, (*2)

First add the dependency in your composer.json file:, (*3)

"require": {
        ...,
        "idci/simple-metadata-bundle": "dev-master"
    },

Then install the bundle with the command:, (*4)

php composer update

Enable the bundle in your application kernel:, (*5)

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        ...
        new IDCI\Bundle\SimpleMetadataBundle\IDCISimpleMetadataBundle(),
    );
}

Now import the bundle configuration in your app/config/config.yml, (*6)

imports:
    ...
    - { resource: @IDCISimpleMetadataBundle/Resources/config/config.yml }

Now the Bundle is installed and configured., (*7)

How to use

OneToOne Relation with a metadata:

In your entity:, (*8)

/**
 * @var Metadata
 *
 * @ORM\OneToOne(targetEntity="IDCI\Bundle\SimpleMetadataBundle\Entity\Metadata", cascade={"all"})
 * @ORM\JoinColumn(name="metadata_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
 */
private $metadata;

In this entity form type:, (*9)

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ...
        ->add('metadata', 'related_to_one_metadata', array(
            'data' => $builder->getData()->getMetadata()
        ))
        ...
    ;
}

ManyToMany Relation with a metadata:

In your entity:, (*10)

/**
 * @var array<Metadata>
 *
 * @ORM\ManyToMany(targetEntity="IDCI\Bundle\SimpleMetadataBundle\Entity\Metadata", cascade={"all"})
 * @ORM\JoinTable(name="my_entity_metadata",
 *     joinColumns={@ORM\JoinColumn(name="my_entity_id", referencedColumnName="id", onDelete="cascade")},
 *     inverseJoinColumns={@ORM\JoinColumn(name="metadata_id", referencedColumnName="id", unique=true, onDelete="cascade")}
 * )
 */
private $metadatas;

In this entity form type:, (*11)

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ...
        ->add('metadatas', 'related_to_many_metadata')
        ...
    ;
}

Without metadata entity relation:

In your entity:, (*12)

/**
 * @var string
 *
 * @ORM\Column(name="metadata", type="textarea")
 */
private $metadata;

In this entity form type:, (*13)

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ...
        ->add('metadata', 'metadata')
        ...
    ;
}

Advanced form usage

The metadata form type accept a fields options ex:, (*14)

    $builder
        ...
        ->add('metadata', 'metadata', array(
            'fields' => array(
                'firstName' => array('text'),
                'lastName' => array('text'),
                'address' => array('text'),
                'city' => array('text'),
                'country' => array('text'),
                'message' => array('textarea')
            )
        ))
        ...
    ;

This bundle provide a json form type which is realy usefull to store a json (must be used on a Text mapped field)., (*15)

Custom namespace

You can create your own namespace, without asking it in the form., (*16)

First declare them like this:, (*17)

idci_simple_metadata:
    namespaces: [tags, features]

If you take a look at the container:debug you will see that new form type are now available:, (*18)

$ php app/console container:debug
...
form.type.form.type.related_to_one_metadata_features               container IDCI\Bundle\SimpleMetadataBundle\Form\Type\RelatedToOneMetadataType
form.type.form.type.related_to_one_metadata_tags                   container IDCI\Bundle\SimpleMetadataBundle\Form\Type\RelatedToOneMetadataType
form.type.related_to_many_metadata_features                        container IDCI\Bundle\SimpleMetadataBundle\Form\Type\RelatedToManyMetadataType
form.type.related_to_many_metadata_tags                            container IDCI\Bundle\SimpleMetadataBundle\Form\Type\RelatedToManyMetadataType
...

simply use them in your form builder:, (*19)

    $builder
        ...
        ->add('features', 'related_to_many_metadata_features')
        ->add('tags', 'related_to_many_metadata_tags')
        ...
    ;

The Versions

26/06 2018

dev-master

9999999-dev

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0+ GPL-3.0-or-later

The Requires

 

form metadata

26/06 2018

1.5.x-dev

1.5.9999999.9999999-dev

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0-or-later

The Requires

 

form metadata

26/06 2018
04/05 2018

dev-fix/symfony3-compatibility

dev-fix/symfony3-compatibility

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0-or-later

The Requires

 

form metadata

10/04 2018
05/04 2018
24/02 2018
24/02 2018

dev-compatibility/3.4

dev-compatibility/3.4

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0-or-later

The Requires

 

form metadata

23/02 2018
01/02 2018
01/02 2018

1.4.x-dev

1.4.9999999.9999999-dev

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0-or-later

The Requires

 

form metadata

01/02 2018
25/01 2018

1.3.x-dev

1.3.9999999.9999999-dev

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0+ GPL-3.0-or-later

The Requires

 

form metadata

25/01 2018
23/08 2017
23/05 2017

dev-feature/tags-behaviour

dev-feature/tags-behaviour

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0+

The Requires

 

form metadata

06/04 2017
30/03 2017

dev-feature/find-by-metadata

dev-feature/find-by-metadata

Symfony SimpleMetadataBundle

  Sources   Download

GPL-3.0+

The Requires

 

form metadata

23/03 2017
06/04 2016
04/02 2016
29/09 2015
24/06 2015