-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBlogsAppModel.php
More file actions
59 lines (53 loc) · 1.19 KB
/
BlogsAppModel.php
File metadata and controls
59 lines (53 loc) · 1.19 KB
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
<?php
/**
* BlogAppModel
*/
App::uses('AppModel', 'Model');
/**
* Class BlogsAppModel
*/
class BlogsAppModel extends AppModel {
/**
* @var null 新規空データ
*/
protected $_newRecord = null;
/**
* プラリマリキーを除いた新規レコード配列を返す
* ex) array('ModelName' => array('filedName' => default, ...));
*
* @return array
*/
public function getNew() {
if (is_null($this->_newRecord)) {
$newRecord = array();
foreach ($this->_schema as $fieldName => $fieldDetail) {
if ($fieldName != $this->primaryKey) {
$newRecord[$this->name][$fieldName] = $fieldDetail['default'];
}
}
$this->_newRecord = $newRecord;
}
return $this->_newRecord;
}
/**
* バリデートメッセージ多言語化対応のためのラップ
*
* @param array $options options
* @return bool
*/
public function beforeValidate($options = array()) {
$this->validate = Hash::merge(
$this->validate,
$this->_getValidateSpecification()
);
return parent::beforeValidate($options);
}
/**
* バリデート仕様を返す(継承した各モデルで実装)
*
* @return array
*/
protected function _getValidateSpecification() {
return array();
}
}