From 0805491b0557fe32df76de1a81b3ca67116e53d5 Mon Sep 17 00:00:00 2001 From: yuhuanbo Date: Fri, 2 Aug 2013 22:12:04 +0800 Subject: [PATCH 1/2] add symfony2 snippets --- UltiSnips/php.snippets | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/UltiSnips/php.snippets b/UltiSnips/php.snippets index 45fd094..0e866d9 100644 --- a/UltiSnips/php.snippets +++ b/UltiSnips/php.snippets @@ -4,7 +4,7 @@ snippet $2; +} +endsnippet + +snippet if "php if" !b +if (${1}) { + ${2} +} endsnippet From ea27dc46277072ff8f894a4b4c02f113c329a29c Mon Sep 17 00:00:00 2001 From: yuhuanbo Date: Fri, 2 Aug 2013 22:16:05 +0800 Subject: [PATCH 2/2] fixup --- UltiSnips/php/symfony2.snippets | 75 +++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 UltiSnips/php/symfony2.snippets diff --git a/UltiSnips/php/symfony2.snippets b/UltiSnips/php/symfony2.snippets new file mode 100644 index 0000000..53df3d3 --- /dev/null +++ b/UltiSnips/php/symfony2.snippets @@ -0,0 +1,75 @@ +snippet contr "symfony2 controller" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +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 `whoami`}${2} + */ +class `!p +snip.rv = re.match(r'.*(?=\.)', fn).group() +` extends Controller +{ +} +endsnippet + +snippet act "symfony2 action" b +/** + * @Route("${3}", name="${4}") + * @Method({${5:"GET"}}) + * @Template() + */ +public function ${1}Action(${2}) +{ + ${6} + return []; +} +endsnippet + +snippet comm "symfony2 command" b +namespace `!p +abspath = os.path.abspath(path) +m = re.search(r'[A-Z].+(?=/)', abspath) +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 `whoami`}${4} + */ +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