コード例 #1
0
 /**
  * Test deleting content
  *
  * @covers eZ\Publish\Core\Persistence\InMemory\Backend::delete
  * @group inMemoryBackend
  */
 public function testDelete()
 {
     $this->backend->delete("Content\\VersionInfo", 1);
     try {
         $this->backend->load("Content\\VersionInfo", 1);
         $this->fail("Content has not been deleted");
     } catch (NotFound $e) {
     }
 }
コード例 #2
0
 /**
  * Link a content type group with a content type
  *
  * @param mixed $groupId
  * @param mixed $contentTypeId
  * @param int $status One of Type::STATUS_DEFINED|Type::STATUS_DRAFT|Type::STATUS_MODIFIED
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If group or type with provided status is not found
  * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException If type is already part of group
  */
 public function link($groupId, $contentTypeId, $status)
 {
     $list = $this->backend->find('Content\\Type', array('id' => $contentTypeId, 'status' => $status));
     if (!isset($list[0])) {
         throw new NotFound('Content\\Type', "{$contentTypeId}' and status '{$status}");
     }
     $type = $list[0];
     if (in_array($groupId, $type->groupIds)) {
         throw new BadStateException('$groupId', "Group {$groupId} is already linked to Type {$contentTypeId}");
     }
     if (!$this->backend->load('Content\\Type\\Group', $groupId)) {
         throw new NotFound('Content\\Type\\Group', $groupId);
     }
     $this->backend->updateByMatch('Content\\Type', array('id' => $contentTypeId, 'status' => $status), array('groupIds' => array_merge($type->groupIds, array($groupId))));
 }
コード例 #3
0
 /**
  * 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);
 }
コード例 #4
0
 /**
  * @see eZ\Publish\SPI\Persistence\Content\Location\Trash\Handler
  */
 public function loadTrashItem($id)
 {
     return $this->backend->load('Content\\Location\\Trashed', $id);
 }
コード例 #5
0
 /**
  * @see eZ\Publish\SPI\Persistence\Content\Section\Handler
  */
 public function load($id)
 {
     return $this->backend->load('Content\\Section', $id);
 }
コード例 #6
0
 /**
  * Returns stripped content name from location value
  * All downcase, special chars to underscores
  * e.g. my_content_name
  * @param LocationValue $vo
  *
  * @return string
  */
 private function getStrippedContentName(LocationValue $vo)
 {
     $version = $this->backend->find("Content\\VersionInfo", array("contentId" => $vo->contentId, "versionNo" => $this->backend->load('Content\\ContentInfo', $vo->contentId)->currentVersionNo));
     return isset($version[0]->names["eng-GB"]) ? preg_replace('`[^a-z0-9_]`i', '_', strtolower(trim(strtr($version[0]->names["eng-GB"], self::CHARS_ACCENT, self::CHARS_NOACCENT)))) : null;
 }
コード例 #7
0
 /**
  * Loads URL alias by given $id
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
  *
  * @param string $id
  *
  * @return \eZ\Publish\SPI\Persistence\Content\UrlAlias
  */
 public function loadUrlAlias($id)
 {
     return $this->backend->load('Content\\UrlAlias', $id);
 }
コード例 #8
0
 /**
  * Loads a url wild card
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the url wild card was not found
  *
  * @param mixed $id
  *
  * @return \eZ\Publish\SPI\Persistence\Content\UrlWildcard
  */
 public function load($id)
 {
     return $this->backend->load('Content\\UrlWildcard', $id);
 }
コード例 #9
0
 /**
  * Returns the metadata object for a content identified by $contentId.
  *
  * @param int|string $contentId
  *
  * @return \eZ\Publish\SPI\Persistence\Content\ContentInfo
  */
 public function loadContentInfo($contentId)
 {
     $contentInfo = $this->backend->load('Content\\ContentInfo', $contentId);
     return $contentInfo;
 }
コード例 #10
0
 /**
  * Get language by id
  *
  * @param mixed $id
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException If language could not be found by $id
  *
  * @return \eZ\Publish\SPI\Persistence\Content\Language
  */
 public function load($id)
 {
     return $this->backend->load('Content\\Language', $id);
 }
コード例 #11
0
 /**
  * Test loading content with a wrong type.
  *
  * @param mixed $type Wrong type to load
  *
  * @expectedException eZ\Publish\Core\Base\Exceptions\InvalidArgumentValue
  * @dataProvider providerForWrongType
  * @covers eZ\Publish\Core\Persistence\InMemory\Backend::load
  */
 public function testLoadWrongType($type)
 {
     $this->backend->load($type, 1);
 }
コード例 #12
0
 /**
  * Loads an object state
  *
  * @param mixed $stateId
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the state was not found
  *
  * @return \eZ\Publish\SPI\Persistence\Content\ObjectState
  */
 public function load($stateId)
 {
     return $this->backend->load('Content\\ObjectState', $stateId);
 }