Skip to main content

GSoC’17 Coding period | Week #2 | Drupal





Google Summer of Code 2017 has entered yet another week and with the conclusion of week 2 of the Coding Phase, things in general have become much more elaborative, as well as exciting !
The previous week was significantly noteworthy in terms of the intricacies and topics dealt with for the  objectives undertaken for the first phase. I was also able to manage time better to focus more towards my project, and the implementation in particular. In the previous blogpost, I had mentioned about the port objectives decided with regard to the first phase of the coding regime. As planned earlier, my main intent for the week was to port the functionality ‘Add administrator wish list settings’. The port of this sub-module encapsulated the completion of the following objectives:
  • Configuring the wish list settings by administrator: This feature allows the administrator to implement crucial settings related to any wish list for authenticated users. 
  • Managing user wish lists: This feature enables the administrator to keep track of the wish lists created by authenticated users and implement changes if necessary.
Thus, briefly explaining the steps taken to port the administrator wish lists settings under this week’s regime:
  • Creating the Form Controller:

    • The first step is to create the actual form, by creating a file called UcWishlistConfigForm.php and place it as src/form/UcWishlistConfigForm.php.In this php file we define a class called UcWishlistConfigForm that extends ConfigFormBase.
    • We give the form a unique id by creating a getFormId() method and returning a unique form ID as a string.
    • To build the actual form, we add a method called buildForm() and define the form elements (using Form API) in this method.
    • Since the form is incomplete without a submit button, we add a method called submitForm() that will be used to save the form values.
  • Building Route and Menu items:

    • For the form controller we need to make it accessible via a menu in Drupal’s admin section, by defining a route in uc_wishlist.routing.yml and a menu item for the route in uc_wishlist.module files and placing them in the module’s root directory.
  • Defining configuration settings:

    • For storing the actual form values, D8 comes with a Configuration System that stores site configuration directly on the file system using YAML files and not in the database.
    • Created a uc_wishlist.settings.yml file and placed it in a folder called config from within the module root directory. The path to the YAML should end up being config/uc_wishlist.settings.yml.
Administrator wish list settings in Drupal 8 after port:
As stated above, I was able to port the ‘administrator wish list settings’ successfully this week through the above mentioned procedure, and the code associated with the port can be found here. Also, the related bugs associated with the port of he sub-module would be reported/fixed as scheduled. I further plan to complete the port of the first sub-module by integrating the functionality to manage the user wish lists in Drupal 8. Furthermore, I also intend to complete a fair part of the next sub-module by porting 'Add to wish list' and 'Add to cart' system functionalities.
Also I came across few crucial facets regarding the differences in the Configuration Management System in D8, which is listed as follows:
  • The Drupal variables are replaced by the Configuration API. We need to define the properties and default values in the new format.
  • In D7 we define your form arrays in functions and in D8 we create a form class.
  • In D7 the form values are usually stored in the ‘variable’ table and retrieved by using the variable_get('name') API function, but D8 involves storing them in YAML files.
Summing up, these were some of the objectives and concepts learned during the second week of coding phase in GSoC’17. Hope to learn many more new concepts in the coming weeks for successful completion of the port.
Cheers!

Comments

Popular posts from this blog

GSoC’17 Coding period | Week #10 | Uc Wishlist

With the conclusion of the tenth week of Google Summer of Code 2017, the coding regime is almost halfway through the third phase. Meanwhile, last week saw a stringent buildup on the concept for the remaining ports, which would aid in its gradual completion. I have maintained a detailed structure of the code for the port which can be accessed here . Focusing on the present scenario, the implementation of the 5th port ‘Email wishlist to users’ has almost reached completion. Additionally, the implementation of the last port ‘Add user wish list settings’ is underway, with a significant portion of the port to be accomplished within the coming week. Therefore, based on a comprehensive evaluation of the current status of the module, the work done previous week can be summarised as: Option to email wishlist to others: This feature would enable users or wish list owners to share any wish list with other users or potential customers by emailing it to the respe...

GSoC’17 Coding period | Week #4 | Drupal

The fourth week of Google Summer of Code 2017 has come to a close, bringing forth the onset of the First Evaluation Period. The conceptualization developed during the first phase of coding have been of immense help and has provided notable assistance for the completion of the assigned ports. As I had stated in the previous blog posts, this month I had the objective of completing the following ports concerning the first phase of the coding regime: Admin wish list settings Add to wishlist  With the conclusion of week 4, I have completed the port of the administrator wish list settings as well as the ‘ Add to wishlist ’ feature as part of the second port. Also for the ‘ Add to Wishlist ’ functionality to work successfully, my next objective would be to add the functionality to view/access the user wish list, on using the button. This functionality would further be succeeded by the option to update the specific wish list, by displaying the required button ...