Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

phpdoc updates

  • Loading branch information...
commit 68bc38279617364a64aaba0b82a8e05269b4eb49 1 parent da3df2a
ElvenPath authored
Showing with 22 additions and 6 deletions.
  1. +22 −6 SortableModelBehavior.php
28 SortableModelBehavior.php
View
@@ -22,6 +22,8 @@ class SortableModelBehavior extends CActiveRecordBehavior
/**
* BeforeSave event handler. Sets orderField.
+ *
+ * @param CModelEvent $event
*/
public function beforeSave($event)
{
@@ -37,22 +39,30 @@ public function beforeSave($event)
/**
* Sets default order
+ *
+ * @param CEvent $event
*/
public function beforeFind($event)
{
- $this->owner->dbCriteria->order = $this->owner->getTableAlias().'.`' . $this->orderField . '`';
+ $this->owner->dbCriteria->order = $this->owner->getTableAlias() . '.`' . $this->orderField . '`';
}
/**
* AfterDelete event handler. Updates order.
+ *
+ * @param CEvent $event
+ *
+ * @throws CDbException
*/
public function afterDelete($event)
{
- $criteria = new CDbCriteria(array(
- 'condition' => '`' . $this->orderField . '` > :position',
- 'params' => array(':position' => $this->owner->attributes[$this->orderField]),
- 'order' => '`t`.`' . $this->orderField . '`',
- ));
+ $criteria = new CDbCriteria(
+ array(
+ 'condition' => '`' . $this->orderField . '` > :position',
+ 'params' => array(':position' => $this->owner->attributes[$this->orderField]),
+ 'order' => '`' . $this->owner->getTableAlias() . '`.`' . $this->orderField . '`',
+ )
+ );
$this->owner->dbConnection->commandBuilder->createUpdateCommand(
$this->owner->tableName(),
array($this->orderField => new CDbExpression('`' . $this->orderField . '` - 1')),
@@ -83,6 +93,7 @@ public function moveUp()
if ($externalTransaction === null && isset($transaction)) {
$transaction->commit();
}
+
return true;
}
@@ -113,8 +124,11 @@ public function moveDown()
if ($externalTransaction === null && isset($transaction)) {
$transaction->commit();
}
+
return true;
}
+
+ return true;
}
/**
@@ -136,6 +150,7 @@ public function next()
'params' => array(':position' => $this->owner->attributes[$this->orderField] + 1)
)
);
+
return $this->owner;
}
@@ -150,6 +165,7 @@ public function previous()
'params' => array(':position' => $this->owner->attributes[$this->orderField] - 1)
)
);
+
return $this->owner;
}
Please sign in to comment.
Something went wrong with that request. Please try again.