I have been porting Search Configuration module from Drupal 7 to 8 as part of this year’ s Google Summer of Code (GSoC). This summer program is an opportunity for university students to work on projects connected with open source organisation. I have been really lucky to be a part of this initiative. I could explore deep of more technologies, version control systems as part of my project in Drupal. This gives young students a platform where they are assigned mentors who are experts and experienced in various software.
Last week, I could learn some of the Drupal concepts as part of this module port. So, let me begin with the Drupal 7 property. The t function translates a string to the current language or to a given language. This makes the strings used in Drupal translatable. This generally takes up the format:
t($string, array $args = array(), array $options = array());
Here, $string is the string containing the English text to get translated.
$args: An associative array of replacements to make after translation.
$options: An optional associative array of additional options, with the following elements: lang code and context.
The translatable markup returns a string as a result of this process.
Another important aspect which I dealt was the roles. This is an important feature for any module as it deals with the security constraints of the module. Roles are often manipulated to grant certain permissions. What we have to do is that, initially, load the particular role to be manipulated and then provide the permission which is to be granted.
$role = Role::load('access page.'); $role->grantPermission('access comments');
These role functions help us to load the roles and manipulate the permissions assigned to it quite easily. Thus, turns out to be really helpful in dealing with permissions.
I have been also dealing with writing the simple test for my module. In one of my previous blog posts, I have introduced the PHP unit testing. The simple test tests the web oriented functionality of the module. It needs a good understanding of the behaviour of the module to write an effective test. Tests are often really important to identify the flaws of a functionality and to correct it accordingly. I will be writing the simple tests for my module in the coming days. I will be sharing you the concept of this mode of testing in my next blog post.
Stay tuned for further developments on this blog post.