Completed
Push — language_match_api_logic ( 0dc4d1...c3b02a )
by André
16:44
created

ContentService::loadContentByVersionInfo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 3
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * File containing the ContentService class.
5
 *
6
 * @copyright Copyright (C) eZ Systems AS. All rights reserved.
7
 * @license For full copyright and license information view LICENSE file distributed with this source code.
8
 */
9
10
namespace eZ\Publish\Core\REST\Client;
11
12
use eZ\Publish\API\Repository\ContentService as APIContentService;
13
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
14
use eZ\Publish\API\Repository\Values\Content\ContentCreateStruct;
15
use eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct;
16
use eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct;
17
use eZ\Publish\API\Repository\Values\Content\LocationCreateStruct;
18
use eZ\Publish\API\Repository\Values\Content\TranslationInfo;
19
use eZ\Publish\API\Repository\Values\Content\TranslationValues;
20
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
21
use eZ\Publish\API\Repository\Values\ContentType\ContentType;
22
use eZ\Publish\API\Repository\Values\Content\Query;
23
use eZ\Publish\API\Repository\Values\User\User;
24
use eZ\Publish\Core\REST\Common\RequestParser;
25
use eZ\Publish\Core\REST\Common\Input\Dispatcher;
26
use eZ\Publish\Core\REST\Common\Output\Visitor;
27
use eZ\Publish\Core\REST\Common\Message;
28
29
/**
30
 * @example Examples/contenttype.php
31
 */
32
class ContentService implements APIContentService, Sessionable
33
{
34
    /**
35
     * @var \eZ\Publish\Core\REST\Client\HttpClient
36
     */
37
    private $client;
38
39
    /**
40
     * @var \eZ\Publish\Core\REST\Common\Input\Dispatcher
41
     */
42
    private $inputDispatcher;
43
44
    /**
45
     * @var \eZ\Publish\Core\REST\Common\Output\Visitor
46
     */
47
    private $outputVisitor;
48
49
    /**
50
     * @var \eZ\Publish\Core\REST\Common\RequestParser
51
     */
52
    private $requestParser;
53
54
    /**
55
     * @var \eZ\Publish\Core\REST\Client\ContentTypeService
56
     */
57
    private $contentTypeService;
58
59
    /**
60
     * @param \eZ\Publish\Core\REST\Client\HttpClient $client
61
     * @param \eZ\Publish\Core\REST\Common\Input\Dispatcher $inputDispatcher
62
     * @param \eZ\Publish\Core\REST\Common\Output\Visitor $outputVisitor
63
     * @param \eZ\Publish\Core\REST\Common\RequestParser $requestParser
64
     * @param \eZ\Publish\Core\REST\Client\ContentTypeService $contentTypeService
65
     */
66 View Code Duplication
    public function __construct(HttpClient $client, Dispatcher $inputDispatcher, Visitor $outputVisitor, RequestParser $requestParser, ContentTypeService $contentTypeService)
67
    {
68
        $this->client = $client;
69
        $this->inputDispatcher = $inputDispatcher;
70
        $this->outputVisitor = $outputVisitor;
71
        $this->requestParser = $requestParser;
72
        $this->contentTypeService = $contentTypeService;
73
    }
74
75
    /**
76
     * Set session ID.
77
     *
78
     * Only for testing
79
     *
80
     * @param mixed $id
81
     *
82
     * @private
83
     */
84
    public function setSession($id)
85
    {
86
        if ($this->outputVisitor instanceof Sessionable) {
87
            $this->outputVisitor->setSession($id);
88
        }
89
    }
90
91
    /**
92
     * Loads a content info object.
93
     *
94
     * To load fields use loadContent
95
     *
96
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read the content
97
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given id does not exist
98
     *
99
     * @param int $contentId
100
     *
101
     * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
102
     */
103 View Code Duplication
    public function loadContentInfo($contentId)
104
    {
105
        $response = $this->client->request(
106
            'GET',
107
            $contentId,
108
            new Message(
109
                array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
110
            )
111
        );
112
113
        $restContentInfo = $this->inputDispatcher->parse($response);
114
115
        return $this->completeContentInfo($restContentInfo);
0 ignored issues
show
Compatibility introduced by
$restContentInfo of type object<eZ\Publish\API\Re...ory\Values\ValueObject> is not a sub-type of object<eZ\Publish\Core\R...Values\RestContentInfo>. It seems like you assume a child class of the class eZ\Publish\API\Repository\Values\ValueObject to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
116
    }
117
118
    /**
119
     * Loads a content info object for the given remoteId.
120
     *
121
     * To load fields use loadContent
122
     *
123
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
124
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content with the given remote id does not exist
125
     *
126
     * @param string $remoteId
127
     *
128
     * @return \eZ\Publish\API\Repository\Values\Content\ContentInfo
129
     */
130 View Code Duplication
    public function loadContentInfoByRemoteId($remoteId)
131
    {
132
        $response = $this->client->request(
133
            'GET',
134
            $this->requestParser->generate('objectByRemote', array('object' => $remoteId)),
135
            new Message(
136
                array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
137
            )
138
        );
139
140
        if ($response->statusCode == 307) {
141
            $response = $this->client->request(
142
                'GET',
143
                $response->headers['Location'],
144
                new Message(
145
                    array('Accept' => $this->outputVisitor->getMediaType('ContentInfo'))
146
                )
147
            );
148
        }
149
150
        $restContentInfo = $this->inputDispatcher->parse($response);
151
152
        return $this->completeContentInfo($restContentInfo);
0 ignored issues
show
Compatibility introduced by
$restContentInfo of type object<eZ\Publish\API\Re...ory\Values\ValueObject> is not a sub-type of object<eZ\Publish\Core\R...Values\RestContentInfo>. It seems like you assume a child class of the class eZ\Publish\API\Repository\Values\ValueObject to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
153
    }
154
155
    /**
156
     * Returns a complete ContentInfo based on $restContentInfo.
157
     *
158
     * @param \eZ\Publish\Core\REST\Client\Values\RestContentInfo $restContentInfo
159
     *
160
     * @return \eZ\Publish\Core\REST\Client\Values\Content\ContentInfo
161
     */
162
    protected function completeContentInfo(Values\RestContentInfo $restContentInfo)
163
    {
164
        $versionUrlValues = $this->requestParser->parse(
165
            'objectVersion',
166
            $this->fetchCurrentVersionUrl($restContentInfo->currentVersionReference)
0 ignored issues
show
Documentation introduced by
The property $currentVersionReference is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
167
        );
168
169
        return new Values\Content\ContentInfo(
170
            $this->contentTypeService,
171
            array(
172
                'id' => $restContentInfo->id,
0 ignored issues
show
Documentation introduced by
The property $id is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
173
                'name' => $restContentInfo->name,
0 ignored issues
show
Documentation introduced by
The property $name is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
174
                'contentTypeId' => $restContentInfo->contentTypeId,
0 ignored issues
show
Documentation introduced by
The property $contentTypeId is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
175
                'ownerId' => $restContentInfo->ownerId,
0 ignored issues
show
Documentation introduced by
The property $ownerId is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
176
                'modificationDate' => $restContentInfo->modificationDate,
0 ignored issues
show
Documentation introduced by
The property $modificationDate is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
177
                'publishedDate' => $restContentInfo->publishedDate,
0 ignored issues
show
Documentation introduced by
The property $publishedDate is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
178
                'published' => $restContentInfo->published,
0 ignored issues
show
Documentation introduced by
The property $published is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
179
                'alwaysAvailable' => $restContentInfo->alwaysAvailable,
0 ignored issues
show
Documentation introduced by
The property $alwaysAvailable is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
180
                'remoteId' => $restContentInfo->remoteId,
0 ignored issues
show
Documentation introduced by
The property $remoteId is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
181
                'mainLanguageCode' => $restContentInfo->mainLanguageCode,
0 ignored issues
show
Documentation introduced by
The property $mainLanguageCode is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
182
                'mainLocationId' => $restContentInfo->mainLocationId,
0 ignored issues
show
Documentation introduced by
The property $mainLocationId is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
183
                'sectionId' => $restContentInfo->sectionId,
0 ignored issues
show
Documentation introduced by
The property $sectionId is declared protected in eZ\Publish\Core\REST\Client\Values\RestContentInfo. Since you implemented __get(), maybe consider adding a @property or @property-read annotation. This makes it easier for IDEs to provide auto-completion.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
184
185
                'currentVersionNo' => $versionUrlValues['version'],
186
            )
187
        );
188
    }
189
190
    /**
191
     * Returns the URL of the current version referenced by
192
     * $currentVersionReference.
193
     *
194
     * @param string $currentVersionReference
195
     *
196
     * @return string
197
     */
198
    protected function fetchCurrentVersionUrl($currentVersionReference)
199
    {
200
        $versionResponse = $this->client->request(
201
            'GET',
202
            $currentVersionReference
203
        );
204
205
        if ($this->isErrorResponse($versionResponse)) {
206
            return $this->inputDispatcher->parse($versionResponse);
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->inputDispa...arse($versionResponse); (eZ\Publish\API\Repository\Values\ValueObject) is incompatible with the return type documented by eZ\Publish\Core\REST\Cli...:fetchCurrentVersionUrl of type string.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
207
        }
208
209
        return $versionResponse->headers['Location'];
210
    }
211
212
    /**
213
     * Checks if the given response is an error.
214
     *
215
     * @param Message $response
216
     *
217
     * @return bool
218
     */
219
    protected function isErrorResponse(Message $response)
220
    {
221
        return (
222
            strpos($response->headers['Content-Type'], 'application/vnd.ez.api.ErrorMessage') === 0
223
        );
224
    }
225
226
    /**
227
     * Loads a version info of the given content object.
228
     *
229
     * If no version number is given, the method returns the current version
230
     *
231
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
232
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
233
     *
234
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
235
     * @param int $versionNo the version number. If not given the current version is returned.
236
     *
237
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
238
     */
239
    public function loadVersionInfo(ContentInfo $contentInfo, $versionNo = null)
240
    {
241
        throw new \Exception('@todo: Implement.');
242
    }
243
244
    /**
245
     * Loads a version info of the given content object id.
246
     *
247
     * If no version number is given, the method returns the current version
248
     *
249
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the version with the given number does not exist
250
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
251
     *
252
     * @param mixed $contentId
253
     * @param int $versionNo the version number. If not given the current version is returned.
254
     *
255
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo
256
     */
257
    public function loadVersionInfoById($contentId, $versionNo = null)
258
    {
259
        throw new \Exception('@todo: Implement.');
260
    }
261
262
    /**
263
     * Loads content in a version for the given content info object.
264
     *
265
     * If no version number is given, the method returns the current version
266
     *
267
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if version with the given number does not exist
268
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
269
     *
270
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
271
     * @param array $languages A language filter for fields. If not given all languages are returned
272
     * @param int $versionNo the version number. If not given the current version is returned
273
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
274
     *
275
     * @return \eZ\Publish\API\Repository\Values\Content\Content
276
     */
277
    public function loadContentByContentInfo(ContentInfo $contentInfo, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
278
    {
279
        return $this->loadContent(
280
            $contentInfo->id,
281
            $languages,
282
            $versionNo
283
        );
284
    }
285
286
    /**
287
     * Loads content in the version given by version info.
288
     *
289
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
290
     *
291
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
292
     * @param array $languages A language filter for fields. If not given all languages are returned
293
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
294
     *
295
     * @return \eZ\Publish\API\Repository\Values\Content\Content
296
     */
297
    public function loadContentByVersionInfo(VersionInfo $versionInfo, array $languages = null, $useAlwaysAvailable = true)
298
    {
299
        $contentInfo = $versionInfo->getContentInfo();
300
301
        return $this->loadContent($contentInfo->id, $languages, $versionInfo->versionNo);
302
    }
303
304
    /**
305
     * Loads content in a version of the given content object.
306
     *
307
     * If no version number is given, the method returns the current version
308
     *
309
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given id does not exist
310
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
311
     *
312
     * @param int $contentId
313
     * @param array $languages A language filter for fields. If not given all languages are returned
314
     * @param int $versionNo the version number. If not given the current version is returned
315
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
316
     *
317
     * @return \eZ\Publish\API\Repository\Values\Content\Content
318
     *
319
     * @todo Handle $versionNo = null
320
     * @todo Handle language filters
321
     */
322
    public function loadContent($contentId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
323
    {
324
        // $contentId should already be a URL!
325
        $contentIdValues = $this->requestParser->parse('object', $contentId);
326
327
        $url = '';
0 ignored issues
show
Unused Code introduced by
$url is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
328
        if ($versionNo === null) {
329
            $url = $this->fetchCurrentVersionUrl(
330
                $this->requestParser->generate(
331
                    'objectCurrentVersion',
332
                    array(
333
                        'object' => $contentIdValues['object'],
334
                    )
335
                )
336
            );
337
        } else {
338
            $url = $this->requestParser->generate(
339
                'objectVersion',
340
                array(
341
                    'object' => $contentIdValues['object'],
342
                    'version' => $versionNo,
343
                )
344
            );
345
        }
346
347
        $response = $this->client->request(
348
            'GET',
349
            $url,
350
            new Message(
351
                array('Accept' => $this->outputVisitor->getMediaType('Version'))
352
            )
353
        );
354
355
        return $this->inputDispatcher->parse($response);
356
    }
357
358
    /**
359
     * Loads content in a version for the content object reference by the given remote id.
360
     *
361
     * If no version is given, the method returns the current version
362
     *
363
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException - if the content or version with the given remote id does not exist
364
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load this version
365
     *
366
     * @param string $remoteId
367
     * @param array $languages A language filter for fields. If not given all languages are returned
368
     * @param int $versionNo the version number. If not given the current version is returned
369
     * @param bool $useAlwaysAvailable Add Main language to \$languages if true (default) and if alwaysAvailable is true
370
     *
371
     * @return \eZ\Publish\API\Repository\Values\Content\Content
372
     */
373
    public function loadContentByRemoteId($remoteId, array $languages = null, $versionNo = null, $useAlwaysAvailable = true)
374
    {
375
        $contentInfo = $this->loadContentInfoByRemoteId($remoteId);
376
377
        return $this->loadContentByContentInfo($contentInfo, $languages, $versionNo);
378
    }
379
380
    /**
381
     * Creates a new content draft assigned to the authenticated user.
382
     *
383
     * If a different userId is given in $contentCreateStruct it is assigned to the given user
384
     * but this required special rights for the authenticated user
385
     * (this is useful for content staging where the transfer process does not
386
     * have to authenticate with the user which created the content object in the source server).
387
     * The user has to publish the draft if it should be visible.
388
     * In 4.x at least one location has to be provided in the location creation array.
389
     *
390
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the content in the given location
391
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is a provided remoteId which exists in the system
392
     *                                                                        or there is no location provided (4.x) or multiple locations
393
     *                                                                        are under the same parent or if the a field value is not accepted by the field type
394
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentCreateStruct is not valid
395
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is missing
396
     *
397
     * @param \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct $contentCreateStruct
398
     * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct[] $locationCreateStructs For each location parent under which a location should be created for the content
399
     *
400
     * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
401
     */
402
    public function createContent(ContentCreateStruct $contentCreateStruct, array $locationCreateStructs = array())
403
    {
404
        throw new \Exception('@todo: Implement.');
405
    }
406
407
    /**
408
     * Updates the metadata.
409
     *
410
     * (see {@link ContentMetadataUpdateStruct}) of a content object - to update fields use updateContent
411
     *
412
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update the content meta data
413
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the remoteId in $contentMetadataUpdateStruct is set but already exists
414
     *
415
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
416
     * @param \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct $contentMetadataUpdateStruct
417
     *
418
     * @return \eZ\Publish\API\Repository\Values\Content\Content the content with the updated attributes
419
     */
420
    public function updateContentMetadata(ContentInfo $contentInfo, ContentMetadataUpdateStruct $contentMetadataUpdateStruct)
421
    {
422
        throw new \Exception('@todo: Implement.');
423
    }
424
425
    /**
426
     * Deletes a content object including all its versions and locations including their subtrees.
427
     *
428
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to delete the content (in one of the locations of the given content object)
429
     *
430
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
431
     */
432
    public function deleteContent(ContentInfo $contentInfo)
433
    {
434
        throw new \Exception('@todo: Implement.');
435
    }
436
437
    /**
438
     * Creates a draft from a published or archived version.
439
     *
440
     * If no version is given, the current published version is used.
441
     * 4.x: The draft is created with the initialLanguage code of the source version or if not present with the main language.
442
     * It can be changed on updating the version.
443
     *
444
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to create the draft
445
     *
446
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
447
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
448
     * @param \eZ\Publish\API\Repository\Values\User\User $user if set given user is used to create the draft - otherwise the current user is used
449
     *
450
     * @return \eZ\Publish\API\Repository\Values\Content\Content - the newly created content draft
451
     */
452
    public function createContentDraft(ContentInfo $contentInfo, VersionInfo $versionInfo = null, User $user = null)
453
    {
454
        throw new \Exception('@todo: Implement.');
455
    }
456
457
    /**
458
     * Loads drafts for a user.
459
     *
460
     * If no user is given the drafts for the authenticated user a returned
461
     *
462
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to load the draft list
463
     *
464
     * @param \eZ\Publish\API\Repository\Values\User\User $user
465
     *
466
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo the drafts ({@link VersionInfo}) owned by the given user
467
     */
468
    public function loadContentDrafts(User $user = null)
469
    {
470
        throw new \Exception('@todo: Implement.');
471
    }
472
473
    /**
474
     * Updates the fields of a draft.
475
     *
476
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version
477
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
478
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $contentUpdateStruct is not valid
479
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value
480
     *
481
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
482
     * @param \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct $contentUpdateStruct
483
     *
484
     * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the updated fields
485
     */
486
    public function updateContent(VersionInfo $versionInfo, ContentUpdateStruct $contentUpdateStruct)
487
    {
488
        throw new \Exception('@todo: Implement.');
489
    }
490
491
    /**
492
     * Publishes a content version.
493
     *
494
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
495
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
496
     *
497
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
498
     *
499
     * @return \eZ\Publish\API\Repository\Values\Content\Content
500
     *
501
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to publish this version
502
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
503
     */
504
    public function publishVersion(VersionInfo $versionInfo)
505
    {
506
        throw new \Exception('@todo: Implement.');
507
    }
508
509
    /**
510
     * Removes the given version.
511
     *
512
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is in
513
     *         published state or is a last version of the Content
514
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to remove this version
515
     *
516
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
517
     */
518
    public function deleteVersion(VersionInfo $versionInfo)
519
    {
520
        throw new \Exception('@todo: Implement.');
521
    }
522
523
    /**
524
     * Loads all versions for the given content.
525
     *
526
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to list versions
527
     *
528
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
529
     *
530
     * @return \eZ\Publish\API\Repository\Values\Content\VersionInfo[] Sorted by creation date
531
     */
532
    public function loadVersions(ContentInfo $contentInfo)
533
    {
534
        throw new \Exception('@todo: Implement.');
535
    }
536
537
    /**
538
     * Copies the content to a new location. If no version is given,
539
     * all versions are copied, otherwise only the given version.
540
     *
541
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to copy the content to the given location
542
     *
543
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
544
     * @param \eZ\Publish\API\Repository\Values\Content\LocationCreateStruct $destinationLocationCreateStruct the target location where the content is copied to
545
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
546
     *
547
     * @return \eZ\Publish\API\Repository\Values\Content\Content
548
     */
549
    public function copyContent(ContentInfo $contentInfo, LocationCreateStruct $destinationLocationCreateStruct, VersionInfo $versionInfo = null)
550
    {
551
        throw new \Exception('@todo: Implement.');
552
    }
553
554
    /**
555
     * Finds content objects for the given query.
556
     *
557
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
558
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
559
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
560
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
561
     *
562
     * @return \eZ\Publish\API\Repository\Values\Content\SearchResult
563
     */
564
    public function findContent(Query $query, array $languageFilter, $filterOnUserPermissions = true)
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $languageFilter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filterOnUserPermissions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
565
    {
566
        throw new \Exception('@todo: Implement.');
567
    }
568
569
    /**
570
     * Performs a query for a single content object.
571
     *
572
     * @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException if the object was not found by the query or due to permissions
573
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if the query would return more than one result
574
     *
575
     * @param \eZ\Publish\API\Repository\Values\Content\Query $query
576
     * @param array $languageFilter Configuration for specifying prioritized languages query will be performed on.
577
     *        Currently supported: <code>array("languages" => array(<language1>,..))</code>.
578
     * @param bool $filterOnUserPermissions if true only the objects which is the user allowed to read are returned.
579
     *
580
     * @return \eZ\Publish\API\Repository\Values\Content\Content
581
     */
582
    public function findSingle(Query $query, array $languageFilter, $filterOnUserPermissions = true)
0 ignored issues
show
Unused Code introduced by
The parameter $query is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $languageFilter is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $filterOnUserPermissions is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
583
    {
584
        throw new \Exception('@todo: Implement.');
585
    }
586
587
    /**
588
     * Loads all outgoing relations for the given version.
589
     *
590
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
591
     *
592
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $versionInfo
593
     *
594
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
595
     */
596
    public function loadRelations(VersionInfo $versionInfo)
597
    {
598
        throw new \Exception('@todo: Implement.');
599
    }
600
601
    /**
602
     * Loads all incoming relations for a content object.
603
     *
604
     * The relations come only
605
     * from published versions of the source content objects
606
     *
607
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to read this version
608
     *
609
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
610
     *
611
     * @return \eZ\Publish\API\Repository\Values\Content\Relation[]
612
     */
613
    public function loadReverseRelations(ContentInfo $contentInfo)
614
    {
615
        throw new \Exception('@todo: Implement.');
616
    }
617
618
    /**
619
     * Adds a relation of type common.
620
     *
621
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to edit this version
622
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
623
     *
624
     * The source of the relation is the content and version
625
     * referenced by $versionInfo.
626
     *
627
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
628
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent the destination of the relation
629
     *
630
     * @return \eZ\Publish\API\Repository\Values\Content\Relation the newly created relation
631
     */
632
    public function addRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
633
    {
634
        throw new \Exception('@todo: Implement.');
635
    }
636
637
    /**
638
     * Removes a relation of type COMMON from a draft.
639
     *
640
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed edit this version
641
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the version is not a draft
642
     * @throws \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException if there is no relation of type COMMON for the given destination
643
     *
644
     * @param \eZ\Publish\API\Repository\Values\Content\VersionInfo $sourceVersion
645
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $destinationContent
646
     */
647
    public function deleteRelation(VersionInfo $sourceVersion, ContentInfo $destinationContent)
648
    {
649
        throw new \Exception('@todo: Implement.');
650
    }
651
652
    /**
653
     * Instantiates a new content create struct object.
654
     *
655
     * alwaysAvailable is set to the ContentType's defaultAlwaysAvailable
656
     *
657
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
658
     * @param string $mainLanguageCode
659
     *
660
     * @return \eZ\Publish\API\Repository\Values\Content\ContentCreateStruct
661
     */
662
    public function newContentCreateStruct(ContentType $contentType, $mainLanguageCode)
663
    {
664
        throw new \Exception('@todo: Implement.');
665
    }
666
667
    /**
668
     * Instantiates a new content meta data update struct.
669
     *
670
     * @return \eZ\Publish\API\Repository\Values\Content\ContentMetadataUpdateStruct
671
     */
672
    public function newContentMetadataUpdateStruct()
673
    {
674
        throw new \Exception('@todo: Implement.');
675
    }
676
677
    /**
678
     * Instantiates a new content update struct.
679
     *
680
     * @return \eZ\Publish\API\Repository\Values\Content\ContentUpdateStruct
681
     */
682
    public function newContentUpdateStruct()
683
    {
684
        throw new \Exception('@todo: Implement.');
685
    }
686
687
    // Ignore this eZ Publish 5 feature by now.
688
689
    // @codeCoverageIgnoreStart
690
691
    /**
692
     * Translate a version.
693
     *
694
     * updates the destination version given in $translationInfo with the provided translated fields in $translationValues
695
     *
696
     * @example Examples/translation_5x.php
697
     *
698
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed to update this version
699
     * @throws \eZ\Publish\API\Repository\Exceptions\BadStateException if the given destination version is not a draft
700
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentValidationException if a required field is set to an empty value
701
     * @throws \eZ\Publish\API\Repository\Exceptions\ContentFieldValidationException if a field in the $translationValues is not valid
702
     *
703
     * @param \eZ\Publish\API\Repository\Values\Content\TranslationInfo $translationInfo
704
     * @param \eZ\Publish\API\Repository\Values\Content\TranslationValues $translationValues
705
     * @param \eZ\Publish\API\Repository\Values\User\User $user If set, this user is taken as modifier of the version
706
     *
707
     * @return \eZ\Publish\API\Repository\Values\Content\Content the content draft with the translated fields
708
     *
709
     * @since 5.0
710
     */
711
    public function translateVersion(TranslationInfo $translationInfo, TranslationValues $translationValues, User $user = null)
712
    {
713
        throw new \Exception('@todo: Implement.');
714
    }
715
716
    /**
717
     * Adds translation information to the content object.
718
     *
719
     * @example Examples/translation_5x.php
720
     *
721
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed add a translation info
722
     *
723
     * @param \eZ\Publish\API\Repository\Values\Content\TranslationInfo $translationInfo
724
     *
725
     * @since 5.0
726
     */
727
    public function addTranslationInfo(TranslationInfo $translationInfo)
728
    {
729
        throw new \Exception('@todo: Implement.');
730
    }
731
732
    /**
733
     * lists the translations done on this content object.
734
     *
735
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the user is not allowed read translation infos
736
     *
737
     * @param \eZ\Publish\API\Repository\Values\Content\ContentInfo $contentInfo
738
     * @param array $filter
739
     *
740
     * @todo TBD - filter by sourceversion destination version and languages
741
     *
742
     * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo[]
743
     *
744
     * @since 5.0
745
     */
746
    public function loadTranslationInfos(ContentInfo $contentInfo, array $filter = array())
747
    {
748
        throw new \Exception('@todo: Implement.');
749
    }
750
751
    /**
752
     * Instantiates a new TranslationInfo object.
753
     *
754
     * @return \eZ\Publish\API\Repository\Values\Content\TranslationInfo
755
     */
756
    public function newTranslationInfo()
757
    {
758
        throw new \Exception('@todo: Implement.');
759
    }
760
761
    /**
762
     * Instantiates a Translation object.
763
     *
764
     * @return \eZ\Publish\API\Repository\Values\Content\TranslationValues
765
     */
766
    public function newTranslationValues()
767
    {
768
        throw new \Exception('@todo: Implement.');
769
    }
770
}
771