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 | 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...

GSoC’17 Coding period | Week #8 | UC Wishlist

The eighth week of Google Summer of Code 2017 has come to a close, bringing forth the onset of the Second Evaluation Period. Presently, I've been working on porting the 'Uc Wishlist' module to Drupal 8, under the guidance of my mentor, Naveen Valecha . The conceptualization and understanding developed during the first phase of coding have been of immense help and has provided notable assistance for the completion of the assigned ports. This month, concerning this week in particular saw the completion of a significant amount of work concerning the ports assigned for the Second phase of the coding regime. The work done this week can be briefly described as follows: Fixed the 'Add to wishlist/Remove from wishlist' submit handler for the second port. Previously, on clicking on the add to wishlist button, the screen showed an error page, and the product couldn't get registered. However, the error has been fixed and products can now be adde...

GSoC’17 Coding period | Week #3 | Drupal

With the conclusion of the third week of Google Summer of Code 2017, the initial phase of the coding period is coming to a closure. The conceptualization developed during the previous weeks have been of immense help, and has been of notable assistance for the completion of the ports for the first phase. The previous week, as I had stated in my earlier blogpost , I had to port the following sub-modules regarding the UC Wish list framework: As I had mentioned in the previous blogpost , till week 2 I had almost completed the first port by configuring the administrator wish list settings and completing a substantial portion of managing user wish lists. With the conclusion of week 3, I have completed the port of the administrator wish list settings. Moreover, I have also included the ‘Add to wish list’ feature as part of the second port. Thereby I would briefly like to state the steps taken to port the above functionalities: Manage user wish lists: Implemen...