eZ\Publish\Core\Persistence\Legacy\Content\Location\Gateway\DoctrineDatabase::swap PHP Method

swap() public method

Make the location identified by $locationId1 refer to the Content referred to by $locationId2 and vice versa.
public swap ( mixed $locationId1, mixed $locationId2 ) : boolean
$locationId1 mixed
$locationId2 mixed
return boolean
    public function swap($locationId1, $locationId2)
    {
        $query = $this->handler->createSelectQuery();
        $query->select($this->handler->quoteColumn('node_id'), $this->handler->quoteColumn('contentobject_id'), $this->handler->quoteColumn('contentobject_version'))->from($this->handler->quoteTable('ezcontentobject_tree'))->where($query->expr->in($this->handler->quoteColumn('node_id'), array($locationId1, $locationId2)));
        $statement = $query->prepare();
        $statement->execute();
        foreach ($statement->fetchAll() as $row) {
            $contentObjects[$row['node_id']] = $row;
        }
        $query = $this->handler->createUpdateQuery();
        $query->update($this->handler->quoteTable('ezcontentobject_tree'))->set($this->handler->quoteColumn('contentobject_id'), $query->bindValue($contentObjects[$locationId2]['contentobject_id']))->set($this->handler->quoteColumn('contentobject_version'), $query->bindValue($contentObjects[$locationId2]['contentobject_version']))->where($query->expr->eq($this->handler->quoteColumn('node_id'), $query->bindValue($locationId1)));
        $query->prepare()->execute();
        $query = $this->handler->createUpdateQuery();
        $query->update($this->handler->quoteTable('ezcontentobject_tree'))->set($this->handler->quoteColumn('contentobject_id'), $query->bindValue($contentObjects[$locationId1]['contentobject_id']))->set($this->handler->quoteColumn('contentobject_version'), $query->bindValue($contentObjects[$locationId1]['contentobject_version']))->where($query->expr->eq($this->handler->quoteColumn('node_id'), $query->bindValue($locationId2)));
        $query->prepare()->execute();
    }