/** * @covers \eZ\Publish\Core\Persistence\InMemory\ObjectStateHandler::setPriority */ public function testSetPriority() { $this->handler->setPriority(2, 0); $firstObjectState = $this->handler->load(1); $this->assertEquals(1, $firstObjectState->priority); $firstObjectState = $this->handler->load(2); $this->assertEquals(0, $firstObjectState->priority); }
/** * Changes the priority of the state. * * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to change priority on an object state * * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState * @param int $priority */ public function setPriorityOfObjectState(APIObjectState $objectState, $priority) { if (!is_int($priority)) { throw new InvalidArgumentValue('priority', $priority); } if ($this->repository->hasAccess('state', 'administrate') !== true) { throw new UnauthorizedException('state', 'administrate'); } $loadedObjectState = $this->loadObjectState($objectState->id); $this->repository->beginTransaction(); try { $this->objectStateHandler->setPriority($loadedObjectState->id, $priority); $this->repository->commit(); } catch (Exception $e) { $this->repository->rollback(); throw $e; } }