本文整理汇总了PHP中eZ\Publish\Core\REST\Common\Output\Generator类的典型用法代码示例。如果您正苦于以下问题:PHP Generator类的具体用法?PHP Generator怎么用?PHP Generator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Generator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: visit
/**
* @param Visitor $visitor
* @param Generator $generator
* @param \eZ\Publish\API\Repository\Values\Content\Query\Criterion\ContentTypeIdentifier $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$contentTypeIdentifiers = is_array($data->value) ? $data->value : [$data->value];
$generator->startList('ContentTypeIdentifierCriterion');
foreach ($contentTypeIdentifiers as $contentTypeIdentifier) {
$generator->startValueElement('ContentTypeIdentifierCriterion', $contentTypeIdentifier);
$generator->endValueElement('ContentTypeIdentifierCriterion');
}
$generator->endList('ContentTypeIdentifierCriterion');
}
示例2: visit
/**
* @param \eZ\Publish\Core\REST\Common\Output\Visitor $visitor
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param mixed $data
* @return mixed
* @throws \EzSystems\RecommendationBundle\Rest\Exception\ResponseClassNotImplementedException
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentList'));
if (empty($data->contents)) {
$visitor->setStatus(204);
return;
}
if (!isset($this->responseRenderers[$data->options['responseType']])) {
throw new ResponseClassNotImplementedException(sprintf('Renderer for %s response not implemented.', $data->options['responseType']));
}
return $this->responseRenderers[$data->options['responseType']]->render($generator, $data);
}
示例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 mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('ContentObjectStates');
$visitor->setHeader('Content-Type', $generator->getMediaType('ContentObjectStates'));
$generator->startList('ObjectState');
foreach ($data->states as $state) {
$generator->startObjectElement('ObjectState');
$generator->startAttribute('href', $this->requestParser->generate('objectstate', array('objectstategroup' => $state->groupId, 'objectstate' => $state->objectState->id)));
$generator->endAttribute('href');
$generator->endObjectElement('ObjectState');
}
$generator->endList('ObjectState');
$generator->endObjectElement('ContentObjectStates');
}
示例4: 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');
}
示例5: visitField
/**
* Visits a single content field and generates its content
*
* @param \eZ\Publish\Core\REST\Common\Output\Generator $generator
* @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
* @param \eZ\Publish\API\Repository\Values\Content\Field $field
*/
public function visitField(Generator $generator, ContentType $contentType, Field $field)
{
$generator->startHashElement('field');
$generator->startValueElement('id', $field->id);
$generator->endValueElement('id');
$generator->startValueElement('fieldDefinitionIdentifier', $field->fieldDefIdentifier);
$generator->endValueElement('fieldDefinitionIdentifier');
$generator->startValueElement('languageCode', $field->languageCode);
$generator->endValueElement('languageCode');
$this->fieldTypeSerializer->serializeFieldValue($generator, $contentType, $field);
$generator->endHashElement('field');
}
示例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 mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('SectionInput');
$visitor->setHeader('Content-Type', $generator->getMediaType('SectionInput'));
$generator->startValueElement('identifier', $data->identifier);
$generator->endValueElement('identifier');
$generator->startValueElement('name', $data->name);
$generator->endValueElement('name');
$generator->endObjectElement('SectionInput');
}
示例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 mixed $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$generator->startObjectElement('SessionInput');
$visitor->setHeader('Content-Type', $generator->getMediaType('SessionInput'));
$generator->startValueElement('login', $data->login);
$generator->endValueElement('login');
$generator->startValueElement('password', $data->password);
$generator->endValueElement('password');
$generator->endObjectElement('SessionInput');
}
示例8: 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);
}
示例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\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');
}
示例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\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');
}
示例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\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');
}
示例12: 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');
}
示例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('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');
}
示例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\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');
}
示例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\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');
}