Commit 0f3b39608f8a5654594d2237c0a33bdc137c9f28
1 parent
d497e24d
test
Showing
2 changed files
with
1 additions
and
55 deletions
Show diff stats
app/library/App/Controllers/UserController.php
... | ... | @@ -46,44 +46,7 @@ class UserController extends CrudResourceController |
46 | 46 | |
47 | 47 | public function registration() { |
48 | 48 | |
49 | - $this->beforeHandle(); | |
50 | - $this->beforeHandleWrite(); | |
51 | - $this->beforeHandleCreate(); | |
52 | - | |
53 | - $data = $this->getPostedData(); | |
54 | - | |
55 | - if (!$data || count($data) == 0) { | |
56 | - return $this->onNoDataProvided(); | |
57 | - } | |
58 | - | |
59 | - if (!$this->postDataValid($data, false)) { | |
60 | - return $this->onDataInvalid($data); | |
61 | - } | |
62 | - | |
63 | - if (!$this->saveAllowed($data) || !$this->createAllowed($data)) { | |
64 | - return $this->onNotAllowed(); | |
65 | - } | |
66 | - | |
67 | - $data = $this->transformPostData($data); | |
68 | - | |
69 | - $item = $this->createModelInstance(); | |
70 | - | |
71 | - $newItem = $this->createItem($item, $data); | |
72 | - | |
73 | - if (!$newItem) { | |
74 | - return $this->onCreateFailed($item, $data); | |
75 | - } | |
76 | - | |
77 | - $primaryKey = $this->getModelPrimaryKey(); | |
78 | - $responseData = $this->getFindData($newItem->$primaryKey); | |
79 | - | |
80 | - $response = $this->getCreateResponse($responseData, $data); | |
81 | - | |
82 | - $this->afterHandleCreate($newItem, $data, $response); | |
83 | - $this->afterHandleWrite(); | |
84 | - $this->afterHandle(); | |
85 | - | |
86 | - return $response; | |
49 | + return parent::create(); | |
87 | 50 | |
88 | 51 | } |
89 | 52 | ... | ... |
app/library/App/Model/User.php
1 | 1 | <?php |
2 | 2 | |
3 | 3 | namespace App\Model; |
4 | -use Phalcon\Mvc\Model\Validator\Email as EmailValidator; | |
5 | 4 | |
6 | 5 | class User extends \App\Mvc\DateTrackingModel |
7 | 6 | { |
... | ... | @@ -27,20 +26,4 @@ class User extends \App\Mvc\DateTrackingModel |
27 | 26 | ]; |
28 | 27 | } |
29 | 28 | |
30 | - public function validation() | |
31 | - { | |
32 | - $validator = new Validation(); | |
33 | - | |
34 | - $validator->add( | |
35 | - 'email', | |
36 | - new EmailValidator( | |
37 | - [ | |
38 | - 'model' => $this, | |
39 | - 'message' => 'Please enter a correct email address', | |
40 | - ] | |
41 | - ) | |
42 | - ); | |
43 | - | |
44 | - return $this->validate($validator); | |
45 | - } | |
46 | 29 | } | ... | ... |