私は具体的な継承とPropelモデルのためのサブクラスのリストを見つけるにはどうすればよいです

StackOverflow https://stackoverflow.com/questions/3826136

  •  26-09-2019
  •  | 
  •  

質問

私は私の地元の慈善のためのミニCMSを構築しています(はい、私はフロスプロジェクトを使用することができます知っているが、彼らはカスタムコーディングされたい)。

私のPropelのスキーマが現在のようななります -

<?xml version="1.0" encoding="UTF-8"?>
<database name="sja" defaultIdMethod="native">
    <table name="section">
        <column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true" />
        <column name="title" type="VARCHAR" required="true" />
        <column name="slug" type="VARCHAR" required="true" />
    </table>
    <table name="page">
        <column name="id" type="INTEGER" primaryKey="true" required="true" autoIncrement="true" />
        <column name="title" type="VARCHAR" required="true" />
        <column name="section_id" type="INTEGER" required="true" />
        <foreign-key foreignTable="section">
            <reference local="section_id" foreign="id" />
        </foreign-key>
    </table>
    <table name="static_page">
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="page" />
        </behavior>
        <column name="content" type="LONGVARCHAR" required="true" />
    </table>
    <table name="home_page">
        <behavior name="concrete_inheritance">
            <parameter name="extends" value="page" />
        </behavior>
        <column name="standfirst_title" type="VARCHAR" />
        <column name="standfirst_image" type="VARCHAR" />
        <column name="standfirst_content" type="VARCHAR" />
    </table>

</database>

私は「home_page」と「static_page」が含まれるだろうリストを取得できるようにしたい - 。私は新しいページタイプを追加するたびに手動でこれを作成することなくを

は、このようなリストを取得する簡単な方法はありますか、私はなど?、リフレクションクラスでいくつかの魔法のものを記述する必要があります。

役に立ちましたか?

解決

freenodeの上#propelから右方向に突く後 - 私は基本概念のためにこれを作ってみた -

けれどもまだそれをテストしていません
function getSubClasses()
{
    $map = $this->getDatabaseMap();
    $children = array();
    foreach ($map->getRelations() AS $relation)
    {
        $behaviours = $relation->getRightTable()->getBehaviours();

        if (issset($behaviours['concrete_inheritance']['extends']) AND $behaviours['concrete_inheritance']['extends'] == $this->getDatabaseMap()->getClassName())
        {
            $children[] = $relation->getRightTable()->getClassName();
        }
    }
    return $children;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top