当前位置: 首页>>代码示例>>PHP>>正文


PHP Visitor::visit方法代码示例

本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Visitor::visit方法的典型用法代码示例。如果您正苦于以下问题:PHP Visitor::visit方法的具体用法?PHP Visitor::visit怎么用?PHP Visitor::visit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZ\Publish\Core\REST\Common\Output\Visitor的用法示例。


在下文中一共展示了Visitor::visit方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: display

 /**
  * Display the controller result
  *
  * @param RMF\Request $request
  * @param mixed $result
  */
 public function display(RMF\Request $request, $result)
 {
     if ($result === null) {
         $message = new Common\Message(array('Status' => '200 No content'));
     } else {
         $message = $this->visitor->visit($result);
     }
     foreach ($message->headers as $name => $value) {
         if ($name === 'Status') {
             // Special handling for PHP running as an Apache module
             header($_SERVER['SERVER_PROTOCOL'] . ' ' . $value);
         }
         header("{$name}: {$value}");
     }
     echo $message->body;
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:22,代码来源:Visitor.php

示例2: assignRoleToUser

 /**
  * Assigns a role to the given user.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the authenticated user is not allowed to assign a role
  * @throws \eZ\Publish\API\Repository\Exceptions\LimitationValidationException if $roleLimitation is not valid
  *
  * @todo add limitations
  *
  * @param \eZ\Publish\API\Repository\Values\User\Role $role
  * @param \eZ\Publish\API\Repository\Values\User\User $user
  * @param \eZ\Publish\API\Repository\Values\User\Limitation\RoleLimitation $roleLimitation an optional role limitation (which is either a subtree limitation or section limitation)
  */
 public function assignRoleToUser(APIRole $role, User $user, RoleLimitation $roleLimitation = null)
 {
     $roleAssignment = new RoleAssignment(array('role' => $role, 'limitation' => $roleLimitation));
     $inputMessage = $this->outputVisitor->visit($roleAssignment);
     $inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('RoleAssignmentList');
     $result = $this->client->request('POST', $this->requestParser->generate('userRoleAssignments', array('user' => $user->id)), $inputMessage);
     $this->inputDispatcher->parse($result);
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:20,代码来源:RoleService.php

示例3: updateLocation

 /**
  * Updates $location in the content repository
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If the current user user is not allowed to update this location
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException   if if set the remoteId exists already
  *
  * @param \eZ\Publish\API\Repository\Values\Content\Location $location
  * @param \eZ\Publish\API\Repository\Values\Content\LocationUpdateStruct $locationUpdateStruct
  *
  * @return \eZ\Publish\API\Repository\Values\Content\Location the updated Location
  */
 public function updateLocation(Location $location, LocationUpdateStruct $locationUpdateStruct)
 {
     $inputMessage = $this->outputVisitor->visit($locationUpdateStruct);
     $inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('Location');
     $inputMessage->headers['X-HTTP-Method-Override'] = 'PATCH';
     $result = $this->client->request('POST', $location->id, $inputMessage);
     return $this->inputDispatcher->parse($result);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:19,代码来源:LocationService.php

示例4: testVisitValueObject

 public function testVisitValueObject()
 {
     $data = new stdClass();
     /** @var \PHPUnit_Framework_MockObject_MockObject|Common\Output\Generator $generatorMock */
     $generatorMock = $this->getMock('\\eZ\\Publish\\Core\\REST\\Common\\Output\\Generator');
     $valueObjectDispatcherMock = $this->getValueObjectDispatcherMock();
     $valueObjectDispatcherMock->expects($this->once())->method('visit')->with($data);
     $visitor = new Common\Output\Visitor($generatorMock, $valueObjectDispatcherMock);
     $visitor->visit($data);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:10,代码来源:VisitorTest.php

示例5: assignSection

 /**
  * Assigns the content to the given section
  * this method overrides the current assigned section.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException If user does not have access to view provided object
  *
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  * @param \eZ\Publish\API\Repository\Values\Content\Section $section
  *
  * @todo In order to make the integration test for this method running, the
  *       countAssignedContents() method must be implemented. Otherwise this
  *       should work fine.
  */
 public function assignSection(ContentInfo $contentInfo, Section $section)
 {
     $inputMessage = $this->outputVisitor->visit(new RestContentMetadataUpdateStruct(array('sectionId' => $section->id)));
     $inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('Content');
     $inputMessage->headers['X-HTTP-Method-Override'] = 'PATCH';
     $this->client->request('POST', $contentInfo->id, $inputMessage);
     // Will throw exception on error, no return value for method
     // @todo: Deactivated due to missing implementation of visitor for
     // content on the server side.
     // Should be: $result = $this->inputDispatcher->parse( $response );
 }
开发者ID:Heyfara,项目名称:ezpublish-kernel,代码行数:24,代码来源:SectionService.php

示例6: setContentState

 /**
  * Sets the object-state of a state group to $state for the given content.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the object state does not belong to the given group
  * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to change the object state
  *
  * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
  * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectStateGroup $objectStateGroup
  * @param \eZ\Publish\API\Repository\Values\ObjectState\ObjectState $objectState
  */
 public function setContentState(ContentInfo $contentInfo, ObjectStateGroup $objectStateGroup, ObjectState $objectState)
 {
     $inputMessage = $this->outputVisitor->visit(new ContentObjectStates(array($objectState)));
     $inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('ContentObjectStates');
     $inputMessage->headers['X-HTTP-Method-Override'] = 'PATCH';
     // Should originally be PATCH, but PHP's shiny new internal web server
     // dies with it.
     $values = $this->requestParser->parse('object', $contentInfo->id);
     $result = $this->client->request('POST', $this->requestParser->generate('objectObjectStates', array('object' => $values['object'])), $inputMessage);
     $this->inputDispatcher->parse($result);
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:21,代码来源:ObjectStateService.php

示例7: createContentType

 /**
  * Create a Content Type object.
  *
  * The content type is created in the state STATUS_DRAFT.
  *
  * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException In case when
  *         - array of content type groups does not contain at least one content type group
  *         - identifier or remoteId in the content type create struct already exists
  *         - there is a duplicate field identifier in the content type create struct
  *         - content type create struct does not contain at least one field definition create struct
  * @throws \eZ\Publish\API\Repository\Exceptions\ContentTypeFieldDefinitionValidationException
  *         if a field definition in the $contentTypeCreateStruct is not valid
  *
  * @param \eZ\Publish\API\Repository\Values\ContentType\ContentTypeCreateStruct $contentTypeCreateStruct
  * @param array $contentTypeGroups Required array of {@link ContentTypeGroup} to link type with (must contain one)
  *
  * @return \eZ\Publish\API\Repository\Values\ContentType\ContentTypeDraft
  */
 public function createContentType(APIContentTypeCreateStruct $contentTypeCreateStruct, array $contentTypeGroups)
 {
     $inputMessage = $this->outputVisitor->visit($contentTypeCreateStruct);
     $inputMessage->headers['Accept'] = $this->outputVisitor->getMediaType('ContentType');
     if (empty($contentTypeGroups)) {
         throw new InvalidArgumentException("Argument '\$contentTypeGroups' is invalid: Argument must contain at least one ContentTypeGroup");
     }
     /** @var $firstGroup \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup */
     /** @var $contentTypeGroups \eZ\Publish\API\Repository\Values\ContentType\ContentTypeGroup[] */
     $firstGroup = array_pop($contentTypeGroups);
     $response = $this->client->request('POST', $this->requestParser->generate("grouptypes", $this->requestParser->parse("typegroup", $firstGroup->id)), $inputMessage);
     try {
         $contentType = $this->inputDispatcher->parse($response);
     } catch (ForbiddenException $e) {
         throw new InvalidArgumentException($e->getMessage(), $e->getCode());
     }
     foreach ($contentTypeGroups as $contentTypeGroup) {
         $this->assignContentTypeGroup($contentType, $contentTypeGroup);
     }
     return $this->completeContentType($contentType);
 }
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:39,代码来源:ContentTypeService.php


注:本文中的eZ\Publish\Core\REST\Common\Output\Visitor::visit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。