Skip to content

Commit c7d5daf

Browse files
committed
Merge pull request #273 from chrisyue/master
add symfony2 form snip
2 parents f499a1a + 2a0cd59 commit c7d5daf

File tree

2 files changed

+51
-6
lines changed

2 files changed

+51
-6
lines changed

UltiSnips/php.snippets

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ endsnippet
6464
snippet sg "Setter and Getter" b
6565

6666
/**
67-
* @var ${3:`!p snip.rv = t[2].capitalize()`}${4}
67+
* @var ${3:`!p snip.rv = t[2].capitalize()`}
6868
*/
6969
${1:protected} $$2;
7070

UltiSnips/php/symfony2.snippets

Lines changed: 50 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# sugguestion? report bugs?
22
# go to https://github.com/chrisyue/vim-snippets/issues
3+
34
snippet contr "symfony2 controller" b
45
namespace `!p
56
abspath = os.path.abspath(path)
@@ -15,7 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller;
1516
use Symfony\Component\HttpFoundation\Request;
1617

1718
/**
18-
* ${1:@author `whoami`}${2}
19+
* ${1:@author `whoami`}
1920
*/
2021
class `!p
2122
snip.rv = re.match(r'.*(?=\.)', fn).group()
@@ -65,7 +66,7 @@ use Symfony\Component\Console\Input\InputInterface;
6566
use Symfony\Component\Console\Output\OutputInterface;
6667

6768
/**
68-
* ${3:@author `whoami`}${4}
69+
* ${3:@author `whoami`}
6970
*/
7071
class `!p
7172
snip.rv = re.match(r'.*(?=\.)', fn).group()
@@ -100,7 +101,7 @@ if m:
100101
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
101102

102103
/**
103-
* ${1:@author `whoami`}${2}
104+
* ${1:@author `whoami`}
104105
*/
105106
class `!p
106107
snip.rv = re.match(r'.*(?=\.)', fn).group()
@@ -132,7 +133,7 @@ use Symfony\Component\Form\DataTransformerInterface;
132133
use Symfony\Component\Form\Exception\TransformationFailedException;
133134

134135
/**
135-
* ${3:@author `whoami`}${4}
136+
* ${3:@author `whoami`}
136137
*/
137138
class `!p
138139
snip.rv = re.match(r'.*(?=\.)', fn).group()
@@ -165,7 +166,7 @@ if m:
165166
use Doctrine\ORM\Mapping as ORM;
166167

167168
/**
168-
* ${3:@author `whoami`}${4}
169+
* ${3:@author `whoami`}
169170
*
170171
* @ORM\Entity()
171172
* @ORM\Table(name="`!p snip.rv = re.match(r'.*(?=\.)', fn).group().lower()`")
@@ -182,3 +183,47 @@ snip.rv = re.match(r'.*(?=\.)', fn).group()
182183
private $id;
183184
}
184185
endsnippet
186+
187+
snippet form "symfony2 form type" b
188+
namespace `!p
189+
abspath = os.path.abspath(path)
190+
m = re.search(r'[A-Z].+(?=/)', abspath)
191+
if m:
192+
snip.rv = m.group().replace('/', '\\')
193+
`;
194+
195+
use Symfony\Component\Form\AbstractType;
196+
use Symfony\Component\Form\FormBuilderInterface;
197+
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
198+
199+
/**
200+
* ${2:@author `whoami`}
201+
*/
202+
class `!p
203+
snip.rv = re.match(r'.*(?=\.)', fn).group()
204+
` extends AbstractType
205+
{
206+
/**
207+
* {@inheritDoc}
208+
*/
209+
public function buildForm(FormBuilderInterface $builder, array $options)
210+
{
211+
}
212+
213+
/**
214+
* {@inheritDoc}
215+
*/
216+
public function setDefaultOptions(OptionsResolverInterface $resolver)
217+
{
218+
$resolver->setDefaults();
219+
}
220+
221+
/**
222+
* {@inheritDoc}
223+
*/
224+
public function getName()
225+
{
226+
return '${1}';
227+
}
228+
}
229+
endsnippet

0 commit comments

Comments
 (0)