The following code will return the root path for a drupal file system. \Drupal::service('file_system')->realpath(file_default_scheme() . "://") . '/');
To enable revision and to log revision message on saving a node in drupal 8 we can use setNewRevision() and setRevisionLogMessage(). Find the below code which uses entity save with revision.
In MySQL, the ORDER BY keyword is used for sorting the records ascending(ASC) or descending(DESC), by default it will be on ascending. The default ORDER BY statement will not work with Alpha-Numerical values(The values is mixed of both numbers and strings). To resolve this problem we can use ABS() MySQL function.
To load the author name or owner from a node entity object we can use getOwner(). The below example show how to load a node object using node id and to get the Author name from it.
Getting the content type using a node id in drupal 8 can be achieved using bundle() function. The following code will return the node object.
The following code will return all the available fields as an array by a field type. You can pass the field type that you want to load within getFieldMapByFieldType() function.
The below code will return all the available user roles as an array in drupal 8.
Changing the location of the module which is installed will return error. To do this you have to rebuild the APC cache. Try the one of the following steps after changing the module location.
In Drupal we have site wide common Email ID. This Email id is used for the set as default from Email address for all emails sent from the site. Also, this email id is used to receive the emails regarding the updates for Core and other modules.
Below code is the condition to check the web site accessing device is from mobile using "HTTP_USER_AGENT" in .htaccess file. You can use this condition and create a RewriteRule for any redirection.