forked from kuisatz/slim_okulsis_v4
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysclusters.php
108 lines (87 loc) · 3.73 KB
/
sysclusters.php
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
// test commit for branch slim2
require 'vendor/autoload.php';
use \Services\Filter\Helper\FilterFactoryNames as stripChainers;
/* $app = new \Slim\Slim(array(
'mode' => 'development',
'debug' => true,
'log.enabled' => true,
)); */
$app = new \Slim\SlimExtended(array(
'mode' => 'development',
'debug' => true,
'log.enabled' => true,
'log.level' => \Slim\Log::INFO,
'exceptions.rabbitMQ' => true,
'exceptions.rabbitMQ.logging' => \Slim\SlimExtended::LOG_RABBITMQ_FILE,
'exceptions.rabbitMQ.queue.name' => \Slim\SlimExtended::EXCEPTIONS_RABBITMQ_QUEUE_NAME
));
/**
* "Cross-origion resource sharing" kontrolüne izin verilmesi için eklenmiştir
* @author Okan CIRAN
* @since 2.10.2015
*/
$res = $app->response();
$res->header('Access-Control-Allow-Origin', '*');
$res->header("Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS");
$app->add(new \Slim\Middleware\MiddlewareInsertUpdateDeleteLog());
$app->add(new \Slim\Middleware\MiddlewareHMAC());
$app->add(new \Slim\Middleware\MiddlewareSecurity());
$app->add(new \Slim\Middleware\MiddlewareMQManager());
$app->add(new \Slim\Middleware\MiddlewareBLLManager());
$app->add(new \Slim\Middleware\MiddlewareDalManager());
$app->add(new \Slim\Middleware\MiddlewareServiceManager());
$app->add(new \Slim\Middleware\MiddlewareMQManager());
/**
* Okan CIRAN
* @since 09-06-2016
*/
$app->get("/pkFillClustersTree_sysClusters/", function () use ($app ) {
$stripper = $app->getServiceManager()->get('filterChainerCustom');
$stripChainerFactory = new \Services\Filter\Helper\FilterChainerFactory();
$BLL = $app->getBLLManager()->get('sysClustersBLL');
$headerParams = $app->request()->headers();
if (!isset($headerParams['X-Public'])) {
throw new Exception('rest api "pkFillClustersTree_sysClusters" end point, X-Public variable not found');
}
$pk = $headerParams['X-Public'];
$vLanguageCode = 'tr';
if (isset($_GET['language_code'])) {
$stripper->offsetSet('language_code', $stripChainerFactory->get(stripChainers::FILTER_ONLY_LANGUAGE_CODE,
$app,
$_GET['language_code']));
}
$vParentId = 0;
if (isset($_GET['parent_id'])) {
$stripper->offsetSet('parent_id', $stripChainerFactory->get(stripChainers::FILTER_ONLY_NUMBER_ALLOWED,
$app,
$_GET['parent_id']));
}
$stripper->strip();
if ($stripper->offsetExists('language_code')) {
$vLanguageCode = $stripper->offsetGet('language_code')->getFilterValue();
}
if($stripper->offsetExists('parent_id')) {
$vParentId = $stripper->offsetGet('parent_id')->getFilterValue();
}
$resultArray = $BLL->fillClustersTree(array('parent_id' => $vParentId,
'language_code' => $vLanguageCode,
'pk' => $pk,
));
$flows = array();
foreach ($resultArray as $flow) {
$flows[] = array(
"id" => $flow["id"],
//"text" => strtolower($flow["name"]),
"text" => $flow["name"],
"state" => $flow["state_type"], // 'closed',
"checked" => false,
"icon_class"=>NULL,
"attributes" => array("root" => $flow["root_type"], "active" => $flow["active"]
,"last_node" => $flow["last_node"]),
);
}
$app->response()->header("Content-Type", "application/json");
$app->response()->body(json_encode($flows));
});
$app->run();