GSoC’17 Coding period | Week #7 | UC-Wishlist

week7

 

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 simple class defining the entity properties required. This class extends the default ContentEntityBase class and implements the UcWishlistinterface. Using annotations, we are basically telling Drupal about our UcWIshlist entity type. The @ContentEntityType tells Drupal that this is a Content Entity type. Within its definition, we have an array-like structure describing the wish list contents.

  • The next thing I did was to create the form we referenced in the annotations above: for adding, editing and deleting wish list entities. The cool thing is that the form for adding can be reused for editing as well. For that we create a form by the name WishlistViewForm.php in the src/Form directory.

  • As I declared when defining the content entity class, I created a class file responsible for building the overview page of the entities. So straight in the src/ folder of the module I created a UcWishlistListBuilder.php class file extending EntityListBuilder.

  • In this class that extends the EntityListBuilder, I implemented three methods:

    • The buildHeader() method is responsible for creating the table header of our overview page.

    • The buildRow() method is responsible for creating the rows based on the number of entities and their values.

    • The buildRow() method will create the rows based on the number of entities and their values.

    • Lastly, we are overriding the render() method so that we can specify a custom message to display in case there are no entities to show (personal preference). And that's basically it with the list builder class.   

  • The last step involved the creation of the related routes so that everything that we created could be accessed in the browser.

The latest port seems to work as planned. However,  the second port, concerning the add to wishlist submit handler displays a minor error while registering products to be added to the wish list. The incumbent errors would be fixed subsequently after the completion of the remaining sole port for the second phase, i.e., ‘Search wishlist’, the porting of which I have already begun and would be completed within the stipulated time.

The third port, therefore, enables users to view a specific wish list (provided required items are added to the wish list through the add to wishlist submit button). On clicking that button the user wish list is automatically updated to include the latest changes.

D8 visuals for the latest port, ‘View/Update wishlist’:

well

 

At present, the directory structure looks like this:

 

struct


 

The code for the current status of the port can be found here.

Winding up, these were the objectives and concepts learned during the seventh week of coding phase in GSoC’17 and hope to learn many more new concepts in the coming weeks for the successful completion of the port for the current and final phases.

Cheers!