schmunk42/gii-template-collection

reimplement autom model behaviors

schmunk42 opened this issue · 2 comments

from "default/model"....

foreach ($columns as $name => $column) {
            if (in_array($column->name, array(
                'create_time',
                'createtime',
                'created_at',
                'createdat',
                'changed',
                'changed_at',
                'updatetime',
                'update_time',
                'timestamp'))
            ) {
                $behaviors .= sprintf("\n            'CTimestampBehavior' => array(
                'class' => 'zii.behaviors.CTimestampBehavior',
                'createAttribute' => %s,
                'updateAttribute' => %s,
            ),\n", $this->getCreatetimeAttribute($columns),
                    $this->getUpdatetimeAttribute($columns));
                break; // once a column is found, we are done
            }
        }
        foreach ($columns as $name => $column) {
            if (in_array($column->name, array(
                'user_id',
                'userid',
                'ownerid',
                'owner_id',
                'created_by',
                'createdby',
                'create_user'))
            ) {
                $behaviors .= sprintf("\n            'OwnerBehavior' => array(
                'class' => 'OwnerBehavior',
                'ownerColumn' => '%s',
            ),\n", $column->name);
                break; // once a column is found, we are done

            }
        }

What was the rationale of removing this? Can we put the code back as it was or how do we reimplement in a better way?

This list will be endless: 'create_time', 'createtime', 'created_at', 'createdat', 'changed', 'changed_at', 'updatetime', 'update_time', 'timestamp' and it's very hard to extend the way it is.

What's about "providers" for this also?