-
Notifications
You must be signed in to change notification settings - Fork 0
/
cakephp.snippets
383 lines (274 loc) · 7.63 KB
/
cakephp.snippets
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
# Layout variables
snippet cfl
<?php echo $content_for_layout; ?>
snippet sfl
<?php echo $scripts_for_layout; ?>
snippet tfl
<?php echo $title_for_layout; ?>
# Form helper
snippet form
<?php echo $this->Form->create('${1:Model}'$2); ?>
snippet end
<?php echo $this->Form->end($3); ?>
snippet date
<?php echo $this->Form->dateTime('${1:Model}.${2:field}'$3); ?>
snippet day
<?php echo $this->Form->day('${1:Model}.${2:field}'$3); ?>
snippet err
<?php echo $this->Form->error('${1:Model}.${2:field}'$3); ?>
snippet file
<?php echo $this->Form->file('${1:Model}.${2:field}'$3); ?>
snippet hid
<?php echo $this->Form->hidden('${1:Model}.${2:field}'$3); ?>
snippet hour
<?php echo $this->Form->hour('${1:Model}.${2:field}'$3); ?>
snippet in
<?php echo $this->Form->input('${1:Model}.${2:field}'$3); ?>
snippet label
<?php echo $this->Form->label('${1:Model}.${2:field}'$3); ?>
snippet merid
<?php echo $this->Form->meridian('${1:Model}.${2:field}'$3); ?>
snippet min
<?php echo $this->Form->minute('${1:Model}.${2:field}'$3); ?>
snippet month
<?php echo $this->Form->month('${1:Model}.${2:field}'$3); ?>
snippet pass
<?php echo $this->Form->password('${1:Model}.${2:field}'$3); ?>
snippet radio
<?php echo $this->Form->radio('${1:Model}.${2:field}'$3); ?>
snippet select
<?php echo $this->Form->select('${1:Model}.${2:field}'$3); ?>
snippet submit
<?php echo $this->Form->submit(${1:'${2:Submit}'$3}); ?>
snippet text
<?php echo $this->Form->text('${1:Model}.${2:field}'$3); ?>
snippet textarea
<?php echo $this->Form->textarea('${1:Model}.${2:field}'$3); ?>
snippet year
<?php echo $this->Form->year('${1:Model}.${2:field}'$3); ?>
# HTML helper
snippet char
<?php echo $this->Html->charset($1); ?>
snippet css
<?php echo $this->Html->css(array('${1:filename}'$2)$3); ?>
snippet div
<?php echo $this->Html->div($1); ?>
snippet doc
<?php echo $this->Html->doctype('${1:xhtml-strict}'); ?>
snippet img
<?php echo $this->Html->image('${1:image.ext}', array('alt'=>'${2:altText}'$3)); ?>
snippet imgl
<?php echo $this->Html->link(
$this->Html->image('${1:image.ext}', array('alt' => '${2:altText}'$3)),
${4:array('controller' => '${5:controller}', 'action' => '${6:action}'$7),
${8:null}, ${9:null}, ${10:false}
); ?>
snippet link
<?php echo $this->Html->link('${1:text}', ${2:array('controller' => '${3:controller}', 'action' => '${4:action}'$5)); ?>
snippet metatom
<?php echo $this->Html->meta('atom', '${1:atom.xml}'); ?>
snippet metadesc
<?php echo $this->Html->meta('description', '${1:your description here}'); ?>
snippet metaicon
<?php echo $this->Html->meta('icon', '${2:favicon.ico}'); ?>
snippet metakey
<?php echo $this->Html->meta('keywords', '${1:your keywords here}'); ?>
snippet metarss
<?php echo $this->Html->meta('rss', '${1:feed.rss}'); ?>
snippet meta
<?php echo $this->Html->meta('${1:type}'$2); ?>
snippet script
<?php echo $this->Html->script(array('${1:filename}'$2)$3); ?>
snippet style
<?php echo $this->Html->style(${1:array($2)}$3); ?>
# JavaScript helper
snippet jobj
<?php echo $this->Javascript->object(${1:$data}); ?>
snippet jval
<?php echo $this->Javascript->value(${1:$var}); ?>
# Controller
snippet dela
$this->${1:ModelName}->deleteAll(${2:$conditions}${3: ,$cascade});
snippet id=
$this->${1:ModelName}->id = ${2:$id};
snippet save
$this->${1:ModelName}->save(${2:$this->data});
snippet savef
$this->${1:ModelName}->saveField('${2:$field}', ${3:$fieldValue});
snippet upa
$this->${1:ModelName}->updateAll(${2:$fields}${3: ,$conditions});
snippet find
$this->${1:ModelName}->find('${2:all}'${3: ,$params});
snippet findby
$this->${1:ModelName}->findBy${2:FieldName}(${3:$value});
snippet findallby
$this->${1:ModelName}->findAllBy${2:FieldName}(${3:$value}));
snippet field
$this->${1:ModelName}->field(${2:'${3:name}'}, ${4:'conditions'}, ${5:'order'});
# Paginator helper
snippet pcount
<?php echo $this->Paginator->counter($1); ?>
snippet plink
<?php echo $this->Paginator->link('${1:title}', array(); ?>
snippet pnum
<?php echo $this->Paginator->numbers($1); ?>
# Session component & helper
snippet scheck
$this->Session->check('${1:Controller}.${2:key}');
snippet sdel
$this->Session->delete('${1:Controller}.${2:key}');
snippet sdes
$this->Session->destroy();
snippet serr
$this->Session->error();
snippet sid
$this->Session->id();
snippet sread
$this->Session->read('${1:Controller}.${2:key}');
snippet sres
$this->Session->restore();
snippet sflash
$this->Session->setFlash('${1:message}'${2:, 'default'}${3:, $params});
snippet svalid
$this->Session->valid();
snippet swrite
$this->Session->write('${1:Controller}.${2:key}', '${3:value}');
snippet serrhelper
<?php echo $this->Session->error(); ?>
snippet sflashhelp
<?php echo $this->Session->flash(${1:'key'}); ?>
snippet sreadhelp
<?php echo $this->Session->read('${1:key}'); ?>
# Assert
snippet assertE
$this->assertEqual(${1:$result}, ${2:$expected});
snippet assertF
$this->assertFalse(${1:$result});
snippet assertP
$this->assertPattern(${1:'/${2:pattern}/'}, ${3:$result});
snippet assertT
$this->assertTrue(${1:$result});
# Misc
snippet echo
<?php echo $${1:data}['${2:Model}']['${3:field}']; ?>
snippet elem
<?php echo $this->element('${1:element}'$0); ?>
snippet ra
$this->requestAction(array('controller' => '${1:controller}', 'action' => '${2:action}'$0));
snippet de
debug($${1:data});
snippet pr
pr($${1:data});
snippet set
$this->set('${1:var}', $${2:$1});
snippet redref
$this->redirect($this->referer(${1:'/'}));
snippet re
$this->redirect(array('controller' => '${1:controller}', 'action' => '${2:action}'));
snippet ren
$this->render(${1:'action'});
snippet app
App::import('${1:LibraryName}'${2:, 'ClassName'});
snippet cr
ClassRegistry::init('${1:ModelName}');
snippet configr
Configure::read('')
snippet configw
Configure::write('$1', $2);
snippet after
/**
* Controller afterFilter callback.
* Called after the controller action is run and rendered.
*
* @return void
*/
function afterFilter() {
$1
}
snippet beforefil
/**
* Controller beforeFilter callback.
* Called before the controller action.
*
* @return void
*/
function beforeFilter() {
$1
}
snippet beforeren
/**
* Controller afterFilter callback.
* Called after the controller action is run, but before the view is rendered.
*
* @return void
*/
function beforeRender() {
$1
}
# Inflector
snippet infcam
Inflector::camelize(${1:$word})
snippet infclass
Inflector::classify(${1:$word})
snippet infhum
Inflector::humanize(${1:$word})
snippet infplur
Inflector::pluralize(${1:$word})
snippet infsing
Inflector::singularize(${1:$word})
snippet infslug
Inflector::slug(${1:$word})
snippet inftab
Inflector::tabelize(${1:$word})
snippet infunder
Inflector::underscore(${1:$word})
snippet infvar
Inflector::variable(${1:$word})
snippet afterdelete
function afterDelete() {
$1
}
# Callback methods
snippet afterfind
function afterFind(${1:$results}) {
$2
}
snippet aftersave
function afterSave(${1:$created}) {
$2
}
snippet beforedelete
function beforeDelete() {
$1
}
snippet beforefind
function beforeFind(${1:$queryData}) {
$2
}
snippet beforesave
function beforeSave() {
$1
}
snippet beforevalidate
function beforeValidate() {
$1
}
snippet onerror
function onError() {
$1
}
snippet __
__('${1}'${2:, true})${3:;}
snippet __h
<?php __('${1}'${2:, true}); ?>
# Model
snippet act
var $actsAs = array('${1:BehaviorName}'${2: => ConfigForBehavior});
snippet bt
var $belongsTo = array('${1:Model}');
snippet habtm
var $hasAndBelongsToMany = array('${1:Model}');
snippet hm
var $hasMany = array('${1:Model}');
snippet ho
var $hasOne = array('${1:Model}');