コード例 #1
0
 /**
  * @param mixed $groupId
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If type group contains types
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If type group with id is not found
  */
 public function deleteGroup($groupId)
 {
     if ($this->backend->count('Content\\Type', array('groupIds' => $groupId))) {
         throw new BadStateException('$groupId', "Group {$groupId} still contains Types and can not be deleted");
     }
     $this->backend->delete('Content\\Type\\Group', $groupId);
 }
コード例 #2
0
 /**
  * Removes a relation by relation Id.
  *
  * @param mixed $relationId
  * @param int $type {@see \eZ\Publish\API\Repository\Values\Content\Relation::COMMON,
  *                 \eZ\Publish\API\Repository\Values\Content\Relation::EMBED,
  *                 \eZ\Publish\API\Repository\Values\Content\Relation::LINK,
  *                 \eZ\Publish\API\Repository\Values\Content\Relation::FIELD}
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if relation to be removed is not found.
  */
 public function removeRelation($relationId, $type)
 {
     $requestedRelation = $this->backend->find("Content\\Relation", array("id" => $relationId));
     if (empty($requestedRelation)) {
         throw new NotFoundException("Content\\Relation", "id: " . $relationId);
     }
     $this->backend->delete("Content\\Relation", $relationId);
 }
コード例 #3
0
 /**
  * Delete a language
  *
  * @throws \LogicException If language could not be deleted
  *
  * @param mixed $id
  */
 public function delete($id)
 {
     $versions = $this->backend->find('Content\\VersionInfo', array('languageIds' => $id));
     if (!empty($versions)) {
         throw new LogicException("Deleting language logic error, some content still references that language and therefore it can't be deleted");
     }
     $this->backend->delete('Content\\Language', $id);
 }
コード例 #4
0
 /**
  * Removes url aliases.
  *
  * Autogenerated aliases are not removed by this method.
  *
  * @param \eZ\Publish\SPI\Persistence\Content\UrlAlias[] $urlAliases
  *
  * @return boolean
  */
 public function removeURLAliases(array $urlAliases)
 {
     foreach ($urlAliases as $index => $urlAlias) {
         if (!$urlAlias instanceof UrlAlias) {
             throw new \eZ\Publish\Core\Base\Exceptions\InvalidArgumentException("\$urlAliases[{$index}]", 'Expected UrlAlias instance');
         }
         if (!$urlAlias->isCustom) {
             continue;
         }
         $this->backend->delete('Content\\UrlAlias', $urlAlias->id);
     }
 }
コード例 #5
0
 /**
  * Removes a location from its $locationId (but not its descendants)
  * Content which looses its main Location will get the first
  * of its other Locations assigned as the new main Location.
  * If content has no location left, it's removed from backend
  *
  * @param mixed $locationId
  */
 public function delete($locationId)
 {
     $location = $this->load($locationId);
     $this->backend->delete('Content\\Location', $locationId);
     $remainingLocations = $this->backend->find('Content\\Location', array('contentId' => $location->contentId));
     // If no remaining location for associated content, remove the content as well
     // Else, update the mainLocationId if needed
     if (empty($remainingLocations)) {
         try {
             $this->handler->contentHandler()->deleteContent($location->contentId);
         } catch (NotFound $e) {
         }
     } else {
         $this->backend->update('Content\\ContentInfo', $location->contentId, array('mainLocationId' => $remainingLocations[0]->id));
     }
 }
コード例 #6
0
 /**
  * Deletes a object state. The state of the content objects is reset to the
  * first object state in the group.
  *
  * @param mixed $stateId
  */
 public function delete($stateId)
 {
     // We need to load the object state as we need $groupId
     $objectState = $this->load($stateId);
     // Find all content for the current $stateId
     $contentList = $this->getObjectStateContentList($stateId);
     // Delete the state
     $this->backend->delete('Content\\ObjectState', $stateId);
     // Update the priorities of the group states if there are any more states in the group
     $groupStates = $this->loadObjectStates($objectState->groupId);
     if (empty($groupStates)) {
         return;
     }
     $priority = 0;
     foreach ($groupStates as $groupState) {
         $this->backend->update('Content\\ObjectState', $groupState->id, array("priority" => $priority));
         $priority++;
     }
     // Now reassign content from old state to the first state in the group
     $firstObjectState = current($this->backend->find("Content\\ObjectState", array("priority" => 0)));
     $existingContent = $this->getObjectStateContentList($firstObjectState->id) + $contentList;
     $existingContent = array_values(array_unique($existingContent));
     $this->backend->update('Content\\ObjectState', $firstObjectState->id, array("_contentId" => $existingContent));
 }
コード例 #7
0
 /**
  * Test deleting content which does not exist
  *
  * @expectedException \eZ\Publish\Core\Base\Exceptions\NotFoundException
  * @covers eZ\Publish\Core\Persistence\InMemory\Backend::delete
  * @group inMemoryBackend
  */
 public function testDeleteNotFound()
 {
     $this->backend->delete("Content\\VersionInfo", 999);
 }
コード例 #8
0
 /**
  * @see eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler
  */
 public function deleteTrashItem($trashedId)
 {
     $vo = $this->loadTrashItem($trashedId);
     $this->handler->contentHandler()->deleteContent($vo->contentId);
     $this->backend->delete('Content\\Location\\Trashed', $trashedId);
 }
コード例 #9
0
 /**
  * @see eZ\Publish\SPI\Persistence\Content\Section\Handler
  */
 public function delete($id)
 {
     $this->backend->delete('Content\\Section', $id);
 }
コード例 #10
0
 /**
  * removes an url wildcard
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the url wild card was not found
  *
  * @param mixed $id
  */
 public function remove($id)
 {
     $this->backend->delete('Content\\UrlWildcard', $id);
 }
コード例 #11
0
 /**
  * Delete the specified role
  *
  * @param mixed $roleId
  */
 public function deleteRole($roleId)
 {
     $this->backend->delete('User\\Role', $roleId);
     $this->backend->deleteByMatch('User\\Policy', array('roleId' => $roleId));
     $this->backend->deleteByMatch('User\\RoleAssignment', array('roleId' => $roleId));
 }
コード例 #12
0
 /**
  * Test deleting content with a wrong type.
  *
  * @param mixed $type Wrong type to delete
  *
  * @expectedException eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue
  * @dataProvider providerForWrongType
  * @covers eZ\Publish\Core\Persistence\InMemory\Backend::delete
  */
 public function testDeleteWrongType($type)
 {
     $this->backend->delete($type, 1);
 }