Instantly share code, notes, and snippets.

Embed
What would you like to do?
PHPStorm Live-Templates for Magento 2 setter/getter methods
<templateSet group="EcomCoders">
<template name="m2setget" value="/**&#10;* Getter for $FIELD_UNDERSCORES$&#10;* &#10;* @return $TYPEHINT$|null&#10;*/&#10;public function get$FIELD_CAMELCASE_CAPITALIZED$()&#10;{&#10; return $this-&gt;_getData('$FIELD_UNDERSCORES$');&#10;}&#10;&#10;/**&#10;* Setter for $FIELD_UNDERSCORES$&#10;*&#10;* @param $TYPEHINT$ $$$FIELD_CAMELCASE$&#10;* @return $this&#10;*/&#10;public function set$FIELD_CAMELCASE_CAPITALIZED$($$$FIELD_CAMELCASE$)&#10;{&#10; return $this-&gt;setData('$FIELD_UNDERSCORES$', $$$FIELD_CAMELCASE$);&#10;}$END$" description="Magento2-Setter/Getter-Method" toReformat="true" toShortenFQNames="true">
<variable name="FIELD_UNDERSCORES" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="FIELD_CAMELCASE" expression="camelCase(FIELD_UNDERSCORES)" defaultValue="" alwaysStopAt="false" />
<variable name="FIELD_CAMELCASE_CAPITALIZED" expression="capitalize(camelCase(FIELD_UNDERSCORES))" defaultValue="" alwaysStopAt="false" />
<variable name="TYPEHINT" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="PHP Class Member" value="true" />
</context>
</template>
</templateSet>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment