Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

webdevilopers commented Dec 3, 2016

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