snippet pf "Create a public function" b public function $1($2) { $5 } endsnippet snippet ppf "Create a protected function" b protected function $1($2) { $5; } endsnippet snippet pvf "Create a private function" b private function $1($2) { $5; } endsnippet snippet php $1 = \$$1; return \$this; } public function get${1/\w+\s*/\u$0/g}(): $2 { return \$this->$1; } endsnippet snippet g "Getter" 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" */ 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" setName('$1') ->setDescription('$2') // ->addArgument('foo', InputArgument::OPTIONAL, '') // ->addOption('bar', null, InputOption::VALUE_NONE, '') ->setHelp("The %command.name% $3"); } /** * {@inheritdoc} */ protected function execute(InputInterface $input, OutputInterface $output) { // $this->getContainer()->get('foo.bar'); // $output->writeln(sprintf('%s bar.', $example)); // $input->getArgument('foo'); // $input->getOption('bar'); $4 } } endsnippet snippet controller "Create trinity controller" handleNodeSecurity($request)) { return $response; } $2 return $this->defaultRender(); } } endsnippet snippet form "Create sf2 form" '$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 get${1/\w+\s*/\u$0/}(); } endsnippet snippet rest_class "JMS class annotation" * @JMS\Serializer\Annotation\ExclusionPolicy("all") endsnippet snippet sec "Securiy attribute" #[Security('is_granted("ROLE_ADMIN") or is_granted("ROLE_DPO")')] endsnippet snippet ig "Securiy attribute" #[IsGranted('$1', 'entity')] endsnippet snippet igs "Securiy attribute" #[IsGranted('show', 'entity')] endsnippet snippet ige "Securiy attribute" #[IsGranted('edit', 'entity')] endsnippet snippet igd "Securiy attribute" #[IsGranted('delete', 'entity')] endsnippet snippet voter "Voter" genericVote($attribute, $entity, $token); if (is_bool($vote)) { return $vote; } if ('show' === $attribute) { return $this->canRead($entity); } if ('edit' === $attribute) { return $this->canWrite($entity); } if ('delete' === $attribute) { return $this->canDelete($entity); } return false; } // protected function canWrite(mixed $entity): bool // { // return $this->isAdmin(); // } // // protected function canDelete(mixed $entity): bool // { // return $this->isAdmin(); // } // // protected function canRead(mixed $entity): bool // { // return $this->isAdmin(); // } } endsnippet