Reply to thread

Entity code:

[CODE=php]<?php


namespace DBTech\eCommerce\Entity;


use XF\Entity\AbstractPrefixMap;

use XF\Mvc\Entity\Structure;


/**

 * COLUMNS

 * @property int category_id

 * @property int prefix_id

 *

 * RELATIONS

 * @property \DBTech\eCommerce\Entity\ProductPrefix Prefix

 * @property \DBTech\eCommerce\Entity\Category Category

 */

class CategoryPrefix extends AbstractPrefixMap

{

    /**

     * @return string|void

     */

    public static function getContainerKey()

    {

        return 'category_id';

    }

   

    /**

     * @param Structure $structure

     *

     * @return Structure

     */

    public static function getStructure(Structure $structure)

    {

        self::setupDefaultStructure($structure, 'xf_dbtech_ecommerce_category_prefix', 'DBTech\eCommerce:CategoryPrefix', 'DBTech\eCommerce:ProductPrefix');


        $structure->relations['Category'] = [

            'entity' => 'DBTech\eCommerce:Category',

            'type' => self::TO_ONE,

            'conditions' => 'category_id',

            'primary' => true

        ];


        return $structure;

    }

}[/CODE]


Generated the following output:

[CODE=php]$this->schemaManager()->createTable('xf_dbtech_ecommerce_category_prefix', function(\XF\Db\Schema\Create $table)

{

        $table->addColumn('category_id', 'int');

        $table->addColumn('prefix_id', 'int');

        $table->addPrimaryKey(['category_id', 'prefix_id'])

});

[/CODE]


Hardly a showstopper, maybe this is another "magical behaviour" that's intended to teach people to use IDEs? ;)



Fillip


Back
Top Bottom