1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com) |
4
|
|
|
* |
5
|
|
|
* Licensed under The MIT License |
6
|
|
|
* Redistributions of files must retain the above copyright notice. |
7
|
|
|
* |
8
|
|
|
* @copyright Copyright 2016 - 2018, Cake Development Corporation (http://cakedc.com) |
9
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace CakeDC\Api\Test\App\Service\Action; |
13
|
|
|
|
14
|
|
|
use CakeDC\Api\Exception\ValidationException; |
15
|
|
|
use CakeDC\Api\Service\Action\CrudAction; |
16
|
|
|
use Cake\Http\Exception\NotImplementedException; |
17
|
|
|
use Cake\Validation\Validator; |
18
|
|
|
|
19
|
|
|
class ArticlesTagAction extends CrudAction |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
public function initialize(array $config) |
23
|
|
|
{ |
24
|
|
|
parent::initialize($config); |
25
|
|
|
$this->Auth->allow($this->getName()); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Apply validation process. |
30
|
|
|
* |
31
|
|
|
* @return bool |
32
|
|
|
*/ |
33
|
|
|
public function validates() |
34
|
|
|
{ |
35
|
|
|
$validator = new Validator(); |
36
|
|
|
$validator |
|
|
|
|
37
|
|
|
->requirePresence('tag_id', 'create') |
38
|
|
|
->notEmpty('tag_id'); |
39
|
|
|
$errors = $validator->errors($this->getData()); |
|
|
|
|
40
|
|
|
if (!empty($errors)) { |
41
|
|
|
throw new ValidationException(__('Validation failed'), 0, null, $errors); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return true; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
public function execute() |
48
|
|
|
{ |
49
|
|
|
throw new NotImplementedException('It will never thrown as action is defined'); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Execute action. |
54
|
|
|
* |
55
|
|
|
* @param int $tag_id the tag id |
56
|
|
|
* @return mixed |
57
|
|
|
*/ |
58
|
|
|
// @codingStandardsIgnoreStart |
59
|
|
|
public function action($tag_id) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
return true; |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|
This method has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.