Commit b38ef2282c77e8fc06f53a300fdfa5790712d1da
1 parent
b2bed68d
generate GaResource
Showing
4 changed files
with
66 additions
and
4 deletions
Show diff stats
app/library/App/Bootstrap/CollectionBootstrap.php
@@ -21,6 +21,7 @@ class CollectionBootstrap implements BootstrapInterface | @@ -21,6 +21,7 @@ class CollectionBootstrap implements BootstrapInterface | ||
21 | ->resource(new UserResource('/users')) | 21 | ->resource(new UserResource('/users')) |
22 | ->resource(new AlbumResource('/albums')) | 22 | ->resource(new AlbumResource('/albums')) |
23 | ->resource(new PhotoResource('/photos')) | 23 | ->resource(new PhotoResource('/photos')) |
24 | - ->resource(new ProjectResource('/projects')); | 24 | + ->resource(new ProjectResource('/projects')) |
25 | + ->resource(new ProjectResource('/ga')); | ||
25 | } | 26 | } |
26 | } | 27 | } |
app/library/App/Bootstrap/RouteBootstrap.php
@@ -7,6 +7,7 @@ use App\Constants\Services; | @@ -7,6 +7,7 @@ use App\Constants\Services; | ||
7 | use Phalcon\Config; | 7 | use Phalcon\Config; |
8 | use Phalcon\DiInterface; | 8 | use Phalcon\DiInterface; |
9 | use PhalconRest\Api; | 9 | use PhalconRest\Api; |
10 | + | ||
10 | use Google_Client; | 11 | use Google_Client; |
11 | use Google_Service_AnalyticsReporting; | 12 | use Google_Service_AnalyticsReporting; |
12 | use Google_Service_AnalyticsReporting_DateRange; | 13 | use Google_Service_AnalyticsReporting_DateRange; |
@@ -19,7 +20,6 @@ use Google_Service_AnalyticsReporting_GetReportsRequest; | @@ -19,7 +20,6 @@ use Google_Service_AnalyticsReporting_GetReportsRequest; | ||
19 | 20 | ||
20 | class RouteBootstrap implements BootstrapInterface | 21 | class RouteBootstrap implements BootstrapInterface |
21 | { | 22 | { |
22 | - public $VIEW_ID = '123'; | ||
23 | 23 | ||
24 | public function run(Api $api, DiInterface $di, Config $config) | 24 | public function run(Api $api, DiInterface $di, Config $config) |
25 | { | 25 | { |
@@ -66,8 +66,8 @@ class RouteBootstrap implements BootstrapInterface | @@ -66,8 +66,8 @@ class RouteBootstrap implements BootstrapInterface | ||
66 | 66 | ||
67 | $param[] = ['metric' => 'ga:sessions', 'alias' => 'Сессии']; | 67 | $param[] = ['metric' => 'ga:sessions', 'alias' => 'Сессии']; |
68 | $param[] = ['metric' => 'ga:users', 'alias' => 'Пользователи']; | 68 | $param[] = ['metric' => 'ga:users', 'alias' => 'Пользователи']; |
69 | - $param[] = ['metric' => 'ga:CTR', 'alias' => 'CTR']; | ||
70 | - $param[] = ['metric' => 'ga:goal1Value', 'alias' => 'цель "Корзина"']; | 69 | + //$param[] = ['metric' => 'ga:CTR', 'alias' => 'CTR']; |
70 | + //$param[] = ['metric' => 'ga:goal1Value', 'alias' => 'цель "Корзина"']; | ||
71 | 71 | ||
72 | $VIEW_ID = "119240817"; | 72 | $VIEW_ID = "119240817"; |
73 | 73 |
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Alex Savenko | ||
5 | + * Date: 09.02.2017 | ||
6 | + * Time: 18:12 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace App\Controllers; | ||
10 | + | ||
11 | + | ||
12 | +use PhalconRest\Mvc\Controllers\CrudResourceController; | ||
13 | + | ||
14 | +class GaController extends CrudResourceController { | ||
15 | + | ||
16 | + public function gaRequest() { | ||
17 | + | ||
18 | + return "123"; | ||
19 | + | ||
20 | + } | ||
21 | + | ||
22 | +} | ||
0 | \ No newline at end of file | 23 | \ No newline at end of file |
1 | +<?php | ||
2 | +/** | ||
3 | + * Created by PhpStorm. | ||
4 | + * User: Alex Savenko | ||
5 | + * Date: 09.02.2017 | ||
6 | + * Time: 18:02 | ||
7 | + */ | ||
8 | + | ||
9 | +namespace App\Resources; | ||
10 | + | ||
11 | + | ||
12 | +use App\Constants\AclRoles; | ||
13 | +use App\Controllers\GaController; | ||
14 | +use PhalconRest\Api\ApiEndpoint; | ||
15 | +use PhalconRest\Api\ApiResource; | ||
16 | + | ||
17 | +class GaResource extends ApiResource { | ||
18 | + | ||
19 | + public function initialize() { | ||
20 | + | ||
21 | + $this | ||
22 | + ->name('Google Analytics') | ||
23 | + //->model(Project::class) | ||
24 | + ->expectsJsonData() | ||
25 | + //->transformer(ModelTransformer::class) | ||
26 | + ->itemKey('ga') | ||
27 | + ->collectionKey('ga') | ||
28 | + ->deny(AclRoles::UNAUTHORIZED) | ||
29 | + ->handler(GaController::class) | ||
30 | + | ||
31 | + ->endpoint(ApiEndpoint::get('/', 'gaRequest') | ||
32 | + ->allow(AclRoles::USER) | ||
33 | + ->description('Returns data from Google Analytics Api') | ||
34 | + ) | ||
35 | + ; | ||
36 | + | ||
37 | + } | ||
38 | + | ||
39 | +} | ||
0 | \ No newline at end of file | 40 | \ No newline at end of file |