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 #11 | Uc wishlist

  Another week has reached its aftermath and the third phase of the coding regime is about to conclude with the onset of the Final Evaluations for Google Summer of Code 2017. The time spent so far during the previous months have been a great learning experience with Drupal, with the timely help provided for the project by my mentor Naveen Valecha . Coming to the present scenario, the majority of the port concerning the Uc Wishlist has been completed, save for some technical fixes and implementation requirements regarding the port of the final sub-module ‘Add user wish list settings’. Other than that, I would put up the alpha release of the module as soon as the current code gets reviewed. Additionally, I would propose few functional tests as per instructions from the mentor and reviews from the developers. Moreover, my code for the previous ports have been committed to the Drupal Core by my mentor and the current status of the code could be found here . S

GSoC'17 | Drupal

This year I had the utmost opportunity of getting selected for the prestigious Google Summer of Code 2017, as a part of Drupal, the open source organisation to which I contribute. Drupal, is a free and open source content-management framework written in PHP and distributed under the GNU General Public License, provides a back-end framework for at least 2.2% of all Web sites worldwide – ranging from personal blogs to corporate, political, and government sites. Systems also use Drupal for knowledge management and for business collaboration. The Google Summer of Code, often abbreviated to GSoC, is an international annual program, first held from May to August 2005, in which Google awards stipends, which depends on place of university of the student, to all students who successfully complete a requested free and open-source software coding project during the summer. The program is open to university students aged 18 or over. Students contact the mentor organization