You are here

public function MomentOperation::moment in Twig Extender 4.x

Same name and namespace in other branches
  1. 8.4 modules/twig_extender_extras/src/Plugin/TwigPlugin/MomentOperation.php \Drupal\twig_extender_extras\Plugin\TwigPlugin\MomentOperation::moment()
  2. 8.2 modules/twig_extender_extras/src/Plugin/TwigPlugin/MomentOperation.php \Drupal\twig_extender_extras\Plugin\TwigPlugin\MomentOperation::moment()
  3. 8.3 modules/twig_extender_extras/src/Plugin/TwigPlugin/MomentOperation.php \Drupal\twig_extender_extras\Plugin\TwigPlugin\MomentOperation::moment()

Possibility to add or substract days or weeks ...

Parameters

string $date: The element array whose children are to be identified. Passed by reference.

bool $operation: Boolean to indicate whether the children should be sorted by weight.

bool $entry: Boolean to indicate whether the children should be sorted by weight.

bool $number: Boolean to indicate whether the children should be sorted by weight.

bool $timezone: Boolean to indicate whether the children should be sorted by weight.

Return value

array The filtered array to loop over.

File

modules/twig_extender_extras/src/Plugin/TwigPlugin/MomentOperation.php, line 36

Class

MomentOperation
Provide helper methods for Drupal render elements.

Namespace

Drupal\twig_extender_extras\Plugin\TwigPlugin

Code

public function moment($date, $operation, $entry, $number, $timezone = NULL) {
  $moment = $this
    ->getMoment($date, $timezone);
  $funcCall = $operation . ucfirst($entry);
  return $moment
    ->{$funcCall}($number);
}