From 2a0cd591e7032f2f71801efba92f58b7e24651ca Mon Sep 17 00:00:00 2001 From: yuhuanbo Date: Thu, 5 Sep 2013 21:08:21 +0800 Subject: [PATCH] add symfony2 form snip --- UltiSnips/php.snippets | 2 +- UltiSnips/php/symfony2.snippets | 55 ++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 6 deletions(-) diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets index 96cae35..7cc3e3c 100644 --- a/UltiSnips/php.snippets +++ b/UltiSnips/php.snippets @@ -64,7 +64,7 @@ endsnippet snippet sg "Setter and Getter" b /** - * @var ${3:`!p snip.rv = t[2].capitalize()`}${4} + * @var ${3:`!p snip.rv = t[2].capitalize()`} */ ${1:protected} $$2; diff --git a/UltiSnips/php/symfony2.snippets b/UltiSnips/php/symfony2.snippets index 0c7951a..5f47ce4 100644 --- a/UltiSnips/php/symfony2.snippets +++ b/UltiSnips/php/symfony2.snippets @@ -1,5 +1,6 @@ # sugguestion? report bugs? # go to https://github.com/chrisyue/vim-snippets/issues + snippet contr "symfony2 controller" b namespace `!p abspath = os.path.abspath(path) @@ -15,7 +16,7 @@ use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Request; /** - * ${1:@author `whoami`}${2} + * ${1:@author `whoami`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -65,7 +66,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; /** - * ${3:@author `whoami`}${4} + * ${3:@author `whoami`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -100,7 +101,7 @@ if m: use Symfony\Component\EventDispatcher\EventSubscriberInterface; /** - * ${1:@author `whoami`}${2} + * ${1:@author `whoami`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -132,7 +133,7 @@ use Symfony\Component\Form\DataTransformerInterface; use Symfony\Component\Form\Exception\TransformationFailedException; /** - * ${3:@author `whoami`}${4} + * ${3:@author `whoami`} */ class `!p snip.rv = re.match(r'.*(?=\.)', fn).group() @@ -165,7 +166,7 @@ if m: use Doctrine\ORM\Mapping as ORM; /** - * ${3:@author `whoami`}${4} + * ${3:@author `whoami`} * * @ORM\Entity() * @ORM\Table(name="`!p snip.rv = re.match(r'.*(?=\.)', fn).group().lower()`") @@ -182,3 +183,47 @@ snip.rv = re.match(r'.*(?=\.)', fn).group() private $id; } endsnippet + +snippet form "symfony2 form type" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +if m: + snip.rv = m.group().replace('/', '\\') +`; + +use Symfony\Component\Form\AbstractType; +use Symfony\Component\Form\FormBuilderInterface; +use Symfony\Component\OptionsResolver\OptionsResolverInterface; + +/** + * ${2:@author `whoami`} + */ +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