├── README.md └── live-templates.jar /README.md: -------------------------------------------------------------------------------- 1 | # Magento 2 Live Templates for PHP Storm 2 | 3 | For more information see [my site](http://www.brideo.co.uk/magento2/Magento-2-PHP-Storm-Live-Templates/) 4 | 5 | To make my life easier during the transition to Magento 2 I have created a bunch of live templates. 6 | 7 | These are very basic and I will be expanding on these, also it would be nice if the community include their live templates in this repo. 8 | 9 | ## Magento 2 Controller 10 | 11 | Shortcode: `mcontroller` 12 | 13 | resultPageFactory = $resultPageFactory; 46 | $this->context = $context; 47 | } 48 | 49 | /** 50 | * Load the page defined in view/frontend/layout/samplenewpage_index_index.xml 51 | * 52 | * @return \Magento\Framework\View\Result\\Magento\Framework\View\Result\Page 53 | */ 54 | public function execute() 55 | { 56 | return $this->resultPageFactory->create(); 57 | } 58 | } 59 | 60 | 61 | ## Magento 2 Block 62 | 63 | Shortcode: `mblock` 64 | 65 | 94 | 95 | 96 | 97 | 98 | ## Magento 2 Basic layout.xml 99 | 100 | Shortcode: `mlayout` 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | ## Magento 2 `module.xml` 112 | 113 | Shortcode: `mmodule` 114 | 115 | 116 | 117 | 118 | 119 | 120 | ## Magento 2 `routes.xml` 121 | 122 | Shortcode `mroutes` 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | ## Magento 2 `system.xml` 134 | 135 | Shortcode `msystem` 136 | 137 | 138 | 139 | 140 |
141 | 142 | $TAB$ 143 | $RESOURCE$ 144 | 145 | 146 | 147 | 148 | $SOURCE_MODEL$ 149 | 150 | 151 |
152 |
153 |
154 | 155 | ## Magento 2 `acl.xml` 156 | 157 | Shortcode `macl` 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | ## Magento 2 menu.xml 173 | 174 | Shortcode `mmenu` 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | ## Magento 2 Block Grid Container 184 | 185 | Shortcode `mgrid` 186 | 187 | _controller = 'adminhtml_$CONTROLLER$'; 198 | $this->_blockGroup = '$COMPANY$_$MODULE$'; 199 | $this->_headerText = __('$TITLE$'); 200 | parent::_construct(); 201 | } 202 | 203 | } 204 | 205 | ## Magento 2 Unit Test 206 | 207 | Shortcode `mtest` 208 | 209 | resultPageFactory = $resultPageFactory; 253 | } 254 | 255 | /** 256 | * Index action 257 | * 258 | * @return \Magento\Framework\View\Result\Page 259 | */ 260 | public function execute() 261 | { 262 | /** @var \Magento\Framework\View\Result\Page $resultPage */ 263 | $resultPage = $this->resultPageFactory->create(); 264 | $resultPage->setActiveMenu(static::ADMIN_RESOURCE); 265 | $resultPage->addBreadcrumb(__(static::PAGE_TITLE), __(static::PAGE_TITLE)); 266 | $resultPage->getConfig()->getTitle()->prepend(__(static::PAGE_TITLE)); 267 | 268 | return $resultPage; 269 | } 270 | 271 | /** 272 | * Is the user allowed to view the blog post grid. 273 | * 274 | * @return bool 275 | */ 276 | protected function _isAllowed() 277 | { 278 | return $this->_authorization->isAllowed(static::ADMIN_RESOURCE); 279 | } 280 | 281 | } 282 | 283 | ## Magento 2 jQuery Plugin Template 284 | 285 | Shortcode `mjquery` 286 | 287 | 288 | ;require(['jquery'], function ($) { 289 | 290 | /** 291 | * Declare a namespace if it doesn't already 292 | * exist. 293 | */ 294 | if (!$.$COMPANY$) { 295 | $.$COMPANY$ = {}; 296 | } 297 | 298 | /** 299 | * Colour switching plugin declaration. 300 | * 301 | * @param element 302 | * @param options 303 | * @constructor 304 | */ 305 | $.$COMPANY$.$MODULE$ = function (element, options) { 306 | 307 | /** 308 | * This variable is used because it's 309 | * easier than binding `this` 310 | * 311 | * @type {$.$COMPANY$.$MODULE$} 312 | */ 313 | var base = this; 314 | 315 | /** 316 | * Accessor to the element we are manipulating. 317 | * 318 | * @type {*|jQuery|HTMLElement} 319 | */ 320 | base.$element = $(element); 321 | base.element = element; 322 | 323 | /** 324 | * Add a reverse reference to the plugin. 325 | */ 326 | base.$element.data("$COMPANY$.$MODULE$", base); 327 | 328 | /** 329 | * Plugin constructor 330 | */ 331 | base.init = function () { 332 | base.options = $.extend({}, $.$COMPANY$.$MODULE$.defaultOptions, options); 333 | 334 | }; 335 | 336 | /** 337 | * Initialize the plugin. 338 | */ 339 | base.init(); 340 | }; 341 | 342 | /** 343 | * Default options for the plugin. 344 | * 345 | * @type 346 | */ 347 | $.$COMPANY$.$MODULE$.defaultOptions = {}; 348 | 349 | /** 350 | * Setup the plugin, this will override the default 351 | * options with the object passed in instantiation. 352 | * 353 | * @constructor 354 | * 355 | * @param options 356 | */ 357 | $.fn.$COMPANY$_$MODULE$ = function 358 | (options) { 359 | return this.each(function () { 360 | (new $.$COMPANY$.$MODULE$(this, options)); 361 | }); 362 | }; 363 | 364 | }); 365 | 366 | ## Magento 2 Model 367 | 368 | Shortcode `mmodel` 369 | 370 | _init('$NAMESPACE$\Model\ResourceModel\$CLASS$'); 399 | } 400 | 401 | } 402 | 403 | 404 | ## Magento 2 Resource Model 405 | 406 | Shortcode `mresourcemodel` 407 | 408 | _init('$TABLE_NAME$', '$POST_ID$'); 433 | } 434 | 435 | } 436 | 437 | ## Magento 2 Resource Collection 438 | 439 | Shortcode `mcollection` 440 | 441 | _init('$NAMESPACE$\Model\$RESOURCE$', '$NAMESPACE$\Model\ResourceModel\$RESOURCE$'); 467 | 468 | return $this; 469 | } 470 | 471 | } 472 | 473 | ## Magento 2 Database Schema Install 474 | 475 | Shortcode `mschema` 476 | 477 | startSetup(); 501 | 502 | 503 | $installer->endSetup(); 504 | 505 | return $this; 506 | } 507 | 508 | } 509 | -------------------------------------------------------------------------------- /live-templates.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/brideo/phpstorm-live-templates-magento-2/a1073b6f07062ec801d73381410c62b8f9d30d56/live-templates.jar --------------------------------------------------------------------------------