373 lines
6.7 KiB
Plaintext
373 lines
6.7 KiB
Plaintext
snippet pf "Create a public function" b
|
|
/**
|
|
* $3.
|
|
*
|
|
* $4
|
|
*/
|
|
public function $1($2)
|
|
{
|
|
$5
|
|
}
|
|
endsnippet
|
|
|
|
snippet ppf "Create a protected function" b
|
|
/**
|
|
* $3.
|
|
*
|
|
* $4
|
|
*/
|
|
protected function $1($2)
|
|
{
|
|
$5;
|
|
}
|
|
endsnippet
|
|
|
|
snippet pvf "Create a private function" b
|
|
/**
|
|
* $3.
|
|
*
|
|
* $4
|
|
*/
|
|
private function $1($2)
|
|
{
|
|
$5;
|
|
}
|
|
endsnippet
|
|
|
|
snippet php
|
|
<?php
|
|
|
|
$1
|
|
endsnippet
|
|
|
|
snippet gs "Getter and setter"
|
|
public function set${1/\w+\s*/\u$0/g}($2 \$$1): $3
|
|
{
|
|
$this->$1 = \$$1;
|
|
|
|
return \$this;
|
|
}
|
|
|
|
public function get${1/\w+\s*/\u$0/g}(): $2
|
|
{
|
|
return \$this->$1;
|
|
}
|
|
endsnippet
|
|
|
|
snippet sf2:a "Create a symfony2 controller function" b
|
|
/**
|
|
* @param Request $request
|
|
*
|
|
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
|
|
*/
|
|
public function $1Action(Request $request)
|
|
{
|
|
if ($response = $this->handleNodeSecurity($request)) {
|
|
return $response;
|
|
}
|
|
|
|
return $this->defaultRender();
|
|
}
|
|
endsnippet
|
|
|
|
snippet page "Create trinity page"
|
|
<?php
|
|
|
|
namespace `!p
|
|
relpath = os.path.relpath(path)
|
|
m = re.search(r'[A-Z].+(?=/)', relpath)
|
|
if m:
|
|
snip.rv = m.group().replace('/', '\\')
|
|
`;
|
|
|
|
use Trinity\Bundle\ContentManagerBundle\Model\Page;
|
|
use Trinity\Bundle\ContentManagerBundle\Model\Block;
|
|
use Trinity\Bundle\ContentManagerBundle\Form\Type\BlockType;
|
|
use Trinity\Bundle\ContentManagerBundle\Form\Type\TinymceAdvancedBlockType;
|
|
|
|
/**
|
|
* Class `!p snip.rv = snip.basename`.
|
|
*
|
|
* @author Simon Vieille <simon@deblan.fr>
|
|
*/
|
|
class `!p snip.rv = snip.basename` extends Page
|
|
{
|
|
/**
|
|
* Constructor.
|
|
*
|
|
* @param string $template
|
|
*/
|
|
public function __construct($template = '$1')
|
|
{
|
|
parent::__construct($template);
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function getConfiguration()
|
|
{
|
|
return $this->configuration
|
|
->setDefaultControllerClass('${2:Foo}\Bundle\\${3:Bar}Bundle\Controller\\${4:My}Controller::${5:bob}Action')
|
|
->setBlock('title', BlockType::class)
|
|
->setBlock('content', TinymceAdvancedBlockType::class);
|
|
}
|
|
|
|
/**
|
|
* Get the block "title".
|
|
*
|
|
* @return Block
|
|
*/
|
|
public function getBlockTitle()
|
|
{
|
|
return $this->getBlock('title');
|
|
}
|
|
|
|
/**
|
|
* Set the block "title".
|
|
*
|
|
* @param Block $block
|
|
*
|
|
* @return `!p snip.rv = snip.basename`
|
|
*/
|
|
public function setBlockTitle(Block $block)
|
|
{
|
|
return $this->setBlock($block);
|
|
}
|
|
|
|
/**
|
|
* Get the block "content".
|
|
*
|
|
* @return Block
|
|
*/
|
|
public function getBlockContent()
|
|
{
|
|
return $this->getBlock('content');
|
|
}
|
|
|
|
/**
|
|
* Set the block "title".
|
|
*
|
|
* @param Block $block
|
|
*
|
|
* @return `!p snip.rv = snip.basename`
|
|
*/
|
|
public function setBlockContent(Block $block)
|
|
{
|
|
return $this->setBlock($block);
|
|
}
|
|
}
|
|
endsnippet
|
|
|
|
snippet command "Create sf2 command"
|
|
<?php
|
|
|
|
namespace `!p
|
|
relpath = os.path.relpath(path)
|
|
m = re.search(r'[A-Z].+(?=/)', relpath)
|
|
if m:
|
|
snip.rv = m.group().replace('/', '\\')
|
|
`;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
use Symfony\Component\Console\Input\InputArgument;
|
|
|
|
/**
|
|
* class `!p snip.rv = snip.basename`.
|
|
*
|
|
* @author `!v g:snips_author`
|
|
*/
|
|
class `!p snip.rv = snip.basename` extends ContainerAwareCommand
|
|
{
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function configure()
|
|
{
|
|
$this
|
|
->setName('$1')
|
|
->setDescription('$2')
|
|
// ->addArgument('foo', InputArgument::OPTIONAL, '')
|
|
// ->addOption('bar', null, InputOption::VALUE_NONE, '')
|
|
->setHelp("The <info>%command.name%</info> $3");
|
|
}
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
protected function execute(InputInterface $input, OutputInterface $output)
|
|
{
|
|
// $this->getContainer()->get('foo.bar');
|
|
// $output->writeln(sprintf('<comment>%s</comment> bar.', $example));
|
|
// $input->getArgument('foo');
|
|
// $input->getOption('bar');
|
|
$4
|
|
}
|
|
}
|
|
endsnippet
|
|
|
|
snippet controller "Create trinity controller"
|
|
<?php
|
|
|
|
namespace `!p
|
|
relpath = os.path.relpath(path)
|
|
m = re.search(r'[A-Z].+(?=/)', relpath)
|
|
if m:
|
|
snip.rv = m.group().replace('/', '\\')
|
|
`;
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Trinity\Bundle\ContentManagerBundle\Controller\PageController;
|
|
|
|
/**
|
|
* class `!p snip.rv = snip.basename`.
|
|
*
|
|
* @author `!v g:snips_author`
|
|
*/
|
|
class `!p snip.rv = snip.basename` extends PageController
|
|
{
|
|
/**
|
|
* @param Request $request
|
|
*
|
|
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
|
|
*/
|
|
public function $1Action(Request $request)
|
|
{
|
|
if ($response = $this->handleNodeSecurity($request)) {
|
|
return $response;
|
|
}
|
|
|
|
$2
|
|
|
|
return $this->defaultRender();
|
|
}
|
|
}
|
|
endsnippet
|
|
|
|
|
|
snippet form "Create sf2 form"
|
|
<?php
|
|
|
|
namespace `!p
|
|
relpath = os.path.relpath(path)
|
|
m = re.search(r'[A-Z].+(?=/)', relpath)
|
|
if m:
|
|
snip.rv = m.group().replace('/', '\\')
|
|
`;
|
|
|
|
use Propel\PropelBundle\Form\BaseAbstractType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
|
|
/**
|
|
* class `!p snip.rv = snip.basename`.
|
|
*
|
|
* @author `!v g:snips_author`
|
|
*/
|
|
class `!p snip.rv = snip.basename` extends BaseAbstractType
|
|
{
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $options = [
|
|
'name' => '$1',
|
|
];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$2
|
|
}
|
|
}
|
|
endsnippet
|
|
|
|
snippet array "Create array"
|
|
[$1]
|
|
endsnippet
|
|
|
|
snippet foreach "foreach"
|
|
foreach (\$${1}s as \$$1) {
|
|
$2
|
|
}
|
|
endsnippet
|
|
|
|
snippet block "block"
|
|
/**
|
|
* Set the block "$1".
|
|
*
|
|
* @param Block $block
|
|
*
|
|
* @return `!p snip.rv = snip.basename`
|
|
*/
|
|
public function setBlock${1/\w+\s*/\u$0/}(Block $block)
|
|
{
|
|
return $this->setBlock($block);
|
|
}
|
|
|
|
/**
|
|
* Get the block "$1".
|
|
*
|
|
* @return Block
|
|
*/
|
|
public function getBlock${1/\w+\s*/\u$0/}()
|
|
{
|
|
return $this->getBlock('${1/(\w+)/\l$0/}');
|
|
}
|
|
endsnippet
|
|
|
|
snippet ind "inheritdoc comment" b
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
endsnippet
|
|
|
|
snippet prop "Class attribute/property" b
|
|
/**
|
|
* @var $2
|
|
*/
|
|
protected \$$1;
|
|
|
|
$3
|
|
endsnippet
|
|
|
|
snippet class "Class" b
|
|
<?php
|
|
|
|
namespace `!p
|
|
relpath = os.path.relpath(path)
|
|
m = re.search(r'[A-Z].+(?=/)', relpath)
|
|
if m:
|
|
snip.rv = m.group().replace('/', '\\')
|
|
`;
|
|
|
|
/**
|
|
* class $1.
|
|
*
|
|
* @author `!v g:snips_author`
|
|
*/
|
|
class $1
|
|
{
|
|
$2
|
|
}
|
|
endsnippet
|
|
|
|
snippet rest "JMS annotation" b
|
|
/**
|
|
* @JMS\Serializer\Annotation\SerializedName("$1")
|
|
* @JMS\Serializer\Annotation\Groups({"$2"})
|
|
* @JMS\Serializer\Annotation\VirtualProperty
|
|
*/
|
|
public function getRest${1/\w+\s*/\u$0/}()
|
|
{
|
|
return $this->get${1/\w+\s*/\u$0/}();
|
|
}
|
|
endsnippet
|
|
|
|
snippet rest_class "JMS class annotation"
|
|
* @JMS\Serializer\Annotation\ExclusionPolicy("all")
|
|
endsnippet
|