<commit_before>Provides integration for DoctrineExtensions_ for your Symfony2 Project.

Features
========

This bundle allows to easyly use DoctrineExtensions_ in your Symfony2
project by configuring it through a ``ListenerManager`` and the DIC.

DoctrineExtensions's features
-----------------------------

- Tree - this extension automates the tree handling process and adds
  some tree specific functions on repository.
- Translatable - gives you a very handy solution for translating
  records into diferent languages. Easy to setup, easier to use.
- Sluggable - urlizes your specified fields into single unique slug
- Timestampable - updates date fields on create, update and even
  property change.

All these extensions can be nested together. And most allready use only
annotations without interface requirement to not to aggregate the
entity itself and has implemented proper caching for metadata.

See the official blog_ for more details.

Installation
============

Add DoctrineExtensions to your vendor dir
-----------------------------------------

::

    git submodule add git://github.com/l3pp4rd/DoctrineExtensions.git vendor/doctrine-extensions

Add DoctrineExtensionsBundle to your src/Bundle dir
---------------------------------------------------

::

    git submodule add git://github.com/stof/DoctrineExtensionsBundle.git src/Stof/DoctrineExtensionsBundle

Register the DoctrineExtensions and Stof namespaces
---------------------------------------------------

::

    // src/autoload.php
    $loader->registerNamespaces(array(
        'Stof' => __DIR__.'/../src',
        'Gedmo' => $vendorDir.'/doctrine-extensions/lib',
        // your other namespaces
    ));

Add DoctrineExtensionsBundle to your application kernel
-------------------------------------------------------

::

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            // ...
        );
    }

Add DoctrineExtensionsBundle to your mapping
--------------------------------------------

See the official documentation_ for details.

for ORM::

    # app/config.yml
    doctrine.orm:
        mappings:
            StofDoctrineExtensionsBundle: ~
            # ... your others bundle

or for MongoDB ODM::

    # app/config.yml
    doctrine_odm.mongodb:
        mappings:
            StofDoctrineExtensionsBundle: ~
            # ... your others bundle

.. Note::

    This is only necessary if you want to use the Translatable behavior.

Configure the bundle
====================

Register the default locale
---------------------------

This bundle uses the session default_locale as the default locale used
if the translation does not exists in the asked language. So you have
to define it in the configuration file (Symfony2 define it to ``en`` by
default).

in YAML::

    # app/config.yml
    app.config:
        session:
            default_locale: en_US

or in XML::

    <!-- app/config.xml -->
    <container>
        <app:config>
            <app:session default-locale="en_US">
        </app:config>
    </container>

Activate the bundle
-------------------

You have to activate the extensions for each entity manager for which
you want to enable the extensions. The id is the id of the DBAL
connection when using the ORM behaviors. It is the id of the document
manager when using mongoDB

in YAML::

    # app/config.yml
    stof_doctrine_extensions.config:
        orm:
            default: ~
        mongodb:
            default: ~

or in XML::

    <!-- app/config.xml -->
    <container xmlns:stof_doctrine_extensions="http://www.symfony-project.org/schema/dic/stof_doctrine_extensions">
        <stof_doctrine_extensions:config>
            <stof_doctrine_extensions:orm>
                <stof_doctrine_extensions:entity-manager id="default" />
            </stof_doctrine_extensions:orm>
            <stof_doctrine_extensions:mongodb>
                <stof_doctrine_extensions:document-manager id="default" />
            </stof_doctrine_extensions:mongodb>
        </stof_doctrine_extensions:config>
    </container>

Use the DoctrineExtensions library
==================================

All explanations about this library are available on the official blog_

The default entity for translations is
``Stof\DoctrineExtensionsBundle\Entity\Translation``. The default
document is ``Stof\DoctrineExtensionsBundle\Document\Translation``.

Creating your own translation entity
------------------------------------

When you have a great number of entries for an entity you should create
a dedicated translation entity to have good performances. The only
difference when using it with Symfony2 is the mapped-superclass to use.

The simpliest way to do it is to copy the default translation entity
and just change the namespace and the class name.

Here is an example for the ORM::

    // src/Application/MyBundle/Entity/MyTranslationEntity.php

    namespace Application\MyBundle\Entity;

    use Stof\DoctrineExtensionsBundle\Entity\AbstractTranslation

    /**
     * Application\MyBundle\Entity\MyTranslationEntity
     *
     * @orm:Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository")
     * @orm:Table(
     *         name="ext_translations",
     *         indexes={@orm:index(name="translations_lookup_idx", columns={
     *             "locale", "entity", "foreign_key"
     *         })},
     *         uniqueConstraints={@orm:UniqueConstraint(name="lookup_unique_idx", columns={
     *             "locale", "entity", "foreign_key", "field"
     *         })}
     * )
     */
    class TranslationEntity extends AbstractTranslation
    {
    }

Same is doable for the ODM.

You can also create your own repositoryClass by extending
``Gedmo\Translatable\Entity\Repository\TranslationRepository`` or<commit_msg>Fixed doc<commit_after>Provides integration for DoctrineExtensions_ for your Symfony2 Project.

Features
========

This bundle allows to easyly use DoctrineExtensions_ in your Symfony2
project by configuring it through a ``ListenerManager`` and the DIC.

DoctrineExtensions's features
-----------------------------

- Tree - this extension automates the tree handling process and adds
  some tree specific functions on repository.
- Translatable - gives you a very handy solution for translating
  records into diferent languages. Easy to setup, easier to use.
- Sluggable - urlizes your specified fields into single unique slug
- Timestampable - updates date fields on create, update and even
  property change.

All these extensions can be nested together. And most allready use only
annotations without interface requirement to not to aggregate the
entity itself and has implemented proper caching for metadata.

See the official blog_ for more details.

Installation
============

Add DoctrineExtensions to your vendor dir
-----------------------------------------

::

    git submodule add git://github.com/l3pp4rd/DoctrineExtensions.git vendor/doctrine-extensions

Add DoctrineExtensionsBundle to your src/Bundle dir
---------------------------------------------------

::

    git submodule add git://github.com/stof/DoctrineExtensionsBundle.git src/Stof/DoctrineExtensionsBundle

Register the DoctrineExtensions and Stof namespaces
---------------------------------------------------

::

    // app/autoload.php
    $loader->registerNamespaces(array(
        'Stof' => __DIR__.'/../src',
        'Gedmo' => __DIR__.'/../vendor/doctrine-extensions/lib',
        // your other namespaces
    ));

Add DoctrineExtensionsBundle to your application kernel
-------------------------------------------------------

::

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
            // ...
        );
    }

Add DoctrineExtensionsBundle to your mapping
--------------------------------------------

See the official documentation_ for details.

for ORM::

    # app/config.yml
    doctrine.orm:
        mappings:
            StofDoctrineExtensionsBundle: ~
            # ... your others bundle

or for MongoDB ODM::

    # app/config.yml
    doctrine_odm.mongodb:
        mappings:
            StofDoctrineExtensionsBundle: ~
            # ... your others bundle

.. Note::

    This is only necessary if you want to use the Translatable behavior.

Configure the bundle
====================

Register the default locale
---------------------------

This bundle uses the session default_locale as the default locale used
if the translation does not exists in the asked language. So you have
to define it in the configuration file (Symfony2 define it to ``en`` by
default).

in YAML::

    # app/config.yml
    app.config:
        session:
            default_locale: en_US

or in XML::

    <!-- app/config.xml -->
    <container>
        <app:config>
            <app:session default-locale="en_US">
        </app:config>
    </container>

Activate the bundle
-------------------

You have to activate the extensions for each entity manager for which
you want to enable the extensions. The id is the id of the DBAL
connection when using the ORM behaviors. It is the id of the document
manager when using mongoDB

in YAML::

    # app/config.yml
    stof_doctrine_extensions.config:
        orm:
            default: ~
        mongodb:
            default: ~

or in XML::

    <!-- app/config.xml -->
    <container xmlns:stof_doctrine_extensions="http://www.symfony-project.org/schema/dic/stof_doctrine_extensions">
        <stof_doctrine_extensions:config>
            <stof_doctrine_extensions:orm>
                <stof_doctrine_extensions:entity-manager id="default" />
            </stof_doctrine_extensions:orm>
            <stof_doctrine_extensions:mongodb>
                <stof_doctrine_extensions:document-manager id="default" />
            </stof_doctrine_extensions:mongodb>
        </stof_doctrine_extensions:config>
    </container>

Use the DoctrineExtensions library
==================================

All explanations about this library are available on the official blog_

The default entity for translations is
``Stof\DoctrineExtensionsBundle\Entity\Translation``. The default
document is ``Stof\DoctrineExtensionsBundle\Document\Translation``.

Creating your own translation entity
------------------------------------

When you have a great number of entries for an entity you should create
a dedicated translation entity to have good performances. The only
difference when using it with Symfony2 is the mapped-superclass to use.

The simpliest way to do it is to copy the default translation entity
and just change the namespace and the class name.

Here is an example for the ORM::

    // src/Application/MyBundle/Entity/MyTranslationEntity.php

    namespace Application\MyBundle\Entity;

    use Stof\DoctrineExtensionsBundle\Entity\AbstractTranslation

    /**
     * Application\MyBundle\Entity\MyTranslationEntity
     *
     * @orm:Entity(repositoryClass="Gedmo\Translatable\Entity\Repository\TranslationRepository")
     * @orm:Table(
     *         name="ext_translations",
     *         indexes={@orm:index(name="translations_lookup_idx", columns={
     *             "locale", "object_class", "foreign_key"
     *         })},
     *         uniqueConstraints={@orm:UniqueConstraint(name="lookup_unique_idx", columns={
     *             "locale", "object_class", "foreign_key", "field"
     *         })}
     * )
     */
    class TranslationEntity extends AbstractTranslation
    {
    }

Same is doable for the ODM.

You can also create your own repositoryClass by extending
``Gedmo\Translatable\Entity\Repository\TranslationRepository`` or
{'fraction_non_alphanumeric': 0.14232558139534884, 'fraction_numerical': 0.001014799154334038, 'mean_word_length': 2.4417927823050056, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 6}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3478492', 'n_tokens_mistral': 3015, 'n_tokens_neox': 2918, 'n_words': 978}