ZF-2379: Add interface to add references to the ZDT

Description

The current way of adding references to a ZDTA subclass is by providing an array. This is a very verbose and non-intuitive way of setting up the relation, which forces the developer to remember array keys that are actually only interesting for the ZDTA class. I want to suggest adding a method to add a relation to the ZDT instance, which will make the process more intuitive and less error-prone.


    /**
     * Add a reference to the reference map
     *
     * @param string $ruleKey
     * @param string|array $columns
     * @param string $refTableClass
     * @param string|array $refColumns
     * @param string $onDelete
     * @param string $onUpdate
     * @return Zend_Db_Table_Abstract
     */
    public function addReference($ruleKey, $columns, $refTableClass, $refColumns, $onDelete = null, $onUpdate = null)
    {
        $reference = array(self::COLUMNS         => $columns,
                           self::REF_TABLE_CLASS => $refTableClass,
                           self::REF_COLUMNS     => $refColumns);

        if (!empty($onDelete)) {
            $reference[self::ON_DELETE] = $onDelete;
        }

        if (!empty($onUpdate)) {
            $reference[self::ON_UPDATE] = $onUpdate;
        }

        $this->_referenceMap[$ruleKey] = $reference;

        return $this;
    }

Comments

Added diff file

Updated code to use the class constants.

Please categorize/fix as needed.

This doesn't appear to have been fixed in 1.5.0. Please update if this is not correct.

Resolved in r. 13553