[FLOW3-general] inheritance and repositories

Mathis Hoffmann mathis at hoffpost.de
Mon Apr 8 12:02:02 CEST 2013


Hey Steffen,

thank you for your help. That works!!

Yours
Mathis

Am 05.04.2013 23:41, schrieb Steffen Wickham:
> Hey Mathis,
>
> I'm sorry, I assumed you already tagged your base class correctly. My
> mistake, sorry!
>
> You have to add some annotations for your base class (AbstractAssignment
> for me), so Doctrine/DBAL can create the right scheme. That's how I
> annotate my base class:
>
> <?php
> namespace AFSVN\Basic\Domain\Model;
>
> use Doctrine\ORM\Mapping as ORM;
> use TYPO3\Flow\Annotations as Flow;
>
> /**
>   * @Flow\Entity
>   * @ORM\InheritanceType("JOINED")
>   */
> abstract class AbstractAssignment {
>      ... (all shared values goes here) ...
> }
> ?>
>
>
> So Doctrine creates a afsvn_basic_domain_model_abstractassignment table
> with your shared values and a column "dtype", which holds a string
> representation of you derived class, e.g. afsvn_basic_refereeassignment.
> In the "afsvn_basic_domain_model_refereeassignment" table it use the
> same identifier as the abstract table and holds only the
> refereeassignment specific data. When you try to access an object by the
> created repository, doctrine joins all data correctly, whether which
> concrete class has been fetched.
>
> Yours
> Steffen
>
>
> Am 05.04.2013 23:30, schrieb Mathis Hoffmann:
>> Hey Steffen,
>>
>> thank you for your quick reply!
>>
>> I just tried out your solution but it doesn't work for me. Did you
>> maybe mark your AbstractAssignment as an entity? Marking Customer as
>> an entity would not make sense for me because Doctrine would create a
>> table that will never be filled with any values (because Customer is
>> an abstract class)..
>>
>> Yours
>> Mathis
>>
>> ---
>> Mathis Hoffmann
>> Tilsiter Straße 14
>> 70374 Stuttgart
>>
>> Telefon: 0711 / 933 018 87
>> Mobil: 0176 235 747 41
>> E-Mail: mathis at hoffpost.de
>>
>> Am 05.04.2013 22:05, schrieb Steffen Wickham:
>>> Hi Mathis,
>>>
>>> /**
>>>    * Repository for parties
>>>    *
>>>    * @Flow\Scope("singleton")
>>>    */
>>> class AssignmentRepository extends \TYPO3\Flow\Persistence\Repository {
>>>       const ENTITY_CLASSNAME =
>>> 'AFSVN\Basic\Domain\Model\AbstractAssignment';
>>> }
>>> ?>
>>> it's a really simple solution! I will post my repository but some
>>> explanation first:
>>>
>>> I'd created two concrete classes called "RefereeAssignment" and
>>> "ClubAssignment" which are derived from the same base class
>>> "AbstractAssignment". All data can be accessed by the
>>> "AssignmentRepository" which only consists of the following code:
>>>
>>> <?php
>>> namespace AFSVN\Basic\Domain\Repository;
>>> use TYPO3\Flow\Annotations as Flow;
>>>
>>> /**
>>>    * Repository for parties
>>>    *
>>>    * @Flow\Scope("singleton")
>>>    */
>>> class AssignmentRepository extends \TYPO3\Flow\Persistence\Repository {
>>>       const ENTITY_CLASSNAME =
>>> 'AFSVN\Basic\Domain\Model\AbstractAssignment';
>>> }
>>> ?>
>>>
>>>
>>> So you only have to set the base class as entity for the Repository
>>> manually, otherwise Flow will determine the type itself.
>>>
>>> Yours
>>> Steffen
>>>
>>>
>>>
>>> Am 05.04.2013 21:51, schrieb Mathis Hoffmann:
>>>> Hi!
>>>>
>>>> I have some trouble implementing inheritance in my FLOW-app. The
>>>> situation is as follows: I have an abstract superclass Customer with
>>>> two subclasses BusinessCustomer and PrivateCustomer. Inheritance
>>>> itself is working as it should. What I want to achieve now is that I
>>>> have a CustomerRepository which enables me to list all Customers.
>>>> Creating such a repository and a corresponding actioncontroller ends
>>>> up in "No class schema found for
>>>> "HdM\Accounting\Domain\Model\Customer"". Does anyone have a solution
>>>> how that could work?
>>>>
>>>> Thank's in advance!
>>>> Mathis Hoffmann
>>>>
>>>>
>>>> _______________________________________________
>>>> FLOW3-general mailing list
>>>> FLOW3-general at lists.typo3.org
>>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>>> _______________________________________________
>>> FLOW3-general mailing list
>>> FLOW3-general at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
>>
>>
>> _______________________________________________
>> FLOW3-general mailing list
>> FLOW3-general at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general
> _______________________________________________
> FLOW3-general mailing list
> FLOW3-general at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/flow3-general



More information about the FLOW3-general mailing list