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: 0

Type:propel-behavior

1.0.1 2021-06-18 06:38 UTC

This package is auto-updated.

Last update: 2024-04-18 12:45:15 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

Installation

To enable the builder, you need to

  1. 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>