2013-11-16 19:45:48 +00:00
|
|
|
# sugguestion? report bugs?
|
|
|
|
# go to https://github.com/chrisyue/vim-snippets/issues
|
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet contr "Symfony2 controller" b
|
2013-08-03 12:50:12 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
2013-11-16 19:45:48 +00:00
|
|
|
* ${1:@author `whoami`}
|
2013-08-03 12:50:12 +00:00
|
|
|
*/
|
|
|
|
class `!p
|
|
|
|
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|
|
|
` extends Controller
|
|
|
|
{
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet act "Symfony2 action" b
|
2013-11-16 19:45:48 +00:00
|
|
|
/**
|
|
|
|
* @Route("${3}", name="${4}")
|
|
|
|
* @Method({${5:"POST"}})
|
2013-12-28 18:23:13 +00:00
|
|
|
* @Template()
|
2013-11-16 19:45:48 +00:00
|
|
|
*/
|
|
|
|
public function ${1}Action(${2})
|
|
|
|
{
|
|
|
|
${6}
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet actt "Symfony2 action and template" b
|
2013-08-03 12:50:12 +00:00
|
|
|
/**
|
|
|
|
* @Route("${3}", name="${4}")
|
|
|
|
* @Method({${5:"GET"}})
|
|
|
|
* @Template()
|
|
|
|
*/
|
|
|
|
public function ${1}Action(${2})
|
|
|
|
{
|
|
|
|
${6}
|
|
|
|
return [];
|
2013-11-16 19:45:48 +00:00
|
|
|
}`!p
|
|
|
|
abspath = os.path.abspath(path)`
|
2013-08-03 12:50:12 +00:00
|
|
|
endsnippet
|
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet comm "Symfony2 command" b
|
2013-08-03 12:50:12 +00:00
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
2013-11-16 19:45:48 +00:00
|
|
|
* ${3:@author `whoami`}
|
2013-08-03 12:50:12 +00:00
|
|
|
*/
|
|
|
|
class `!p
|
|
|
|
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|
|
|
` extends ContainerAwareCommand
|
|
|
|
{
|
|
|
|
protected function configure()
|
|
|
|
{
|
2013-12-28 18:23:13 +00:00
|
|
|
$this->setName('${1}')
|
2013-08-03 12:50:12 +00:00
|
|
|
->setDescription('${2}')
|
|
|
|
->setDefinition([
|
|
|
|
new InputArgument('', InputArgument::REQUIRED, ''),
|
|
|
|
new InputOption('', null, InputOption::VALUE_NONE, ''),
|
2013-12-28 18:23:13 +00:00
|
|
|
]);
|
2013-08-03 12:50:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endsnippet
|
2013-11-16 19:45:48 +00:00
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet subs "Symfony2 subscriber" b
|
2013-11-16 19:45:48 +00:00
|
|
|
namespace `!p
|
|
|
|
abspath = os.path.abspath(path)
|
|
|
|
m = re.search(r'[A-Z].+(?=/)', abspath)
|
|
|
|
if m:
|
|
|
|
snip.rv = m.group().replace('/', '\\')
|
|
|
|
`;
|
|
|
|
|
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ${1:@author `whoami`}
|
|
|
|
*/
|
|
|
|
class `!p
|
|
|
|
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|
|
|
` implements EventSubscriberInterface
|
|
|
|
{
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public static function getSubscribedEvents()
|
|
|
|
{
|
|
|
|
return [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet transf "Symfony2 form data transformer" b
|
2013-11-16 19:45:48 +00:00
|
|
|
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\DataTransformerInterface;
|
|
|
|
use Symfony\Component\Form\Exception\TransformationFailedException;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ${3:@author `whoami`}
|
|
|
|
*/
|
|
|
|
class `!p
|
|
|
|
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|
|
|
` implements DataTransformerInterface
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function transform(${1})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* {@inheritDoc}
|
|
|
|
*/
|
|
|
|
public function reverseTransform(${2})
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet ent "Symfony2 doctrine entity" b
|
2013-11-16 19:45:48 +00:00
|
|
|
namespace `!p
|
|
|
|
abspath = os.path.abspath(path)
|
|
|
|
m = re.search(r'[A-Z].+(?=/)', abspath)
|
|
|
|
if m:
|
|
|
|
snip.rv = m.group().replace('/', '\\')
|
|
|
|
`;
|
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ${3:@author `whoami`}
|
|
|
|
*
|
|
|
|
* @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
|
|
|
|
|
2013-12-28 18:23:13 +00:00
|
|
|
snippet form "Symfony2 form type" b
|
2013-11-16 19:45:48 +00:00
|
|
|
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
|
2013-12-28 18:23:13 +00:00
|
|
|
|
|
|
|
snippet ev "Symfony2 event" 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\EventDispatcher\Event;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ${2:@author `whoami`}
|
|
|
|
*/
|
|
|
|
class `!p
|
|
|
|
snip.rv = re.match(r'.*(?=\.)', fn).group()
|
|
|
|
` extends Event
|
|
|
|
{
|
|
|
|
}
|
|
|
|
endsnippet
|
|
|
|
|
|
|
|
snippet redir "Symfony2 redirect"
|
|
|
|
$this->redirect($this->generateUrl('${1}', ${2}));
|
|
|
|
endsnippet
|