Find this useful? Enter your email to receive occasional updates for securing PHP code.

Signing you up...

Thank you for signing up!

PHP Decode

<?php namespace Drupal\Core\Field\Plugin\Field\FieldType; use Drupal\Core\Field\Attribut..

Decoded Output download

<?php

namespace Drupal\Core\Field\Plugin\Field\FieldType;

use Drupal\Core\Field\Attribute\FieldType;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Defines the 'created' entity field type.
 */
#[FieldType(
  id: "created",
  label: new TranslatableMarkup("Created"),
  description: new TranslatableMarkup("An entity field containing a UNIX timestamp of when the entity has been created."),
  default_widget: "datetime_timestamp",
  default_formatter: "timestamp",
  no_ui: TRUE,
)]
class CreatedItem extends TimestampItem {

  /**
   * {@inheritdoc}
   */
  public function applyDefaultValue($notify = TRUE) {
    parent::applyDefaultValue($notify);
    // Created fields default to the current timestamp.
    $this->setValue(['value' => \Drupal::time()->getRequestTime()], $notify);
    return $this;
  }

}
 ?>

Did this file decode correctly?

Original Code

<?php

namespace Drupal\Core\Field\Plugin\Field\FieldType;

use Drupal\Core\Field\Attribute\FieldType;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Defines the 'created' entity field type.
 */
#[FieldType(
  id: "created",
  label: new TranslatableMarkup("Created"),
  description: new TranslatableMarkup("An entity field containing a UNIX timestamp of when the entity has been created."),
  default_widget: "datetime_timestamp",
  default_formatter: "timestamp",
  no_ui: TRUE,
)]
class CreatedItem extends TimestampItem {

  /**
   * {@inheritdoc}
   */
  public function applyDefaultValue($notify = TRUE) {
    parent::applyDefaultValue($notify);
    // Created fields default to the current timestamp.
    $this->setValue(['value' => \Drupal::time()->getRequestTime()], $notify);
    return $this;
  }

}

Function Calls

None

Variables

None

Stats

MD5 55351d73a7564ca0415b21f37aa910b0
Eval Count 0
Decode Time 89 ms