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 #7 | UC Wishlist

With the last week of the second phase of the Google Summer of Code 2017 underway, the seventh week has come to a close. The previous week saw the completion of the third port for the second regime, i.e., porting ‘View/Update wishlist’ . The earlier week I had summarised the implementation for the third port, i.e, porting ‘View/Update wishlist’ functionality. So, the work done the previous week for the implementation of the mentioned third port can be summarised below: The first thing I did was to define an interface my UcWishlist entity type class can implement and that extends the default ContentEntityInterface alongwith EntityOwnerInterface . So inside of the module's src/Entity folder, create a file called UcWishlistInterface.php . Next,  I focused on the crux of defining my own Content Entity class and created a folder inside the src/ directory called Entity , and within it, a file called UcWishlist.php . What we have here is a...

GSoC’17 Coding period | Week #1 | Drupal

The Coding phase of Google Summer of Code 2017 kicked off the previous week on May 30th, 16:00 UTC, marking the conclusion of the one-month long Community Bonding period. As stated earlier in my previous post , the Community Bonding term proffered the selected students an opportunity to build a rapport with their community, helping them in interacting with the respective mentors and fellow developers. Presently, I am working on porting the UC Wish list module to Drupal 8, under the guidance of Naveen Valecha , which would specifically allow customers to create and administer personalized wish lists of products in their Ubercart store, thereby enabling potential customers to get a better understanding by referring to those wishlists. During the community bonding phase, I had been asked to create a Plan issue for tracking the status of the port and sub-issues of the project goals, by my mentor. As per the implementation, for the first phase/month of the coding pe...