Last active
November 16, 2017 13:07
-
-
Save spelcaster/67665a740ac1f38d9eb2f98ad8966f52 to your computer and use it in GitHub Desktop.
Vim Snippets for Symfony (PHP)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snippet docc "Symfony Entity attribute with doctrine annotation" | |
/** | |
* @ORM\Column(type="${2:string}"${3:, length=${4:25}}${5:, unique=${6:true}}${7:, nullable=${8:false}}) | |
* | |
* @var ${9:$2} | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet doc11 "Symfony Entity attribute with Doctrine association mapping 1-1" | |
/** | |
* @ORM\OneToOne(targetEntity="${1/\w+/\u$0/}") | |
* @ORM\JoinColumn(name="${2:$1_id}", referencedColumnName="${3:id}") | |
* | |
* @var ${1/\w+/\u$0/} | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet docn1u "Symfony Entity attribute with Doctrine association mapping N-1 Unidirectional" | |
/** | |
* @ORM\ManyToOne(targetEntity="${1/\w+/\u$0/}") | |
* @ORM\JoinColumn(name="${2:$1_id}", referencedColumnName="${3:id}") | |
* | |
* @var ${1/\w+/\u$0/} | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet docnnu "Symfony Entity attribute with Doctrine association mapping N-N Unidirectional" | |
/** | |
* @ORM\ManyToMany(targetEntity="${1/\w+/\u$0/}") | |
* @ORM\JoinTable(name="${2:associative_table}" | |
* joinColumns={@ORM\JoinColumn(name="${3:ours_id}", referencedColumnName="${4:id}")} | |
* inverseJoinColumns={@ORM\JoinColumn(name="${5:$1_id}", referencedColumnName="${6:id}")} | |
* ) | |
* | |
* @var ${1/\w+/\u$0/} | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet docmnn "Symfony Entity attribute with Doctrine association mapping N-N Bidirectional Owned Side" | |
/** | |
* @ORM\ManyToMany(targetEntity="${2:${1/\w+/\u$0/}}", mappedBy="${3:${1/\w+/\u$0/}::targetAttr}"${4:, cascade={${5:"all"}}}) | |
* | |
* @var Doctrine\Common\Collections\ArrayCollection | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet docinn "Symfony Entity attribute with Doctrine association mapping N-N Bidirectional Owner Side" | |
/** | |
* @ORM\ManyToMany(targetEntity="${2:${1/\w+/\u$0/}}", inversedBy="${3:${1/\w+/\u$0/}::targetAttr}") | |
* @ORM\JoinTable(name="${4:associative_table}") | |
* | |
* @var Doctrine\Common\Collections\ArrayCollection | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet doc1n "Symfony Entity attribute with Doctrine association mapping 1-N Bidirectional Owned Side" | |
/** | |
* @ORM\OneToMany(targetEntity="${1/\w+/\u$0/}", mappedBy="${2:${1/\w+/\u$0/}::targetAttr}"${3:, cascade={${4:"all"}}}) | |
* | |
* @var Doctrine\Common\Collections\ArrayCollection | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet docn1 "Symfony Entity attribute with Doctrine association mapping N-1 Bidirectional Owner Side" | |
/** | |
* @ORM\ManyToOne(targetEntity="${1/\w+/\u$0/}", inversedBy="${2:${1/\w+/\u$0/}::targetAttr}") | |
* @ORM\JoinColumn(name="${3:$1_id}", referencedColumnName="${4:id}") | |
* | |
* @var ${1/\w+/\u$0/} | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet docm11 "Symfony Entity attribute with Doctrine association mapping 1-1 Bidirectional Owned Side" | |
/** | |
* @ORM\OneToOne(targetEntity="${1/\w+/\u$0/}", mappedBy="${2:${1/\w+/\u$0/}::targetAttr}"${3:, cascade={${4:"all"}}}) | |
* | |
* @var ${1/\w+/\u$0/} | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet doci11 "Symfony Entity attribute with Doctrine association mapping 1-1 Bidirectional Owner Side" | |
/** | |
* @ORM\OneToOne(targetEntity="${1/\w+/\u$0/}", inversedBy="${2:${1/\w+/\u$0/}::targetAttr}") | |
* @ORM\JoinColumn(name="${3:$1_id}", referencedColumnName="${4:id}") | |
* | |
* @var ${1/\w+/\u$0/} | |
*/ | |
protected $${1:attr}; | |
endsnippet | |
snippet sfixture "Symfony Fixture" | |
<?php | |
namespace ${2:AppBundle}\DataFixtures\ORM; | |
use $2\Entity\\$1; | |
use Doctrine\Bundle\FixturesBundle\Fixture; | |
use Doctrine\Common\Persistence\ObjectManager; | |
/** | |
* Class $1Fixtures | |
*/ | |
class ${1:Entity}Fixtures extends Fixture | |
{ | |
public function load(ObjectManager $manager) | |
{ | |
${3} | |
} | |
/** | |
public function getDependencies() | |
{ | |
return []; | |
} | |
*/ | |
} | |
endsnippet | |
snippet sentity "Symfony Entity" | |
<?php | |
namespace ${2:AppBundle}\Entity; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* @ORM\Table(name="${3:${1/\w+/\L$0\E/}}") | |
* @ORM\Entity(repositoryClass="$2\Repository\\$1Repository") | |
* | |
* $1 | |
*/ | |
class ${1:Entity} implements \Serializable | |
{ | |
/** | |
* @ORM\Id | |
* @ORM\Column(type="integer") | |
* @ORM\GeneratedValue(strategy="AUTO") | |
* | |
* @var integer | |
*/ | |
protected $id; | |
/** | |
* $1 ctor | |
*/ | |
public function __contruct() | |
{ | |
} | |
/** | |
* Get id | |
* | |
* @return integer | |
*/ | |
public function getId() | |
{ | |
return $this->id; | |
} | |
/** | |
* @see \Serializable::serialize() | |
*/ | |
public function serialize() | |
{ | |
return serialize( | |
[ | |
$this->id | |
] | |
); | |
} | |
/** | |
* @see \Serializable::unserialize() | |
*/ | |
public function unserialize($serialized) | |
{ | |
list( | |
$this->id | |
) = unserialize($serialized); | |
} | |
} | |
endsnippet | |
snippet srepository "Symfony Repository" | |
<?php | |
namespace ${2:AppBundle}\Repository; | |
/** | |
* $1Repository | |
* | |
* This class was generated by the Doctrine ORM. Add your own custom | |
* repository methods below. | |
*/ | |
class ${1:Entity}Repository extends \Doctrine\ORM\EntityRepository | |
{ | |
} | |
endsnippet |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment