The Google Summer of Code 2017 (GSoC’ 17) coding period started last week on May 30th. Each student got 4 weeks community bonding period with their respective organization. I had written about my community bonding period with Drupal in the previous blog post.
I am working on Adding support for The league OAuth and new implementers for social auth and social post under the mentorship of Getulio Sánchez "gvso" (Paraguay) and Daniel Harris “dahacouk” (UK). During my initial phase, I worked on creating Universal Entities in Drupal 8 and making the league required library for social auth and social post.
Here are some of the things that I worked on during the initial week of GSoC coding period.
Making The League a required dependency in Social Auth And Social Post modules - The library requirement is checked by checkLibrary method written in SocialApiImplementerInstaller.php in Social API module. The minimum supported version of the league by social API will be 2.1.0, also as the league has semantic versioning the maximum supported version after the GSoC will be 3.0
Entities - Entities are the basic building blocks of Drupal's data model. There are two type of entities in Drupal 8.
Configuration entities are objects that allow us to store information (and default values) for configurable settings on our site. Examples of configuration entities in core include image styles, user roles and displays in views.
Content entities are configurable, support translation and revisions, and allow additional fields to be attached for more complex data modeling.
As we’re not using email to identify the user, we needed to create new content entity through which we could identify the user using ids gotten from the providers. The entity class and associated schema is defined in social_auth/src/Entity/SocialAuth.php and social_post/src/Entity/SocialPost.php.
Schema Of Entities Created
We created entities for social auth and social post, we’re using content entities to store user related data. The Social Media ID will be the unique id returned by the social media provider and will be associated with the Drupal user id in both social auth and social post. Whereas in the case of Social Post we’re also including one more field ‘Access Token’, which is a credential used by the implementers to access a provider’s API. We store access tokens which will be further used to take action on behalf of the user by making API calls.
Test for adding records in entities - The patch was written to test if records are getting entered into newly created entities, currently, the records are being added directly from social implementers module. The task for the next week will be to modify methods defined in SocialAuthUserManager.php to use entities to manage user related data.
These were some of the important concepts related to my project that I had to deal with during Integrating The League In Social API. I was thrilled by the first week of GsoC coding phase, my goal for the next week will be to implement the league in social auth and social post and get started with implementing helper methods.