Code Duplication    Length = 33-36 lines in 2 locations

Core/ReferenceResolver/ContentResolver.php 1 location

@@ 11-43 (lines=33) @@
8
 * Handles references to Contents. Supports remote Ids at the moment.
9
 * @deprecated
10
 */
11
class ContentResolver extends AbstractResolver
12
{
13
    /**
14
     * Constant defining the prefix for all reference identifier strings in definitions
15
     */
16
    protected $referencePrefixes = array('content_remote_id:');
17
18
    protected $contentMatcher;
19
20
    /**
21
     * @param ContentMatcher $contentMatcher
22
     */
23
    public function __construct(ContentMatcher $contentMatcher)
24
    {
25
        parent::__construct();
26
27
        $this->contentMatcher = $contentMatcher;
28
    }
29
30
    /**
31
     * @param $stringIdentifier format: content_remote_id:<remote_id>
32
     * @return string Content id
33
     * @throws \Exception
34
     */
35
    public function getReferenceValue($stringIdentifier)
36
    {
37
        $ref = $this->getReferenceIdentifierByPrefix($stringIdentifier);
38
        switch($ref['prefix']) {
39
            case 'content_remote_id:':
40
                return $this->contentMatcher->matchOne(array(ContentMatcher::MATCH_CONTENT_REMOTE_ID => $ref['identifier']))->id;
41
        }
42
    }
43
}
44

Core/ReferenceResolver/LocationResolver.php 1 location

@@ 12-47 (lines=36) @@
9
 *
10
 * @todo drop support for 'location:' in favour of 'location_remote_id:'
11
 */
12
class LocationResolver extends AbstractResolver
13
{
14
    /**
15
     * Defines the prefix for all reference identifier strings in definitions
16
     */
17
    protected $referencePrefixes = array('location:' /*, 'location_remote_id:'*/);
18
19
    protected $locationMatcher;
20
21
    /**
22
     * @param LocationMatcher $locationMatcher
23
     */
24
    public function __construct(LocationMatcher $locationMatcher)
25
    {
26
        parent::__construct();
27
28
        $this->locationMatcher = $locationMatcher;
29
    }
30
31
    /**
32
     * @param $stringIdentifier location:<remote_id>
33
     * @return string Location id
34
     * @throws \Exception
35
     */
36
    public function getReferenceValue($stringIdentifier)
37
    {
38
        $ref = $this->getReferenceIdentifierByPrefix($stringIdentifier);
39
        switch($ref['prefix']) {
40
            // deprecated tag: 'location:'
41
            case 'location:':
42
                return $this->locationMatcher->MatchOne(array(LocationMatcher::MATCH_LOCATION_REMOTE_ID => $ref['identifier']))->id;
43
            //case 'location_remote_id:':
44
            //    return $this->repository->getLocationService()->loadLocationByRemoteId($ref['identifier'])->id;
45
        }
46
    }
47
}
48