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\file\Plugin\Field\FieldFormatter; use Drupal\Core\Field\FieldItem..
Decoded Output download
<?php
namespace Drupalile\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
/**
* Plugin implementation of the 'file_table' formatter.
*
* @FieldFormatter(
* id = "file_table",
* label = @Translation("Table of files"),
* field_types = {
* "file"
* }
* )
*/
class TableFormatter extends FileFormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
if ($files = $this->getEntitiesToView($items, $langcode)) {
$header = [t('Attachment'), t('Size')];
$rows = [];
foreach ($files as $delta => $file) {
$rows[] = [
[
'data' => [
'#theme' => 'file_link',
'#file' => $file,
'#cache' => [
'tags' => $file->getCacheTags(),
],
],
],
['data' => format_size($file->getSize())],
];
}
$elements[0] = [];
if (!empty($rows)) {
$elements[0] = [
'#theme' => 'table__file_formatter_table',
'#header' => $header,
'#rows' => $rows,
];
}
}
return $elements;
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace Drupal\file\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldItemListInterface;
/**
* Plugin implementation of the 'file_table' formatter.
*
* @FieldFormatter(
* id = "file_table",
* label = @Translation("Table of files"),
* field_types = {
* "file"
* }
* )
*/
class TableFormatter extends FileFormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
if ($files = $this->getEntitiesToView($items, $langcode)) {
$header = [t('Attachment'), t('Size')];
$rows = [];
foreach ($files as $delta => $file) {
$rows[] = [
[
'data' => [
'#theme' => 'file_link',
'#file' => $file,
'#cache' => [
'tags' => $file->getCacheTags(),
],
],
],
['data' => format_size($file->getSize())],
];
}
$elements[0] = [];
if (!empty($rows)) {
$elements[0] = [
'#theme' => 'table__file_formatter_table',
'#header' => $header,
'#rows' => $rows,
];
}
}
return $elements;
}
}
Function Calls
None |
Stats
MD5 | 0c658adb9b0cd7e330bbd66e99ddf476 |
Eval Count | 0 |
Decode Time | 78 ms |