Merge pull request #255 from chrisyue/master

add some nice symfony2 snippets
This commit is contained in:
Honza Pokorny 2013-08-02 09:55:01 -07:00
commit e5a811ad21
2 changed files with 89 additions and 2 deletions

View File

@ -4,7 +4,7 @@ snippet <? "php open tag" b
endsnippet endsnippet
snippet vdd "php var_dump and die" b snippet vdd "php var_dump and die"
var_dump(${1}); die(); var_dump(${1}); die();
endsnippet endsnippet
@ -15,6 +15,7 @@ m = re.search(r'[A-Z].+(?=/)', abspath)
if m: if m:
snip.rv = m.group().replace('/', '\\') snip.rv = m.group().replace('/', '\\')
`}; `};
endsnippet endsnippet
snippet nc "php namespace and class" b snippet nc "php namespace and class" b
@ -26,7 +27,7 @@ if m:
`}; `};
/** /**
* ${3:@author `whoami`}$4 * ${3:@author `whoami`}${4}
*/ */
class ${2:`!p class ${2:`!p
snip.rv = re.match(r'.*(?=\.)', fn).group() snip.rv = re.match(r'.*(?=\.)', fn).group()
@ -67,4 +68,15 @@ else:
return $this; return $this;
} }
public function get`!p snip.rv = t[2].capitalize()`()
{
return $this->$2;
}
endsnippet
snippet if "php if" !b
if (${1}) {
${2}
}
endsnippet endsnippet

View File

@ -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