Completed
Push — develop ( 5e88fe...8e0188 )
by
unknown
08:29
created

IndexController::indexAction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
/**
3
 * YAWIK
4
 *
5
 * @filesource
6
 * @copyright (c) 2013 - 2016 Cross Solution (http://cross-solution.de)
7
 * @license   MIT
8
 */
9
10
/** Geo controller */
11
namespace Geo\Controller;
12
13
use Geo\Options\ModuleOptions;
14
use Zend\Mvc\Controller\AbstractActionController;
15
use Zend\View\Model\JsonModel;
16
17
/**
18
 * Class IndexController
19
 * @package Geo\Controller
20
 */
21
class IndexController extends AbstractActionController
22
{
23
    /**
24
     * Used geo coder plugin. Copy Geo.options.local.php.dist in your autoload and configure it
25
     *
26
     * @var string $plugin
27
     */
28
    protected $plugin;
29
30
    /**
31
     * Used geo coder server. Copy Geo.options.local.php.dist in your autoload and configure it
32
     *
33
     * @var string $geoCoderUrl
34
     */
35
    protected $geoCoderUrl;
36
37
    public function __construct(ModuleOptions $options) {
38
        $this->plugin = $options->getPlugin();
39
        $this->geoCoderUrl = $options->getGeoCoderUrl();
40
    }
41
42
    /**
43
     * @return JsonModel
44
     */
45
    public function indexAction()
46
    {
47
        $client = $this->serviceLocator->get('Geo/Client');
48
        $result = $client->query($this->params()->fromQuery('q'), ['lang' => $this->params('lang')]);
49
        return new JsonModel(['items' => $result]);
50
    }
51
}