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
|
# sugguestion? report bugs?
# go to https://github.com/chrisyue/vim-snippets/issues
priority -50
snippet classn "Basic class with namespace snippet" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
/**
* ${1:@author `!v g:snips_author`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
`$2
{
public function __construct(${3:$options})
{
${4:// code}
}$0
}
endsnippet
snippet contr "Symfony2 controller" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* ${1:@author `!v g:snips_author`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends Controller
{
}
endsnippet
snippet sfa "Symfony 2 Controller action"
/**
* @Route("/${1:route_name}", name="$1")
* @Template()
*/
public function $1Action($2)
{
$3
return ${4:array();}$0
}
endsnippet
snippet act "Symfony2 action" b
/**
* @Route("${3}", name="${4}")
* @Method({${5:"POST"}})
* @Template()
*/
public function ${1}Action(${2})
{
${6}
}
endsnippet
snippet actt "Symfony2 action and template" b
/**
* @Route("${3}", name="${4}")
* @Method({${5:"GET"}})
* @Template()
*/
public function ${1}Action(${2})
{
${6}
return [];
}`!p
relpath = os.path.relpath(path)`
endsnippet
snippet comm "Symfony2 command" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* ${3:@author `!v g:snips_author`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends ContainerAwareCommand
{
protected function configure()
{
$this->setName('${1}')
->setDescription('${2}')
->setDefinition([
new InputArgument('', InputArgument::REQUIRED, ''),
new InputOption('', null, InputOption::VALUE_NONE, ''),
]);
}
protected function execute(InputInterface $input, OutputInterface $output)
{
}
}
endsnippet
snippet subs "Symfony2 subscriber" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* ${1:@author `!v g:snips_author`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` implements EventSubscriberInterface
{
public function __construct()
{
}
/**
* {@inheritDoc}
*/
public static function getSubscribedEvents()
{
return [];
}
}
endsnippet
snippet transf "Symfony2 form data transformer" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Symfony\Component\Form\DataTransformerInterface;
use Symfony\Component\Form\Exception\TransformationFailedException;
/**
* ${3:@author `!v g:snips_author`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` implements DataTransformerInterface
{
/**
* {@inheritDoc}
*/
public function transform(${1})
{
}
/**
* {@inheritDoc}
*/
public function reverseTransform(${2})
{
}
}
endsnippet
snippet ent "Symfony2 doctrine entity" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Doctrine\ORM\Mapping as ORM;
/**
* ${3:@author `!v g:snips_author`}
*
* @ORM\Entity()
* @ORM\Table(name="`!p
tmp = re.match(r'.*(?=\.)', fn).group()
tmp = re.sub(r'\B([A-Z])', r'_\1', tmp)
snip.rv = tmp.lower()
`")
*/
`!p
m = re.search(r'Abstract', path)
if m:
snip.rv = 'abstract '
`class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
`
{
/**
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
* @ORM\Id
*/
private $id;
}
endsnippet
snippet form "Symfony2 form type" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
/**
* ${2:@author `!v g:snips_author`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends AbstractType
{
/**
* {@inheritDoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
}
/**
* {@inheritDoc}
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults();
}
/**
* {@inheritDoc}
*/
public function getName()
{
return '${1}';
}
}
endsnippet
snippet ev "Symfony2 event" b
<?php
namespace `!p
relpath = os.path.relpath(path)
m = re.search(r'[A-Z].+(?=/)', relpath)
if m:
snip.rv = m.group().replace('/', '\\')
`;
use Symfony\Component\EventDispatcher\Event;
/**
* ${2:@author `!v g:snips_author`}
*/
class `!p
snip.rv = re.match(r'.*(?=\.)', fn).group()
` extends Event
{
}
endsnippet
snippet redir "Symfony2 redirect" b
$this->redirect($this->generateUrl('${1}', ${2}));
endsnippet
snippet usecontroller "Symfony2 use Symfony\..\Controller" b
use Symfony\Bundle\FrameworkBundle\Controller\Controller;${1}
endsnippet
snippet usereauest "Symfony2 use Symfony\..\Request" b
use Symfony\Component\HttpFoundation\Request;${1}
endsnippet
snippet useroute "Symfony2 use Sensio\..\Route" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;${1}
endsnippet
snippet useresponse "Symfony2 use Symfony\..\Response" b
use Symfony\Component\HttpFoundation\Response;${1}
endsnippet
snippet usefile "Symfony2 use Symfony\..\File" b
use Symfony\Component\HttpFoundation\File\UploadedFile;${1}
endsnippet
snippet useassert "Symfony2 use Symfony\..\Constraints as Assert" b
use Symfony\Component\Validator\Constraints as Assert;${1}
endsnippet
snippet usetemplate "Symfony2 use Sensio\..\Template" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;${1}
endsnippet
snippet usecache "Symfony2 use Sensio\..\Cache" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache;${1}
endsnippet
snippet usemethod "Symfony2 use Sensio\..\Method" b
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;${1}
endsnippet
snippet usearray "Symfony2 use Doctrine\..\ArrayCollection" b
use Doctrine\Common\Collections\ArrayCollection;${1}
endsnippet
snippet useorm "Symfony2 use Doctrine\..\Mapping as ORM" b
use Doctrine\ORM\Mapping as ORM;${1}
endsnippet
snippet usesecure "Symfony2 use JMS\..\Secure" b
use JMS\SecurityExtraBundle\Annotation\Secure;${1}
endsnippet
|