DrupalX

Extension
Framework

API guidelines

There are 3 very basic principles that run through the whole DrupalX API. These principles decide how classes and methods are named, what arguments methods can get and much more. We'd like to quickly mention them here, so you'll understand better what you are dealing with and why things are the way they are. So, here we go:

Simplicity

Do not over-complicate things. Make them intuitively to guess and easy to remember. Call the class for menu items just that "MenuItem" - not "MenuLinkContent". Use class names, method names etc. that mostly consist of one or two words. Give methods only one or two arguments that flexibly accept lots of different input (Arrays, single objects etc.) instead of creating methods with 5 or more arguments where you never seem to get the order right or many different methods with slightly varying names that you all need to memorize.

Brevity

This naturally comes along with simplicity: Keep. Things. Short. Yes, we know, there is autocomplete. But still: It takes you out of your typing flow - every single time. You have to interrupt and watch the screen - hoping the correct completion comes up. If not, type another few letters. Wait again. Why not use short names, short namespaces, short everything in the first place? Just type less. You're already tired of typing "{%" in twig for the 100th time for each and every single Twig statement in a template? DrupalX is not only the solution to this mess - but much more. Access fields just by their name - without the redundant "field_" prefix you'll find usually scattered all over the place. If the keys needed to type "f", "i", "e", "l" and "d" already start to wear off on your keyboard - DrupalX comes to the rescue. And: DrupalX uses a single short namespace instead of monstrous namespaces nested a hundered times deep. The list goes on and on. Less is more!

Consistency

Great care has been taken, to make DrupalX as consistent as possible. Similar methods in different objects should have the same name. The same API methods available in PHP should just as easily be callable from Twig under the same name, methods are always in camel-case, and so on. We don't like surprises! Well - not during Website development at least...