I’m completely new to Drupal module development and am struggling to understand the basic code in Drupal. I followed tutorials on how to create a module and was successful in building a couple simple ones that just creates a page with some hardcoded data. Now my struggles is when reading other modules that were contributed.
Take for example the code below I got from an entity php in the contributed Commerce module:
public function getFieldMap($ variation_type_id = NULL); public function clearCaches(); /** * Creates an attribute field for the given attribute. * * @param \Drupal\commerce_product\Entity\ProductAttributeInterface $ attribute * The product attribute. * @param string $ variation_type_id * The product variation type ID. */ public function createField(ProductAttributeInterface $ attribute, $ variation_type_id); public function canDeleteField(ProductAttributeInterface $ attribute, $ variation_type_id);
I just picked a couple functions. I see these functions above getting declared, but I don’t see anywhere any of the functions are called. My understanding of Object Oriented Programming is you create a Class, and within that Class you can have Methods and Properties. But when you declare Methods or Properties, shouldn’t these properties be called to be used or utilized? Does Drupal call these declared functions by default so any function you create in your controller, php files, entity files get called by Drupal?
I also see some php files in Drupal where there’s just a bunch of “Protected $ Variable”, which I don’t get why it’s being declared in one file, but not sure where it’s being called.
Is Drupal code different and has a certain way of working? Please no criticism on how stupid my question can be. I’m not asking for a lecture, but just for a brief explanation. I sincerely appreciate any answers you can provide. I just need to get a basic understanding of how codes in a module work exactly. I’ve been to many tutorials and read a lot on Drupal.org, but haven’t really come across a resource I could understand.
Thank you for your time.
✓ Extra quality
ExtraProxies brings the best proxy quality for you with our private and reliable proxies
✓ Extra anonymity
Top level of anonymity and 100% safe proxies – this is what you get with every proxy package
✓ Extra speed
1,ooo mb/s proxy servers speed – we are way better than others – just enjoy our proxies!
USA proxy location
We offer premium quality USA private proxies – the most essential proxies you can ever want from USA
Our proxies have TOP level of anonymity + Elite quality, so you are always safe and secure with your proxies
Use your proxies as much as you want – we have no limits for data transfer and bandwidth, unlimited usage!
Superb fast proxy servers with 1,000 mb/s speed – sit back and enjoy your lightning fast private proxies!
99,9% servers uptime
Alive and working proxies all the time – we are taking care of our servers so you can use them without any problems
No usage restrictions
You have freedom to use your proxies with every software, browser or website you want without restrictions
Perfect for SEO
We are 100% friendly with all SEO tasks as well as internet marketing – feel the power with our proxies
Buy more proxies and get better price – we offer various proxy packages with great deals and discounts
We are working 24/7 to bring the best proxy experience for you – we are glad to help and assist you!