getUpdated example


  public function preRenderLock($element) {
    if (isset($element['#lock']) && isset($element['#label']) && isset($element['#url'])) {
      /** @var \Drupal\Core\TempStore\Lock $lock */
      $lock = $element['#lock'];
      $age = $this->dateFormatter->formatTimeDiffSince($lock->getUpdated());
      $owner = $this->entityTypeManager->getStorage('user')->load($lock->getOwnerId());
      $username = [
        '#theme' => 'username',
        '#account' => $owner,
      ];
      $element['#markup'] = $this->t('This @label is being edited by user @user, and is therefore locked from editing by others. This lock is @age old. Click here to <a href=":url">break this lock</a>.', [
        '@label' => $element['#label'],
        '@user' => $this->renderer->render($username),
        '@age' => $age,
        ':url' => $element['#url']->toString(),
      ]);
    }
Home | Imprint | This part of the site doesn't use cookies.