User login

Drupal 8

Argument 2 passed to hook help() must be an instance of RouteMatchInterface

I got this error message, that argument two passed to my module's implementation of hook_help() "must be an instance of RouteMatchInterface, instance of Drupal\Core\Routing\CurrentRouteMatch given", and it's a misleading one.

CurrentRouteMatch in fact (unsurprisingly) implements the RouteMatchInterface. The problem was i hadn't actually defined CurrentRouteMatch— i needed to have a use statement at the top of my module (or use the full PSR4 path in the parameter definition of the hook implementation, but i went with the former). Like so:

How to get the base path for your Drupal 8 site in a Twig template

In page.html.twig you will have a working {{ base_path }} variable. Why it isn't available in every template, i have no idea. As i think it should be and everything else looks messy, my preferred solution is to do exactly as Drupal does in the preprocess page function for any place i need it.

Embedding a content add form in a block in Drupal 8

The Form block module, mentioned in the forum post how to embed node add form in a block?, is still going strong in Drupal 8.

Drupal 8 default content the Agaric way

For the moment, we're following the crowd and using the Default content module. It is nice and has built-in integration with installation profiles, but the export could be more convenient (multiple items of content at once, please!) and import could be made much more robust (given half a chance, we'll reimplement it on migrate).

What to do when developing a Drupal 8 module and a class file just isn't being autoloaded even though it is definitely there

Short answer: Restart apache or disable the APC classloader in your local.settings.php (see settings.php).

While working on the Give module, which follows the same pattern for donation forms as Drupal 8 core's Contact module uses for contact forms, an access control handler was not being found even though i quadruple checked that my handler annotation described the handler correctly for the name and location of its file.

The ConfigEntityType annotation for the access handler, with most other annotations removed:

Is Git corrupting your font files?

I was getting errors like this in the console:

downloadable font: incorrect file size in WOFF header (font-family: "Graphik" style:normal weight:bold stretch:normal src index:1) source: ... themes/butaro/fonts/Graphik-Bold-Web.woff
downloadable font: rejected by sanitizer (font-family: "Graphik" style:normal weight:bold stretch:normal src index:1) source: ... themes/butaro/fonts/Graphik-Bold-Web.woff

Git would have given you warnings that look like this when you git added the fonts:

Setting text format per field in Drupal 8

UPDATE: There is a contributed Drupal 8 module to set allowed formats that was spun off of the core issue to allow text field to enforce a specific text format.

Right now, there's no good way to do it, but there's good hope that this issue will be fixed in Drupal 8 core. OK but right now? Better Formats isn't stable for Drupal 8 yet. So hacky custom form alters is the best i've come up with.

Allowing regular (short) text fields to use the multiline textarea form widget

There's a module for that now:

It's nice and simple with an alter hook (as detailed on the module page) and in this answer.

Using composer require to get an alpha, beta, or release candidate of a Drupal 8 module

The composer require command can help you get your requirements into composer.json more easily. However, that ease is more theoretical than actual for modules without a full stable release.

The Honeypot module has a full stable release version, so any of these will work:

composer require drupal/honeypot:8.*
composer require drupal/honeypot:8.x
composer require drupal/honeypot:8
composer require drupal/honeypot

Drush update not seeing the patch-level version of Drupal 8?

Does it appear that Drush update is not fetching the newest minor version update of Drupal 8? Changelog says 8.0.0 at the top, but you know 8.0.2 has been released, and drush up or drush upc says update information last refreshed that day yet says "No code updates available."?

Syndicate content