本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Visitor::visitValueObject方法的典型用法代码示例。如果您正苦于以下问题:PHP Visitor::visitValueObject方法的具体用法?PHP Visitor::visitValueObject怎么用?PHP Visitor::visitValueObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZ\Publish\Core\REST\Common\Output\Visitor
的用法示例。
在下文中一共展示了Visitor::visitValueObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: visit
public function visit(Visitor $visitor, Generator $generator, $data)
{
if ($data instanceof LocationQueryValue) {
$rootObjectElement = 'LocationQuery';
} else {
if ($data instanceof ContentQueryValue) {
$rootObjectElement = 'ContentQuery';
} else {
throw new Exceptions\InvalidArgumentException("ViewInput Query", "No content nor location query found in ViewInput");
}
}
$generator->startObjectElement($rootObjectElement, 'Query');
if (isset($data->filter)) {
$generator->startHashElement('Filter');
$visitor->visitValueObject($data->filter);
$generator->endHashElement('Filter');
}
if (isset($data->query)) {
$generator->startHashElement('Query');
$visitor->visitValueObject($data->query);
$generator->endhashElement('Query');
}
// $generator->startObjectElement('SortClauses');
// foreach ($data->sortClauses as $sortClause) {
// $visitor->visitValueObject($sortClause);
// }
// $generator->endObjectElement('SortClauses');
$generator->endObjectElement($rootObjectElement);
}
示例2: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\Version $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$content = $data->content;
$versionInfo = $content->getVersionInfo();
$contentType = $data->contentType;
$generator->startObjectElement('Version');
$visitor->setHeader('Content-Type', $generator->getMediaType('Version'));
$visitor->setHeader('Accept-Patch', $generator->getMediaType('VersionUpdate'));
$path = $data->path;
if ($path == null) {
$path = $this->router->generate('ezpublish_rest_loadContentInVersion', array('contentId' => $content->id, 'versionNumber' => $versionInfo->versionNo));
}
$generator->startAttribute('href', $path);
$generator->endAttribute('href');
$visitor->visitValueObject($versionInfo);
$generator->startHashElement('Fields');
$generator->startList('field');
foreach ($content->getFields() as $field) {
$this->visitField($generator, $contentType, $field);
}
$generator->endList('field');
$generator->endHashElement('Fields');
$visitor->visitValueObject(new RelationListValue($data->relations, $content->id, $versionInfo->versionNo));
$generator->endObjectElement('Version');
}
示例3: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\RestLocation $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('Location');
$visitor->setHeader('Content-Type', $generator->getMediaType('Location'));
$visitor->setHeader('Accept-Patch', $generator->getMediaType('LocationUpdate'));
$location = $data->location;
$contentInfo = $location->getContentInfo();
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => trim($location->pathString, '/'))));
$generator->endAttribute('href');
$generator->startValueElement('id', $location->id);
$generator->endValueElement('id');
$generator->startValueElement('priority', $location->priority);
$generator->endValueElement('priority');
$generator->startValueElement('hidden', $this->serializeBool($generator, $location->hidden));
$generator->endValueElement('hidden');
$generator->startValueElement('invisible', $this->serializeBool($generator, $location->invisible));
$generator->endValueElement('invisible');
$generator->startObjectElement('ParentLocation', 'Location');
if (trim($location->pathString, '/') !== '1') {
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => implode('/', array_slice($location->path, 0, count($location->path) - 1)))));
$generator->endAttribute('href');
}
$generator->endObjectElement('ParentLocation');
$generator->startValueElement('pathString', $location->pathString);
$generator->endValueElement('pathString');
$generator->startValueElement('depth', $location->depth);
$generator->endValueElement('depth');
$generator->startValueElement('childCount', $data->childCount);
$generator->endValueElement('childCount');
$generator->startValueElement('remoteId', $location->remoteId);
$generator->endValueElement('remoteId');
$generator->startObjectElement('Children', 'LocationList');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocationChildren', array('locationPath' => trim($location->pathString, '/'))));
$generator->endAttribute('href');
$generator->endObjectElement('Children');
$generator->startObjectElement('Content');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)));
$generator->endAttribute('href');
$generator->endObjectElement('Content');
$generator->startValueElement('sortField', $this->serializeSortField($location->sortField));
$generator->endValueElement('sortField');
$generator->startValueElement('sortOrder', $this->serializeSortOrder($location->sortOrder));
$generator->endValueElement('sortOrder');
$generator->startObjectElement('UrlAliases', 'UrlAliasRefList');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_listLocationURLAliases', array('locationPath' => trim($location->pathString, '/'))));
$generator->endAttribute('href');
$generator->endObjectElement('UrlAliases');
$generator->startObjectElement('ContentInfo', 'ContentInfo');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)));
$generator->endAttribute('href');
$visitor->visitValueObject(new RestContentValue($contentInfo));
$generator->endObjectElement('ContentInfo');
$generator->endObjectElement('Location');
}
示例4: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\URLAliasList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('UrlAliasList');
$visitor->setHeader('Content-Type', $generator->getMediaType('UrlAliasList'));
$generator->startAttribute('href', $data->path);
$generator->endAttribute('href');
$generator->startList('UrlAlias');
foreach ($data->urlAliases as $urlAlias) {
$visitor->visitValueObject($urlAlias);
}
$generator->endList('UrlAlias');
$generator->endObjectElement('UrlAliasList');
}
示例5: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\URLWildcardList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('UrlWildcardList');
$visitor->setHeader('Content-Type', $generator->getMediaType('UrlWildcardList'));
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_listURLWildcards'));
$generator->endAttribute('href');
$generator->startList('UrlWildcard');
foreach ($data->urlWildcards as $urlWildcard) {
$visitor->visitValueObject($urlWildcard);
}
$generator->endList('UrlWildcard');
$generator->endObjectElement('UrlWildcardList');
}
示例6: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\RoleAssignmentList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('RoleAssignmentList');
$visitor->setHeader('Content-Type', $generator->getMediaType('RoleAssignmentList'));
$generator->startAttribute('href', $data->isGroupAssignment ? $this->router->generate('ezpublish_rest_loadRoleAssignmentsForUserGroup', array('groupPath' => $data->id)) : $this->router->generate('ezpublish_rest_loadRoleAssignmentsForUser', array('userId' => $data->id)));
$generator->endAttribute('href');
$generator->startList('RoleAssignment');
foreach ($data->roleAssignments as $roleAssignment) {
$visitor->visitValueObject($data->isGroupAssignment ? new Values\RestUserGroupRoleAssignment($roleAssignment, $data->id) : new Values\RestUserRoleAssignment($roleAssignment, $data->id));
}
$generator->endList('RoleAssignment');
$generator->endObjectElement('RoleAssignmentList');
}
示例7: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\Trash $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('Trash');
$visitor->setHeader('Content-Type', $generator->getMediaType('Trash'));
$generator->startAttribute('href', $data->path);
$generator->endAttribute('href');
$generator->startList('TrashItem');
foreach ($data->trashItems as $trashItem) {
$visitor->visitValueObject($trashItem);
}
$generator->endList('TrashItem');
$generator->endObjectElement('Trash');
}
示例8: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('RoleAssignInput');
$visitor->setHeader('Content-Type', $generator->getMediaType('RoleAssignInput'));
$generator->startObjectElement('Role');
$generator->startAttribute('href', $this->requestParser->generate('role', array('role' => $data->getRole()->id)));
$generator->endAttribute('href');
$generator->endObjectElement('Role');
$roleLimitation = $data->getRoleLimitation();
if ($roleLimitation !== null) {
$visitor->visitValueObject($roleLimitation);
}
$generator->endObjectElement('RoleAssignInput');
}
示例9: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\ObjectStateList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ObjectStateList');
$visitor->setHeader('Content-Type', $generator->getMediaType('ObjectStateList'));
//@todo Needs refactoring, disabling certain headers should not be done this way
$visitor->setHeader('Accept-Patch', false);
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadObjectStates', array('objectStateGroupId' => $data->groupId)));
$generator->endAttribute('href');
$generator->startList('ObjectState');
foreach ($data->states as $state) {
$visitor->visitValueObject(new RestObjectStateValue($state, $data->groupId));
}
$generator->endList('ObjectState');
$generator->endObjectElement('ObjectStateList');
}
示例10: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\ContentList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentList');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentList'));
//@todo Needs refactoring, disabling certain headers should not be done this way
$visitor->setHeader('Accept-Patch', false);
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_redirectContent'));
$generator->endAttribute('href');
$generator->startList('ContentInfo');
foreach ($data->contents as $content) {
$visitor->visitValueObject($content);
}
$generator->endList('ContentInfo');
$generator->endObjectElement('ContentList');
}
示例11: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\ContentTypeInfoList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentTypeInfoList');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentTypeInfoList'));
//@todo Needs refactoring, disabling certain headers should not be done this way
$visitor->setHeader('Accept-Patch', false);
$generator->startAttribute('href', $data->path);
$generator->endAttribute('href');
$generator->startList('ContentType');
foreach ($data->contentTypes as $contentType) {
$visitor->visitValueObject(new Values\RestContentType($contentType));
}
$generator->endList('ContentType');
$generator->endObjectElement('ContentTypeInfoList');
}
示例12: visit
/**
* @param Visitor $visitor
* @param Generator $generator
* @param \eZ\Publish\Core\REST\Client\Values\ViewInput $data
* @throws Exceptions\InvalidArgumentException
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ViewInput');
$generator->startValueElement('identifier', $data->identifier);
$generator->endValueElement('identifier');
if ($data->locationQuery !== null) {
$queryElementName = 'locationQuery';
} elseif ($data->contentQuery !== null) {
$queryElementName = 'contentQuery';
} else {
throw new Exceptions\InvalidArgumentException("ViewInput Query", "No content nor location query found in ViewInput");
}
$visitor->visitValueObject($data->{$queryElementName});
$generator->endObjectElement('ViewInput');
}
示例13: visit
/**
* Visit struct returned by controllers
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('PolicyUpdate');
$visitor->setHeader('Content-Type', $generator->getMediaType('PolicyUpdate'));
$limitations = $data->getLimitations();
if (!empty($limitations)) {
$generator->startObjectElement('limitations');
$generator->startList('limitations');
foreach ($limitations as $limitation) {
$visitor->visitValueObject($limitation);
}
$generator->endList('limitations');
$generator->endObjectElement('limitations');
}
$generator->endObjectElement('PolicyUpdate');
}
示例14: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\RelationList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('Relations', 'RelationList');
$visitor->setHeader('Content-Type', $generator->getMediaType('RelationList'));
$path = $data->path;
if ($path === null) {
$path = $this->router->generate('ezpublish_rest_loadVersionRelations', array('contentId' => $data->contentId, 'versionNumber' => $data->versionNo));
}
$generator->startAttribute('href', $path);
$generator->endAttribute('href');
$generator->startList('Relation');
foreach ($data->relations as $relation) {
$visitor->visitValueObject(new ValuesRestRelation($relation, $data->contentId, $data->versionNo));
}
$generator->endList('Relation');
$generator->endObjectElement('Relations');
}
示例15: visit
/**
* Visit struct returned by controllers.
*
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\Core\REST\Server\Values\RestTrashItem $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('TrashItem');
$visitor->setHeader('Content-Type', $generator->getMediaType('TrashItem'));
$trashItem = $data->trashItem;
$contentInfo = $trashItem->getContentInfo();
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadTrashItem', array('trashItemId' => $trashItem->id)));
$generator->endAttribute('href');
$generator->startValueElement('id', $trashItem->id);
$generator->endValueElement('id');
$generator->startValueElement('priority', $trashItem->priority);
$generator->endValueElement('priority');
$generator->startValueElement('hidden', $this->serializeBool($generator, $trashItem->hidden));
$generator->endValueElement('hidden');
$generator->startValueElement('invisible', $this->serializeBool($generator, $trashItem->invisible));
$generator->endValueElement('invisible');
$pathStringParts = explode('/', trim($trashItem->pathString, '/'));
$pathStringParts = array_slice($pathStringParts, 0, count($pathStringParts) - 1);
$generator->startObjectElement('ParentLocation', 'Location');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadLocation', array('locationPath' => implode('/', $pathStringParts))));
$generator->endAttribute('href');
$generator->endObjectElement('ParentLocation');
$generator->startValueElement('pathString', $trashItem->pathString);
$generator->endValueElement('pathString');
$generator->startValueElement('depth', $trashItem->depth);
$generator->endValueElement('depth');
$generator->startValueElement('childCount', $data->childCount);
$generator->endValueElement('childCount');
$generator->startValueElement('remoteId', $trashItem->remoteId);
$generator->endValueElement('remoteId');
$generator->startObjectElement('Content');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)));
$generator->endAttribute('href');
$generator->endObjectElement('Content');
$generator->startValueElement('sortField', $this->serializeSortField($trashItem->sortField));
$generator->endValueElement('sortField');
$generator->startValueElement('sortOrder', $this->serializeSortOrder($trashItem->sortOrder));
$generator->endValueElement('sortOrder');
$generator->startObjectElement('ContentInfo', 'ContentInfo');
$generator->startAttribute('href', $this->router->generate('ezpublish_rest_loadContent', array('contentId' => $contentInfo->id)));
$generator->endAttribute('href');
$visitor->visitValueObject(new RestContentValue($contentInfo));
$generator->endObjectElement('ContentInfo');
$generator->endObjectElement('TrashItem');
}