作者:ezsystem
项目:ezpublish-kerne
/**
* @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');
}
作者:kamilmusia
项目:EzSystemsRecommendationBundl
/**
* @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);
}
作者:CG7
项目:ezpublish-kerne
/**
* 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');
}
作者:ezsystem
项目:ezpublish-kerne
/**
* @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');
}
作者:CG7
项目:ezpublish-kerne
/**
* 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');
}
作者:CG7
项目:ezpublish-kerne
/**
* 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');
}
作者:Pix
项目:ezpublish-kerne
/**
* 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');
}
作者:ezsystem
项目:ezpublish-kerne
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);
}
作者:Pix
项目:ezpublish-kerne
/**
* 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');
}
作者:Pix
项目:ezpublish-kerne
/**
* 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');
}
作者:Pix
项目:ezpublish-kerne
/**
* 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');
}
作者:ezsystem
项目:ezpublish-kerne
/**
* 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');
}
作者:CG7
项目:ezpublish-kerne
/**
* 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');
}
作者:dfritsch
项目:ezpublish-kerne
/**
* 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');
}
作者:dfritsch
项目:ezpublish-kerne
/**
* 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');
}
作者:brookinsconsultin
项目:ezecosyste
/**
* 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');
}
作者:brookinsconsultin
项目:ezecosyste
/**
* 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');
}
作者:kamilmusia
项目:EzSystemsRecommendationBundl
public function render(Generator $generator, $data)
{
ini_set('max_execution_time', 0);
if (file_exists($data->options['documentRoot'] . '/var/export/.lock')) {
throw new ExportInProgressException('Export is running');
}
$chunkDir = $this->createChunkDir($data->options['documentRoot']);
$chunkDirPath = $data->options['documentRoot'] . '/var/export' . $chunkDir;
$chunks = array_chunk($data->contents, $data->options['chunkSize']);
$urls = [];
touch($data->options['documentRoot'] . '/var/export/.lock');
foreach ($chunks as $id => $chunk) {
$chunkPath = $chunkDirPath . $id;
$generator->reset();
$generator->startDocument($chunk);
$this->contentListElementGenerator->generateElement($generator, $chunk);
file_put_contents($chunkPath, $generator->endDocument($chunk));
$urls[] = sprintf('%s/api/ezp/v2/ez_recommendation/v1/exportDownload%s%s', $data->options['host'], $chunkDir, $id);
}
unlink($data->options['documentRoot'] . '/var/export/.lock');
echo $this->sendYCResponse($urls, $data->options, $chunkDirPath);
$generator->reset();
return $generator;
}
作者:Pix
项目:ezpublish-kerne
/**
* 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');
}
作者:CG7
项目:ezpublish-kerne
/**
* 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\FieldDefinitionList $data
*/
public function visit(Visitor $visitor, Generator $generator, $data)
{
$fieldDefinitionList = $data;
$contentType = $fieldDefinitionList->contentType;
$urlTypeSuffix = $this->getUrlTypeSuffix($contentType->status);
$generator->startObjectElement('FieldDefinitions', 'FieldDefinitionList');
$visitor->setHeader('Content-Type', $generator->getMediaType('FieldDefinitionList'));
//@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_loadContentType' . $urlTypeSuffix . 'FieldDefinitionList', array('contentTypeId' => $contentType->id)));
$generator->endAttribute('href');
$generator->startList('FieldDefinition');
foreach ($fieldDefinitionList->fieldDefinitions as $fieldDefinition) {
$visitor->visitValueObject(new ValuesRestFieldDefinition($contentType, $fieldDefinition));
}
$generator->endList('FieldDefinition');
$generator->endObjectElement('FieldDefinitions');
}