├── .gitignore ├── CHANGELOG.md ├── LICENSE.md ├── README.md ├── composer.json └── src ├── AutocompleteTwigExtension.php ├── AutocompleteVariable.php ├── craftcms ├── AutocompleteTwigExtension.php └── AutocompleteVariable.php ├── nystudio107 ├── AutocompleteTwigExtension.php └── AutocompleteVariable.php └── putyourlightson ├── AutocompleteTwigExtension.php └── AutocompleteVariable.php /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Release Notes for Autocomplete 2 | 3 | ## 1.0.1 - 2021-07-23 4 | ### Added 5 | - Added a mixin for a root autocomplete variable. 6 | 7 | ## 1.0.0 - 2021-07-15 8 | - Initial release. 9 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright © PutYourLightsOn 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Stable Version](https://img.shields.io/packagist/v/putyourlightson/craft-autocomplete?label=stable)]((https://packagist.org/packages/putyourlightson/craft-autocomplete)) 2 | [![Total Downloads](https://img.shields.io/packagist/dt/putyourlightson/craft-autocomplete)](https://packagist.org/packages/putyourlightson/craft-autocomplete) 3 | 4 | # Autocomplete for Craft CMS [DEPRECATED] 5 | 6 | ### ⚠️ This package has been replaced by the superior [Craft Autocomplete](https://github.com/nystudio107/craft-autocomplete) as a collaboration between [PutYourLightsOn](https://putyourlightson.com/) and [nystudio107](https://nystudio107.com/). 7 | 8 | Provides autocompletion for Craft CMS and plugins in Twig templates. 9 | 10 | Currently works with **PhpStorm only**, as VSCode does not support intellisense for Twig extensions. 11 | 12 | Adapted from `FauxTwigExtension.php` by nystudio107 as documented in the article: 13 | https://nystudio107.com/blog/auto-complete-craft-cms-3-apis-in-twig-with-phpstorm 14 | 15 | ![demo](https://user-images.githubusercontent.com/57572400/126911028-7d7d06dd-c60f-42b9-ae42-95d5f078a229.gif) 16 | 17 | ## Usage 18 | 19 | Install the package using composer. 20 | 21 | ``` 22 | composer require putyourlightson/craft-autocomplete 23 | ``` 24 | 25 | Ensure that the Symfony plugin is installed and enabled in PhpStorm: 26 | https://plugins.jetbrains.com/plugin/7219-symfony-plugin 27 | 28 | Once your IDE indexes the files, autocompletion for Craft and supported plugins will immediately become available in your Twig templates. 29 | 30 | ![screenshot](https://user-images.githubusercontent.com/57572400/125784167-618830ae-e475-4faf-81d3-194ad7ce3a08.png) 31 | 32 | ### Adding Custom Variables 33 | 34 | You can add autocompletion for your own custom modules/plugins by creating a file called `AutocompleteVariable.php` and placing it inside any folder that PhpStorm will index (for example in the `/config` directory). 35 | 36 | ```php 37 | new AutocompleteVariable(), 29 | 30 | // Craft Elements 31 | 'asset' => new Asset(), 32 | 'category' => new Category(), 33 | 'entry' => new Entry(), 34 | 'tag' => new Tag(), 35 | 'section' => new Section(), 36 | 37 | // Craft "Constants" 38 | 'SORT_ASC' => 4, 39 | 'SORT_DESC' => 3, 40 | 'SORT_REGULAR' => 0, 41 | 'SORT_NUMERIC' => 1, 42 | 'SORT_STRING' => 2, 43 | 'SORT_LOCALE_STRING' => 5, 44 | 'SORT_NATURAL' => 6, 45 | 'SORT_FLAG_CASE' => 8, 46 | 'POS_HEAD' => 1, 47 | 'POS_BEGIN' => 2, 48 | 'POS_END' => 3, 49 | 'POS_READY' => 4, 50 | 'POS_LOAD' => 5, 51 | 52 | // Craft Globals 53 | 'currentUser' => new User(), 54 | 'currentSite' => new Site(), 55 | 'now' => new DateTime(), 56 | ]; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/AutocompleteVariable.php: -------------------------------------------------------------------------------- 1 | new Order(), 24 | 'lineItem' => new LineItem(), 25 | 'order' => new Order(), 26 | 'product' => new Product(), 27 | ]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/craftcms/AutocompleteVariable.php: -------------------------------------------------------------------------------- 1 | new SeomaticVariable(), 22 | ]; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/nystudio107/AutocompleteVariable.php: -------------------------------------------------------------------------------- 1 | new CampaignElement(), 25 | 'contact' => new ContactElement(), 26 | 'mailingList' => new MailingListElement(), 27 | 'segment' => new SegmentElement(), 28 | 'sendout' => new SendoutElement(), 29 | 30 | // Sprig 31 | 'sprig' => new SprigVariable(), 32 | 'pageInfo' => new PaginateVariable(), 33 | ]; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/putyourlightson/AutocompleteVariable.php: -------------------------------------------------------------------------------- 1 |