chq81 / query-inheritance-base-behavior
Propel 2 Query Inheritance Behavior to provide generic base query class for query inheritance objects
Installs: 3 182
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 1
Type:propel-behavior
Requires
- chq81/query-inheritance-behavior-builder: ^1.0
- propel/propel: dev-master || 2.0.0-alpha10
This package is auto-updated.
Last update: 2025-03-06 16:51:51 UTC
README
Propel 2 Behavior to customize the inheritance for query objects in a single inheritance setup
License
MIT License
copyright (c) 2015 Christoph Quadt
Functionality
If there is a single inheritance set on a propel class, the current way of inheriting is:
FantasyBookQuery
=> BaseFantasyBookQuery
=> BaseBookQuery
=> ModelCriteria
This Builder provides the following setup:
FantasyBookQuery
=> BaseFantasyBookQuery
=> **BookQuery**
or
=> **MyCustomQuery**
=> BaseBookQuery
=> ModelCriteria
Requirements
This behavior requires
- Propel2 >= 2.0@dev
- QueryInheritanceBehaviorBuilder >= 1.0.0
Installation
To enable the builder, you need to
- reference the QueryInheritanceBehaviorBuilder as a custom builder in the propel settings:
propel.generator.objectModel.builders.queryinheritance = chq81\\CustomQueryInheritance\\Builder\\CustomQuerySingleInheritanceBuilder
2a. enable the behavior in the schema.xml for inheriting from the default query class (BookQuery):
<table name="book"> <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" /> <column name="title" type="VARCHAR" required="true" /> <column name="genre" phpName="Genre" type="INTEGER" size="11" required="true" defaultValue="0" inheritance="single"> <inheritance key="1" class="FantasyBook" extends="Book" /> <inheritance key="2" class="HorrorBook" extends="Book" /> </column> <behavior name="custom-query-inheritance" /> </table>
2b. enable the behavior in the schema.xml for inheriting from the custom query class (MyCustomQuery):
<table name="book"> <column name="id" required="true" primaryKey="true" autoIncrement="true" type="INTEGER" /> <column name="title" type="VARCHAR" required="true" /> <column name="genre" phpName="Genre" type="INTEGER" size="11" required="true" defaultValue="0" inheritance="single"> <inheritance key="1" class="FantasyBook" extends="Book" /> <inheritance key="2" class="HorrorBook" extends="Book" /> </column> <behavior name="custom-query-inheritance"> <parameter name="base" value="[NAMESPACE]\\MyCustomQuery" /> </behavior> </table>