In this snippet we will know how to trim any string in Drupal way using the truncate_utf8 function
truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1)
So for example we can do something like this:
git branch --merged | egrep -v "(^\*|master|dev)" | xargs git branch -d |
<?php | |
namespace App\Rules; | |
use Illuminate\Contracts\Validation\Rule; | |
use Carbon\Carbon; | |
class Timestamp implements Rule | |
{ | |
/** |
<?php | |
namespace App\Http\Middleware; | |
use Closure; | |
use Illuminate\Http\JsonResponse; | |
class ProfileJsonResponse | |
{ | |
/** |
<?php | |
/* | |
* Plugin: StreamlineFoundation | |
* | |
* Class: Schedule | |
* | |
* Description: Provides scheduling mechanics including creating a schedule, testing if a specific moment is part of the schedule, moving back | |
* and forth between scheduled moments in time and translating the created schedule back to a human readable form. | |
* | |
* Usage: ::fromCronString() creates a new Schedule class and requires a string in the cron ('* * * * *', $language) format. |
In this snippet we will know how to trim any string in Drupal way using the truncate_utf8 function
truncate_utf8($string, $max_length, $wordsafe = FALSE, $add_ellipsis = FALSE, $min_wordsafe_length = 1)
So for example we can do something like this:
This snippet is a follow up from this one: Crear formato personalizado para un campo de tipo fecha
In order to implement a settings form to our custom field formatter we only need to use the 'settings' parameter in the field formatter declaration (in hook_field_formatter_info()) and a few hooks.
Through the hook_field_formatter_settings_summary() we can implement a summary showing the configuration used.