Jackalope\Transport\DoctrineDBAL\Client::reorderChildren PHP Method

reorderChildren() public method

{@inheritDoc}
public reorderChildren ( Node $node )
$node Jackalope\Node
    public function reorderChildren(Node $node)
    {
        $this->assertLoggedIn();
        $values[':absPath'] = $node->getPath();
        $sql = "UPDATE phpcr_nodes SET sort_order = CASE CONCAT(\n          namespace,\n          (CASE namespace WHEN '' THEN '' ELSE ':' END),\n          local_name\n        )";
        $i = 0;
        foreach ($node->getNodeNames() as $name) {
            $values[':name' . $i] = $name;
            $values[':order' . $i] = $i;
            // use our counter to avoid gaps
            $sql .= " WHEN :name" . $i . " THEN :order" . $i;
            $i++;
        }
        $sql .= " ELSE sort_order END WHERE parent = :absPath";
        try {
            $this->getConnection()->executeUpdate($sql, $values);
        } catch (DBALException $e) {
            throw new RepositoryException('Unexpected exception while reordering nodes', $e->getCode(), $e);
        }
        return true;
    }

Usage Example

 /**
  * {@inheritDoc}
  */
 public function reorderChildren(Node $node)
 {
     $result = parent::reorderChildren($node);
     if ($result) {
         $this->clearNodeCache($node);
     }
     return $result;
 }