Last active
March 6, 2019 23:20
-
-
Save jamesmoey/0552c5c811ffd387149f18e8699ee455 to your computer and use it in GitHub Desktop.
Setter & Getter, Adder & Remover live template for Doctrine Collection. Use in IntellJ
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
<templateSet group="Custom"> | |
<template name="sgcollection" value="/** * @return $CLASS$ */ public function get$CLASS$(): $CLASS$ { return $this->$VAR$; } /** * @param $CLASS$ $$$VAR$ * @return $this */ public function set$CLASS$($CLASS$ $$$VAR$) { if ($$$VAR$ !== $this->$VAR$) { if ($this->$VAR$ !== null) { $this->$VAR$->remove$RELATECLASS$($this); } $this->$VAR$ = $$$VAR$; if ($this->$VAR$ !== null) { $this->$VAR$->add$RELATECLASS$($this); } } return $this; }" description="Generate Setter & Getter for Relationship" toReformat="true" toShortenFQNames="true"> | |
<variable name="CLASS" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" /> | |
<variable name="VAR" expression="phpVar" defaultValue="" alwaysStopAt="true" /> | |
<variable name="RELATECLASS" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="arcollection" value="/** * @param $CLASS$ $item * @return $this */ public function add$CLASS$($CLASS$ $item) { if (!$this->$VAR$->contains($item)) { $this->$VAR$->add($item); $item->set$METHOD$($this); } return $this; } /** * @param $CLASS$ $item * @return $this */ public function remove$CLASS$($CLASS$ $item) { if ($this->$VAR$->contains($item)) { $this->$VAR$->removeElement($item); $item->set$METHOD$(null); } return $this; }" description="Generate Adder & Remover Collection" toReformat="true" toShortenFQNames="true"> | |
<variable name="CLASS" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" /> | |
<variable name="VAR" expression="phpVar" defaultValue="" alwaysStopAt="true" /> | |
<variable name="METHOD" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
<template name="one2one" value="/** * @return $CLASS$ */ public function get$CLASS$(): $CLASS$ { return $this->$VAR$; } /** * @param $CLASS$ $$$VAR$ * @return $this */ public function set$CLASS$($CLASS$ $$$VAR$) { if ($$$VAR$ !== $this->$VAR$) { $prev = $this->$VAR$; $this->$VAR$ = $$$VAR$; if ($prev !== null) { $prev->set$RELATECLASS$(null); } if ($this->$VAR$ !== null) { $this->$VAR$->set$RELATECLASS$($this); } } return $this; }" description="Generate Setter & Getter for One To One Relationship" toReformat="true" toShortenFQNames="true"> | |
<variable name="CLASS" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" /> | |
<variable name="VAR" expression="phpVar" defaultValue="" alwaysStopAt="true" /> | |
<variable name="RELATECLASS" expression="classNameComplete()" defaultValue="" alwaysStopAt="true" /> | |
<context> | |
<option name="PHP" value="true" /> | |
</context> | |
</template> | |
</templateSet> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment