Skip to content

Instantly share code, notes, and snippets.

@webdevilopers
Last active December 3, 2016 11:08
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 webdevilopers/9a2cb92f80fc3fd100be324c65b005ad to your computer and use it in GitHub Desktop.
Save webdevilopers/9a2cb92f80fc3fd100be324c65b005ad to your computer and use it in GitHub Desktop.
Doctrine Single Table Inheritance working with YAML service configuration but not XML
<?php
namespace Sps\Bundle\PriceQuoteBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* PriceQuoteRequest
*
* @ORM\Entity(repositoryClass="Sps\PriceQuote\Infrastructure\Persistence\Doctrine\DoctrinePriceQuoteRepository")
* @ORM\InheritanceType("SINGLE_TABLE"))
* @ORM\DiscriminatorColumn(name="type", type="integer")
* @ORM\DiscriminatorMap({
* "1" = "DormerPriceQuote",
* "2" = "BayWindowPriceQuote"
* })
*/
abstract class PriceQuoteRequest
extends AbstractPriceQuote
implements PriceQuote
{}
<?xml version="1.0" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<services>
<service id="sps.price_quote.repository.dormer"
class="Doctrine\ORM\EntityRepository">
<factory class="%doctrine.orm.entity_manager.class%" method="getRepository"/>
<argument>Plusquam\Bundle\PriceQuoteBundle\Entity\DormerPriceQuote</argument>
</service>
</services>
</container>
services:
sps.price_quote.repository.dormer:
class: Doctrine\ORM\EntityRepository
factory: [ "%doctrine.orm.entity_manager.class%", getRepository ]
arguments:
- Sps\Bundle\PriceQuoteBundle\Entity\PriceQuoteRequest
public: false
@webdevilopers
Copy link
Author

webdevilopers commented Dec 3, 2016

Using the YAML configuration works just fine. But XML throws:

Using $this when not in object context

Any idea?

Came from:

@webdevilopers
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment