Migrations\View\Helper\MigrationHelper::constraints PHP Method

constraints() public method

Returns an array of constraints for a given table
public constraints ( string $table ) : array
$table string Name of the table to retrieve constraints for
return array
    public function constraints($table)
    {
        $tableSchema = $table;
        if (!$table instanceof Table) {
            $tableSchema = $this->schema($table);
        }
        $constraints = [];
        $tableConstraints = $tableSchema->constraints();
        if (empty($tableConstraints)) {
            return $constraints;
        }
        if ($tableConstraints[0] === 'primary') {
            unset($tableConstraints[0]);
        }
        if (!empty($tableConstraints)) {
            foreach ($tableConstraints as $name) {
                $constraint = $tableSchema->constraint($name);
                if (isset($constraint['update'])) {
                    $constraint['update'] = strtoupper(Inflector::underscore($constraint['update']));
                    $constraint['delete'] = strtoupper(Inflector::underscore($constraint['delete']));
                }
                $constraints[$name] = $constraint;
            }
        }
        return $constraints;
    }