282 lines
5.7 KiB
Plaintext
282 lines
5.7 KiB
Plaintext
snippet pf "Create a public function" b
|
|
public function $1()
|
|
{
|
|
return $this;
|
|
}
|
|
endsnippet
|
|
|
|
snippet ppf "Create a private function" b
|
|
public function $1()
|
|
{
|
|
return $this;
|
|
}
|
|
endsnippet
|
|
|
|
snippet ptf "Create a protected function" b
|
|
public function $1()
|
|
{
|
|
return $this;
|
|
}
|
|
endsnippet
|
|
|
|
snippet php
|
|
<?php $1 ?>
|
|
endsnippet
|
|
|
|
snippet gs "Getter and setter"
|
|
public function set${1/\w+\s*/\u$0/g}(\$$1)
|
|
{
|
|
$this->$1 = \$$1;
|
|
|
|
return \$this;
|
|
}
|
|
|
|
public function get${1/\w+\s*/\u$0/g}()
|
|
{
|
|
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
|
|
|
|
`!p snip.rv = os.popen('/home/simon/bin/namespace ' + path).readline().strip()`
|
|
|
|
use Trinity\Bundle\ContentManagerBundle\Model\Page;
|
|
use Trinity\Bundle\ContentManagerBundle\Model\Block;
|
|
|
|
/**
|
|
* @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
|
|
->setDefaultController('FooBarBundle:MyController:bob')
|
|
->setDefaultControllerClass('Foo\Bundle\BarBundle\Controller\MyController::bobAction')
|
|
->setBlock('title', 'Trinity\Bundle\ContentManagerBundle\Form\Type\BlockType')
|
|
->setBlock('content', 'Trinity\Bundle\ContentManagerBundle\Form\Type\TinymceAdvancedBlockType');
|
|
}
|
|
|
|
/**
|
|
* Getter for the block title
|
|
*
|
|
* @return Block
|
|
*/
|
|
public function getBlockTitle()
|
|
{
|
|
return $this->getBlock('title');
|
|
}
|
|
|
|
/**
|
|
* Setter for the block title
|
|
*
|
|
* @param Block $block
|
|
*
|
|
* @return `!p snip.rv = snip.basename`
|
|
*/
|
|
public function setBlockTitle(Block $block)
|
|
{
|
|
return $this->setBlock($block);
|
|
}
|
|
|
|
/**
|
|
* Getter for the block content
|
|
*
|
|
* @return Block
|
|
*/
|
|
public function getBlockContent()
|
|
{
|
|
return $this->getBlock('content');
|
|
}
|
|
|
|
/**
|
|
* Setter for 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
|
|
|
|
`!p snip.rv = os.popen('/home/simon/bin/namespace ' + path).readline().strip()`
|
|
|
|
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;
|
|
|
|
/**
|
|
* @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');
|
|
}
|
|
}
|
|
endsnippet
|
|
|
|
snippet controller "Create trinity controller"
|
|
<?php
|
|
|
|
`!p snip.rv = os.popen('/home/simon/bin/namespace ' + path).readline().strip()`
|
|
|
|
use Symfony\Component\HttpFoundation\Request;
|
|
use Trinity\Bundle\ContentManagerBundle\Controller\PageController;
|
|
|
|
/**
|
|
* @author `!v g:snips_author`
|
|
*/
|
|
class `!p snip.rv = snip.basename` extends PageController
|
|
{
|
|
/**
|
|
* @param Request $request
|
|
*
|
|
* @return \Symfony\Bundle\FrameworkBundle\Controller\Response
|
|
*/
|
|
public function indexAction(Request $request)
|
|
{
|
|
if ($response = $this->handleNodeSecurity($request)) {
|
|
return $response;
|
|
}
|
|
|
|
return $this->defaultRender();
|
|
}
|
|
}
|
|
endsnippet
|
|
|
|
|
|
snippet form "Create sf2 form"
|
|
<?php
|
|
|
|
`!p snip.rv = os.popen('/home/simon/bin/namespace ' + path).readline().strip()`
|
|
|
|
use Propel\PropelBundle\Form\BaseAbstractType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
|
|
/**
|
|
* @author `!v g:snips_author`
|
|
*/
|
|
class `!p snip.rv = snip.basename` extends BaseAbstractType
|
|
{
|
|
/**
|
|
* @var array
|
|
*/
|
|
protected $options = [
|
|
'name' => '',
|
|
];
|
|
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
}
|
|
}
|
|
endsnippet
|
|
|
|
snippet array "Create array"
|
|
array($1)
|
|
endsnippet
|
|
|
|
snippet foreach "foreach"
|
|
foreach (\$${1}s as \$$1) {
|
|
|
|
}
|
|
endsnippet
|
|
|
|
snippet block "block"
|
|
/**
|
|
* Setter for 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);
|
|
}
|
|
|
|
/**
|
|
* Getter for the block $1
|
|
*
|
|
* @return Block
|
|
*/
|
|
public function getBlock${1/\w+\s*/\u$0/}()
|
|
{
|
|
return $this->getBlock('${1/(\w+)/\l$0/}');
|
|
}
|
|
endsnippet
|
|
|
|
snippet title "Titelize in the Transformation"
|
|
${1:a text}
|
|
${1/\w+\s*/\u$0/g}
|
|
endsnippet
|
|
|
|
snippet ind "inheritdoc comment" b
|
|
/**
|
|
* {@inheritdoc}
|
|
*/
|
|
endsnippet
|