-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathYandexApiYii.php
More file actions
42 lines (37 loc) · 1.2 KB
/
YandexApiYii.php
File metadata and controls
42 lines (37 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* User: aotd (work@aotd.ru)
*/
class YandexApiYii extends CApplicationComponent
{
public $client_id;
public $client_secret;
public $access_token;
public $service = 'metrika';
public $_service;
public function init()
{
parent::init();
if (Yii::getPathOfAlias('YandexApi') === false)
Yii::setPathOfAlias('YandexApi', realpath(dirname(__FILE__)));
Yii::import('YandexApi.YandexApiBase', true);
$class = 'Yandex' . ucfirst($this->service);
Yii::import('YandexApi.' . $class, true);
$this->_service = new $class($this->access_token, $this->client_id, $this->client_secret);
}
/**
* Proxy fetch allowed callable methods to service
* @param string $method
* @param array $arguments
* @return mixed
*/
public function __call($method, $arguments)
{
if (method_exists($this->_service, $method)) {
Yii::trace("Call $method of $this->service service");
return call_user_func_array(array($this->_service, $method), $arguments);
} else {
return parent::__call($method, $arguments);
}
}
}