Problem/Motivation

The method names generated by ThemeSuggestions::getAlterMethods() are created prepending 'alter' to each suggestion, after making the first letter of each suggestion uppercase. This produces method names like this:

  • alterInput
  • alterSelect
  • alterUser

which are fine. However, it also produces method names like this:

  • alterStatus_messages
  • alterForm_element
  • alterForm_element_label

which technically will work, but violate coding standards for following lowerCamelCase naming for methods. Instead, they should be like this:

  • alterStatusMessages
  • alterFormElement
  • alterFormElementLabel

Proposed resolution

Change ThemeSuggestions::getAlterMethods() so that all method names are fully lowerCamelCase, with no underscores.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexdmccabe created an issue. See original summary.

alexdmccabe’s picture

Title: Use camel case when generating ThemeSuggestions method names » Use lowerCamelCase when generating ThemeSuggestions method names
alexdmccabe’s picture

alexdmccabe’s picture

Issue summary: View changes

Status: Needs review » Needs work
alexdmccabe’s picture

Status: Needs work » Needs review

I don't think themes can be tested yet, so setting this back to Needs Review.

markhalliwell’s picture

Title: Use lowerCamelCase when generating ThemeSuggestions method names » Dynamic alter methods do not convert to proper lowerCamelCase
Category: Feature request » Bug report
Priority: Minor » Normal
Status: Needs review » Reviewed & tested by the community
FileSize
2.09 KB

Ah, good catch. This needs a bit of work though to support backwards compatibility with sub-themes that may have already used the malformed method name. This is a complete rework of the above patch, so no interdiff is necessary.

edit: also, themes can now be tested... this project just hasn't really set all that up just yet.

  • markcarver committed 1ae2836 on 8.x-3.x
    Issue #3008004 by alexdmccabe, markcarver: Dynamic alter methods do not...
markhalliwell’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.