Last active
February 15, 2019 06:39
-
-
Save simpleadm/0707a0997b478fecd728ba67200f7bd1 to your computer and use it in GitHub Desktop.
PhpStorm File and code templates for Magento 2
This file contains hidden or 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
<?php | |
#parse("PHP File Header.php") | |
#set($current = "") | |
#set($MODULE_NAMESPACE = "") | |
#foreach($current in $MODULE_NAME.split("_")) | |
#set($MODULE_NAMESPACE = $MODULE_NAMESPACE + "\" + $current) | |
#end | |
namespace $MODULE_NAMESPACE.substring(1)\Api\Data; | |
/** | |
* ${NAME} data interface. | |
* @api | |
*/ | |
interface ${NAME} | |
{ | |
/**#@+ | |
* Constants for keys of data array. Identical to the name of the getter in snake case | |
*/ | |
#foreach($current in $PROPERTIES.split(",")) | |
#set($current = $current.trim()) | |
const $current.toUpperCase() = '$current'; | |
#end | |
/**#@-*/ | |
#foreach($current in $PROPERTIES.split(",")) | |
#set($current = $current.trim()) | |
#set($method = $current.substring(0,1).toUpperCase() + $current.substring(1)) | |
/** | |
* Get $current | |
* | |
* @return #TYPE | |
*/ | |
public function get$method(); | |
/** | |
* Set $current | |
* | |
* @param #TYPE ${DS}$current | |
* @return ${DS}this | |
*/ | |
public function set$method(${DS}$current); | |
#end | |
} |
This file contains hidden or 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
<?php | |
#parse("PHP File Header.php") | |
#set($current = "") | |
#set($MODULE_NAMESPACE = "") | |
#foreach($current in $MODULE_NAME.split("_")) | |
#set($MODULE_NAMESPACE = $MODULE_NAMESPACE + '\' + $current) | |
#end | |
namespace $MODULE_NAMESPACE.substring(1)\Model; | |
use Magento\Framework\Model\AbstractModel; | |
/** | |
* ${NAME} model | |
*/ | |
class ${NAME} extends AbstractModel implements ${MODULE_NAMESPACE}\Api\Data\\${NAME}Interface | |
{ | |
#foreach($current in $PROPERTIES.split(",")) | |
#set($current = $current.trim()) | |
#set($method = $current.substring(0,1).toUpperCase() + $current.substring(1)) | |
/** | |
* {@inheritdoc} | |
*/ | |
public function get$method() | |
{ | |
return ${DS}this->getData(self::$current.toUpperCase()); | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function set$method(${DS}$current) | |
{ | |
${DS}this->setData(self::$current.toUpperCase(), ${DS}$current); | |
return ${DS}this; | |
} | |
#end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Docs: https://www.jetbrains.com/help/phpstorm/using-file-and-code-templates.html
How create new file template:
How use it:
Result:
https://prnt.sc/mlc4xm