Note: NEVER USE THIS IN PRODUCTION!
См. также: eZ\Publish\API\Repository\Repository
Наследование: extends Repository, implements eZ\Publish\Core\REST\Client\Sessionable
Пример #1
0
 */
// Set communication encoding depending on environment defined in the
// phpunit.xml files. This defines what encoding will be generated and thus send
// to the server.
$generator = getenv('backendEncoding') === 'xml' ? new Common\Output\Generator\Xml(new Common\Output\Generator\Xml\FieldTypeHashGenerator()) : new Common\Output\Generator\Json(new Common\Output\Generator\Json\FieldTypeHashGenerator());
// The URL Handler is responsible for URL parsing and generation. It will be
// used in the output generators and in some parsing handlers.
$requestParser = new Common\RequestParser\EzPublish();
// FieldTypes to be used in integration tests. The field types are only used
// in terms of conversions from and to hash values.
$fieldTypes = array(new Client\FieldType(new FieldType\Author\Type()), new Client\FieldType(new FieldType\Checkbox\Type()), new Client\FieldType(new FieldType\DateAndTime\Type()), new Client\FieldType(new FieldType\Float\Type()), new Client\FieldType(new FieldType\Integer\Type()), new Client\FieldType(new FieldType\Keyword\Type()), new Client\FieldType(new FieldType\MapLocation\Type()), new Client\FieldType(new FieldType\Relation\Type()), new Client\FieldType(new FieldType\RelationList\Type()), new Client\FieldType(new FieldType\Selection\Type()), new Client\FieldType(new FieldType\TextBlock\Type()), new Client\FieldType(new FieldType\TextLine\Type()), new Client\FieldType(new FieldType\Url\Type()), new Client\FieldType(new FieldType\User\Type()), new Client\FieldType(new FieldType\Null\Type('ezpage')));
// The IntegrationTestRepository is only meant for integration tests. It
// handles sessions which run throughout a single test case run and submission
// of user information to the server, which needs a corresponding
// authenticator.
$repository = new Client\IntegrationTestRepository($authenticator = new Client\HttpClient\Authentication\IntegrationTestAuthenticator(new Client\HttpClient\Stream(HTTP_BASE_URL)), new Common\Input\Dispatcher($parsingDispatcher = new Common\Input\ParsingDispatcher(), array('json' => new Common\Input\Handler\Json(), 'xml' => new Common\Input\Handler\Xml())), new Common\Output\Visitor($generator, array('\\eZ\\Publish\\API\\Repository\\Values\\Content\\SectionCreateStruct' => new Client\Output\ValueObjectVisitor\SectionCreateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\Content\\SectionUpdateStruct' => new Client\Output\ValueObjectVisitor\SectionUpdateStruct($requestParser), '\\eZ\\Publish\\Core\\REST\\Common\\Values\\SectionIncludingContentMetadataUpdateStruct' => new Client\Output\ValueObjectVisitor\SectionIncludingContentMetadataUpdateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\User\\RoleCreateStruct' => new Client\Output\ValueObjectVisitor\RoleCreateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\User\\RoleUpdateStruct' => new Client\Output\ValueObjectVisitor\RoleUpdateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\User\\PolicyCreateStruct' => new Client\Output\ValueObjectVisitor\PolicyCreateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\User\\Limitation' => new Client\Output\ValueObjectVisitor\Limitation($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\User\\PolicyUpdateStruct' => new Client\Output\ValueObjectVisitor\PolicyUpdateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\Content\\LocationCreateStruct' => new Client\Output\ValueObjectVisitor\LocationCreateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateGroupCreateStruct' => new Client\Output\ValueObjectVisitor\ObjectStateGroupCreateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateGroupUpdateStruct' => new Client\Output\ValueObjectVisitor\ObjectStateGroupUpdateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateCreateStruct' => new Client\Output\ValueObjectVisitor\ObjectStateCreateStruct($requestParser), '\\eZ\\Publish\\API\\Repository\\Values\\ObjectState\\ObjectStateUpdateStruct' => new Client\Output\ValueObjectVisitor\ObjectStateUpdateStruct($requestParser))), $requestParser, $fieldTypes, $authenticator);
// Object with convenience methods for parsers
$parserTools = new Common\Input\ParserTools();
// Parser for field values (using FieldTypes for toHash()/fromHash() operations)
$fieldTypeParser = new Common\Input\FieldTypeParser($repository->getContentService(), $repository->getContentTypeService(), $repository->getFieldTypeService(), new Common\FieldTypeProcessorRegistry());
// The parsing dispatcher configures which parsers are used for which
// mime type. The mime types (content types) are provided *WITHOUT* an
// encoding type (+json / +xml).
//
// For each mime type you specify an instance of the parser which
// should be used to process the given mime type.
$inputParsers = array('application/vnd.ez.api.Version' => new Client\Input\Parser\Content($parserTools, $repository->getContentService(), new Client\Input\Parser\VersionInfo($parserTools, $repository->getContentService()), $fieldTypeParser), 'application/vnd.ez.api.ContentList' => new Client\Input\Parser\ContentList(), 'application/vnd.ez.api.ContentInfo' => new Client\Input\Parser\ContentInfo($parserTools, $repository->getContentTypeService()), 'application/vnd.ez.api.ContentType' => new Client\Input\Parser\ContentType($parserTools, $repository->getContentTypeService()), 'application/vnd.ez.api.FieldDefinitionList' => new Client\Input\Parser\FieldDefinitionList($parserTools, $repository->getContentTypeService()), 'application/vnd.ez.api.FieldDefinition' => new Client\Input\Parser\FieldDefinition($parserTools, $fieldTypeParser), 'application/vnd.ez.api.SectionList' => new Client\Input\Parser\SectionList(), 'application/vnd.ez.api.Section' => new Client\Input\Parser\Section(), 'application/vnd.ez.api.ErrorMessage' => new Client\Input\Parser\ErrorMessage(), 'application/vnd.ez.api.RoleList' => new Client\Input\Parser\RoleList(), 'application/vnd.ez.api.Role' => new Client\Input\Parser\Role(), 'application/vnd.ez.api.Policy' => new Client\Input\Parser\Policy(), 'application/vnd.ez.api.limitation' => new Client\Input\Parser\Limitation(), 'application/vnd.ez.api.PolicyList' => new Client\Input\Parser\PolicyList(), 'application/vnd.ez.api.RelationList' => new Client\Input\Parser\RelationList(), 'application/vnd.ez.api.Relation' => new Client\Input\Parser\Relation($repository->getContentService()), 'application/vnd.ez.api.RoleAssignmentList' => new Client\Input\Parser\RoleAssignmentList(), 'application/vnd.ez.api.RoleAssignment' => new Client\Input\Parser\RoleAssignment(), 'application/vnd.ez.api.Location' => new Client\Input\Parser\Location($parserTools), 'application/vnd.ez.api.LocationList' => new Client\Input\Parser\LocationList(), 'application/vnd.ez.api.ObjectStateGroup' => new Client\Input\Parser\ObjectStateGroup($parserTools), 'application/vnd.ez.api.ObjectStateGroupList' => new Client\Input\Parser\ObjectStateGroupList(), 'application/vnd.ez.api.ObjectState' => new Client\Input\Parser\ObjectState($parserTools), 'application/vnd.ez.api.ObjectStateList' => new Client\Input\Parser\ObjectStateList());
foreach ($inputParsers as $mimeType => $parser) {
    $parsingDispatcher->addParser($mimeType, $parser);
}
// Force sets the used user. This will be refactored most likely, since this is