Skip to content

Instantly share code, notes, and snippets.

@desarrolla2
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save desarrolla2/61624386e8f7d66f0e80 to your computer and use it in GitHub Desktop.
Save desarrolla2/61624386e8f7d66f0e80 to your computer and use it in GitHub Desktop.
# Doctrine Configuration
doctrine:
orm:
auto_generate_proxy_classes: "%kernel.debug%"
entity_managers:
default:
mappings:
FOSUserBundle: ~
SonataMediaBundle: ~
ApplicationSonataMediaBundle: ~
CoreBundle: ~
TadiumPromotionBundle:
prefix: 'Tadium\Component\Promotion\Model'
<?xml version="1.0" encoding="UTF-8" ?>
<doctrine-mapping
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"
xmlns:gedmo="http://gediminasm.org/schemas/orm/doctrine-extensions-mapping">
<entity name="Tadium\Component\Promotion\Model\Promotion"
repository-class="Tadium\Bundle\PromotionBundle\Repository\PromotionRepository"
table="promotion">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>
<field name="name" column="name" type="string" length="255"/>
<field name="description" column="description" type="text"/>
<field name="discount" column="discount" type="decimal" scale="2"/>
<field name="isActive" column="is_active" type="boolean"/>
<field name="startsAt" column="starts_at" type="datetime" nullable="true"/>
<field name="endsAt" column="ends_at" type="datetime" nullable="true"/>
<field name="createdAt" type="datetime">
<gedmo:timestampable on="create"/>
</field>
<field name="updatedAt" type="datetime">
<gedmo:timestampable on="update"/>
</field>
<one-to-many field="coupons" target-entity="Tadium\Component\Promotion\Model\Coupon"
mapped-by="promotion"/>
</entity>
</doctrine-mapping>
<?php
namespace Tadium\Bundle\PromotionBundle;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Doctrine\Bundle\DoctrineBundle\DependencyInjection\Compiler\DoctrineOrmMappingsPass;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Class TadiumPromotionBundle
*/
class TadiumPromotionBundle extends Bundle
{
/**
* @param ContainerBuilder $container
*/
public function build(ContainerBuilder $container)
{
$this->addRegisterMappingsPass($container);
}
/**
* {@inheritDoc}
*/
public function boot()
{
$this->addEntityNamespace($this->container);
}
/**
* @param ContainerInterface $container
*/
protected function addEntityNamespace(ContainerInterface $container)
{
/** @var \Doctrine\ORM\Configuration $configuration */
$configuration = $container->get('doctrine')->getManager()->getConfiguration();
$configuration->addEntityNamespace('TadiumPromotionBundle', 'Tadium\\Component\\Promotion\\Model');
}
/**
* @param ContainerBuilder $container
*/
protected function addRegisterMappingsPass(ContainerBuilder $container)
{
$mappings = [
realpath(__DIR__ . '/Resources/config/doctrine/model') => 'Tadium\Component\Promotion\Model',
];
$container->addCompilerPass(
DoctrineOrmMappingsPass::createXmlMappingDriver(
$mappings,
['doctrine.orm.entity_manager']
)
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment