Passed
Push — 4-cactus ( b46433...1ce1ed )
by Paolo
02:42
created

TranslationsController::getAvailableUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * BEdita, API-first content management framework
4
 * Copyright 2018 ChannelWeb Srl, Chialab Srl
5
 *
6
 * This file is part of BEdita: you can redistribute it and/or modify
7
 * it under the terms of the GNU Lesser General Public License as published
8
 * by the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * See LICENSE.LGPL or <http://gnu.org/licenses/lgpl-3.0.html> for more details.
12
 */
13
namespace BEdita\API\Controller;
14
15
use BEdita\Core\Model\Action\ListRelatedObjectsAction;
16
use Cake\ORM\Association;
17
use Cake\Routing\Router;
18
19
/**
20
 * Controller for `/translations` endpoint.
21
 *
22
 * @since 4.0.0
23
 *
24
 * @property \BEdita\Core\Model\Table\TranslationsTable $Translations
25
 */
26
class TranslationsController extends ResourcesController
27
{
28
29
    /**
30
     * {@inheritDoc}
31
     */
32
    public $modelClass = 'Translations';
33
34
    /**
35
     * {@inheritDoc}
36
     */
37
    protected $_defaultConfig = [
38
        'allowedAssociations' => [
39
            'object' => [],
40
        ],
41
    ];
42
43
    /**
44
     * {@inheritDoc}
45
     */
46
    protected function getAvailableUrl($relationship)
47
    {
48
        return Router::url(
49
            [
50
                '_name' => 'api:objects:index',
51
                'object_type' => 'objects'
52
            ],
53
            true
54
        );
55
    }
56
57
    /**
58
     * {@inheritDoc}
59
     *
60
     * @return \BEdita\Core\Model\Action\ListRelatedObjectsAction
61
     */
62
    protected function getAssociatedAction(Association $association)
63
    {
64
        return new ListRelatedObjectsAction(compact('association'));
65
    }
66
}
67