nstcactus / craft-utils
A collection of utility classes to make my life easier when working on Craft CMS projects
Installs: 1 464
Dependents: 2
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- craftcms/cms: ^3.5.0 || ^4.0.0 || ^5.0.0-beta.1
README
This is a collection a Craft utilities to ease custom development on Craft CMS.
AbstractModule
This base class for custom modules aims at making less painful to create a Craft module. Most of the time, all you have to do to register/customize the following components is to override the corresponding getter:
- translation category (reasonable default value provided)
- CP template roots (reasonable default value provided)
- site template roots (reasonable default value provided)
- twig extensions
- CP nav items
- CP routes
- site routes
- User permissions
- Craft variables additions
- element types
- view hooks
⚠️ There may be some performance implications as the getters are executed on each request. Do as little as possible in the getters, and return early if possible.
If you need to further optimize your code, it's easy to get rid of this module and register the components the traditional way.
MailerComponentConfiguratorModule
This simple module lets you configure the Craft mailer component using environment variables.
Set the mailer transport adapter using the NST_MAILER_TRANSPORT_TYPE
environment variable.
Supported values: smtp
, mailchimp
(mandrill
is also accepted, but it is deprecated) or mailjet
.
Depending on the adapter you choose, different environments variables are needed to configure the adapter.
Common to all adapters
NST_MAILER_FROM_NAME
: required — the name used in theFrom:
header of outgoing emailsNST_MAILER_FROM_EMAIL
: required — the email used in theFrom:
header of outgoing emails
SMTP
NST_MAILER_SMTP_HOST
: required — the SMTP server hostnameNST_MAILER_SMTP_PORT
: required — the SMTP server port numberNST_MAILER_SMTP_USE_AUTHENTICATION
: boolean — whether the SMTP server requires authenticationNST_MAILER_SMTP_USERNAME
: required ifNST_MAILER_SMTP_USE_AUTHENTICATION
— the SMTP usernameNST_MAILER_SMTP_PASSWORD
: required ifNST_MAILER_SMTP_USE_AUTHENTICATION
— the SMTP passwordNST_MAILER_SMTP_ENCRYPTION
: the SMTP encryption method. Eithertls
orssl
Mailchimp
In order to use this adapter, the mailchimp-transactional
plugin must be installed.
See the documentation of the mailchimp-transactional
plugin for details on the settings
mapped to these environment variables.
NST_MAILER_MAILCHIMP_API_KEY
: required — the value of themailchimp-transactional
pluginapiKey
settingNST_MAILER_MAILCHIMP_SUBACCOUNT
: the value of themailchimp-transactional
pluginsubaccount
settingNST_MAILER_MAILCHIMP_TEMPLATE
: the value of themailchimp-transactional
plugintemplate
setting
Mailjet
In order to use this adapter, the mailjet
plugin must be installed.
See the documentation of the mailjet
plugin for details on the settings
mapped to these environment variables.
NST_MAILER_MAILJET_API_KEY
: required — the value of themailjet
pluginapiKey
settingNST_MAILER_MAILJET_API_SECRET
: required — the value of themailjet
pluginapiSecret
setting