Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4202678

Browse files
author
fuze
committed
наборы и ограничение на кол-во методов в execute
1 parent 84d6580 commit 4202678

File tree

2 files changed

+71
-0
lines changed

2 files changed

+71
-0
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
3+
class actionContentApiContentGetDatasets extends cmsAction {
4+
5+
/**
6+
* Блокировка прямого вызова экшена
7+
* обязательное свойство
8+
* @var boolean
9+
*/
10+
public $lock_explicit_call = true;
11+
/**
12+
* Результат запроса
13+
* обязательное свойство
14+
* @var array
15+
*/
16+
public $result;
17+
18+
/**
19+
* Возможные параметры запроса
20+
* с правилами валидации
21+
* Если запрос имеет параметры, необходимо описать их здесь
22+
* Правила валидации параметров задаются по аналогии с полями форм
23+
* @var array
24+
*/
25+
public $request_params = array(
26+
'show_all' => array(
27+
'default' => 0,
28+
'rules' => array(
29+
array('digits')
30+
)
31+
)
32+
);
33+
34+
/**
35+
* Служебное свойство типа контента
36+
* для этого экшена
37+
* @var array
38+
*/
39+
private $ctype;
40+
41+
public function validateApiRequest($ctype_name=null) {
42+
43+
if(!$ctype_name){
44+
return array('error_msg' => LANG_API_EMPTY_CTYPE);
45+
}
46+
47+
$this->ctype = $this->model->getContentTypeByName($ctype_name);
48+
49+
if(!$this->ctype){
50+
return array('error_msg' => LANG_API_EMPTY_CTYPE);
51+
}
52+
53+
return false;
54+
55+
}
56+
57+
public function run($ctype_name){
58+
59+
$datasets = $this->model->getContentDatasets($this->ctype['id'], !$this->request->get('show_all'));
60+
61+
$this->result['count'] = count($datasets);
62+
$this->result['items'] = $datasets;
63+
64+
}
65+
66+
}

‎package/system/controllers/api/frontend.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ public function actionExecute() {
8484
}
8585

8686
$response = array();
87+
$max_method_count = 10;
88+
89+
if(count($methods) > $max_method_count){
90+
return $this->error(13);
91+
}
8792

8893
foreach ($methods as $method_param) {
8994

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /