Example #1
0
    public function getAttributes($type, $visibility, \Phalcon\Db\ColumnInterface $field, $annotate = false, $customFieldName = null)
    {
        $fieldName = $customFieldName ?: $field->getName();
        if ($annotate) {
            $templateAttributes = <<<EOD
    /**
     *
     * @var %s%s%s
     * @Column(type="%s"%s, nullable=%s)
     */
    %s \$%s;
EOD;
            return PHP_EOL . sprintf($templateAttributes, $type, $field->isPrimary() ? PHP_EOL . '     * @Primary' : '', $field->isAutoIncrement() ? PHP_EOL . '     * @Identity' : '', $type, $field->getSize() ? ', length=' . $field->getSize() : '', $field->isNotNull() ? 'false' : 'true', $visibility, $fieldName) . PHP_EOL;
        } else {
            $templateAttributes = <<<EOD
    /**
     *
     * @var %s
     */
    %s \$%s;
EOD;
            return PHP_EOL . sprintf($templateAttributes, $type, $visibility, $fieldName) . PHP_EOL;
        }
    }