2017 © Pedro Peláez
 

symfony-bundle labels-bundle

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

image

astina/labels-bundle

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  • Tuesday, May 3, 2016
  • by pkraeutli
  • Repository
  • 15 Watchers
  • 0 Stars
  • 1,015 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Astina Labels Bundle

Add categorized translatable labels to Doctrine entities and use them for filtered search., (*1)

Configuration

Add the following to your AppKernel.php file, (*2)

class AppKernel extends Kernel {
    public function registerBundles() {
        $bundles = array(
            ...
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            new Astina\Bundle\LabelsBundle\AstinaLabelsBundle(),
            ...
        );
    }
}

Add the following to your config.yml, (*3)

stof_doctrine_extensions:
    default_locale: de
    translation_fallback: true
    orm:
        default:
            translatable: true

doctrine:
    orm:
        mappings:
            gedmo_translatable:
                type: annotation
                prefix: Gedmo\Translatable\Entity
                dir: "%kernel.root_dir%/../vendor/gedmo/doctrine-extensions/lib/Gedmo/Translatable/Entity"
                is_bundle: false

Usage

Add labels property to your entity:, (*4)

class Foo
{
    // ...

    /**
     * @ORM\ManyToMany(targetEntity="Astina\Bundle\LabelsBundle\Entity\Label")
     */
    private $labels;
}

Use it in a formType like this:, (*5)

    $builder
        ->add('labels', 'astina_labels', array(
            'categories' => array('category1', 'category2'...),
            'label' => 'Labels',
            'required' => false,
        ))
    ;

Each label has to belong to a category if you want to see them in a formType so configure them with fixtures., (*6)

    public function load(ObjectManager $manager)
    {
        $labelCategory = new LabelCategory();
        $labelCategory->setName('category1');
        $manager->persist($labelCategory);

        foreach ($labelsArray as $labelName) {
            $label = new Label();
            $label->setName($labelName);
            $label->setCategory($labelCategory);
            $manager->persist($label);
        }
        $manager->flush();
    }

Configure a filter search service:, (*7)

# .../config/services.yml
services:
    app.filter_search.foo:
        class: Astina\Bundle\LabelsBundle\Search\LabelSearch
        #class: Astina\Bundle\LabelsBundle\Search\TranslatedLabelSearch
        arguments:
            - @astina_labels.repository.label
            - @app.repository.foo

    app.repository.foo:
        class: Doctrine\ORM\EntityRepository
        factory_service: doctrine
        factory_method: getRepository
        arguments:
            - AppMyBundle:Foo

Use the service to find entities for given labels:, (*8)

$search = $container->get('app.filter_search.foo');
$results = $search->search(new SearchQuery($labels));

The Versions

03/05 2016

dev-master

9999999-dev http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels

03/05 2016

0.4.0

0.4.0.0 http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels

13/08 2015

0.3.0

0.3.0.0 http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels

23/10 2014

0.2.2

0.2.2.0 http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels

12/08 2014

0.2.1

0.2.1.0 http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels

12/08 2014

0.2.0

0.2.0.0 http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels

08/05 2014

0.1.1

0.1.1.0 http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels

06/05 2014

0.1.0

0.1.0.0 http://astina.ch

Symfony bundle that offers categorized labels for Doctrine entities to be used for filtered search.

  Sources   Download

MIT

The Requires

 

by Astina AG

filter search labels