/**
  * Update content objects
  *
  * Updates content objects, depending on the changed field definitions.
  *
  * A content type has a state which tells if its content objects yet have
  * been adapted.
  *
  * Flags the content type as updated.
  *
  * @param mixed $contentTypeId
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If type with $contentTypeId and Type::STATUS_DRAFT is not found
  *
  * @return void
  */
 public function publish($contentTypeId)
 {
     $draftType = $this->load($contentTypeId, Type::STATUS_DRAFT);
     try {
         $publishedType = $this->load($contentTypeId);
     } catch (NotFound $e) {
         // No published version of type, jump to last section where draft is promoted to defined
         goto updateType;
     }
     // @todo update content based on new type data change (field/scheme changes from $publishedType to $draftType)
     $this->backend->deleteByMatch('Content\\Type', array('id' => $contentTypeId, 'status' => Type::STATUS_DEFINED));
     $this->backend->deleteByMatch('Content\\Type\\FieldDefinition', array('_typeId' => $contentTypeId, '_status' => Type::STATUS_DEFINED));
     updateType:
     $this->backend->updateByMatch('Content\\Type', array('id' => $contentTypeId, 'status' => Type::STATUS_DRAFT), array('status' => Type::STATUS_DEFINED));
     $this->backend->updateByMatch('Content\\Type\\FieldDefinition', array('_typeId' => $contentTypeId, '_status' => Type::STATUS_DRAFT), array('_status' => Type::STATUS_DEFINED));
 }
 /**
  * @see eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler
  */
 public function emptyTrash()
 {
     $trashedIds = array();
     $contentIds = array();
     foreach ($this->backend->find('Content\\Location\\Trashed') as $trashed) {
         $trashedIds[] = $trashed->id;
         $contentIds[] = $trashed->contentId;
     }
     if (!empty($trashedIds)) {
         // Remove associated content for trashed locations
         foreach ($contentIds as $contentId) {
             $this->handler->contentHandler()->deleteContent($contentId);
         }
         // Remove trashed locations
         $this->backend->deleteByMatch('Content\\Location\\Trashed', array('id' => $trashedIds));
     }
 }
 /**
  * Un-assign a role
  *
  * @param mixed $contentId The user or user group Id to un-assign the role from.
  * @param mixed $roleId
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If group or role is not found
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If group is not of user[_group] Content Type
  * @throws \eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue If group does not contain role
  */
 public function unAssignRole($contentId, $roleId)
 {
     $content = $this->backend->load('Content\\ContentInfo', $contentId);
     if (!$content) {
         throw new NotFound('User Group', $contentId);
     }
     $role = $this->backend->load('User\\Role', $roleId);
     if (!$role) {
         throw new NotFound('Role', $roleId);
     }
     // @todo Use eZ Publish settings for this, and maybe a better exception
     if ($content->contentTypeId != 3 && $content->contentTypeId != 4) {
         throw new NotFound("3 or 4", $contentId);
     }
     $roleAssignments = $this->backend->find('User\\RoleAssignment', array('roleId' => $roleId, 'contentId' => $contentId));
     if (empty($roleAssignments)) {
         throw new InvalidArgumentValue('$roleId', $roleId);
     }
     $this->backend->deleteByMatch('User\\RoleAssignment', array('roleId' => $roleId, 'contentId' => $contentId));
     $role->groupIds = array_values(array_diff($role->groupIds, array($contentId)));
     $this->backend->update('User\\Role', $roleId, (array) $role);
 }
 /**
  * Notifies the underlying engine that a location was deleted or moved to trash
  *
  * @param mixed $locationId
  */
 public function locationDeleted($locationId)
 {
     $this->backend->deleteByMatch('Content\\UrlAlias', array('destination' => $locationId));
 }
 /**
  * Deletes a object state group including all states and links to content
  *
  * @param mixed $groupId
  */
 public function deleteGroup($groupId)
 {
     $this->backend->deleteByMatch('Content\\ObjectState', array('groupId' => $groupId));
     $this->backend->delete('Content\\ObjectState\\Group', $groupId);
 }