Fixed xf-dev:generate-schema-entity missing ; after $table->addPrimaryKey() if the PK is a compound key

DragonByte Tech

Well-known member
Affected version
2.0.1
Entity 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;
    }
}

Generated the following output:
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'])
});

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


Fillip
 
Back
Top Bottom