-
Notifications
You must be signed in to change notification settings - Fork 118
class \Drupal\rules\Plugin\DataType\LoggerEntry #315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.x-3.x
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| <?php | ||
|
|
||
| /** | ||
| * @file | ||
| * Contains \Drupal\rules\Plugin\DataType\LoggerEntry. | ||
| */ | ||
|
|
||
| namespace Drupal\rules\Plugin\DataType; | ||
|
|
||
| use Drupal\Core\TypedData\Plugin\DataType\Map; | ||
|
|
||
| /** | ||
| * The logger entry data type. | ||
| * | ||
| * @see: https://www.drupal.org/node/2625238 | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the "@see" annotations should not have a colon after it, see https://www.drupal.org/coding-standards/docs#see |
||
| * | ||
| * @ingroup typed_data | ||
| * | ||
| * @DataType( | ||
| * id = "loggerentry", | ||
| * label = @Translation("Logger Entry"), | ||
| * definition_class = "\Drupal\Core\TypedData\MapDataDefinition" | ||
| * ) | ||
| */ | ||
| class LoggerEntry extends Map { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can look at examples for typed data in core: Language.php |
||
|
|
||
| /** | ||
| * The data definition. | ||
| * | ||
| * @var \Drupal\Core\TypedData\ComplexDataDefinitionInterface | ||
| */ | ||
| protected $definition; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that property already exists on the parent class. |
||
|
|
||
| /** | ||
| * An array of values for the contained properties. | ||
| * | ||
| * @var array | ||
| */ | ||
| protected $values = array(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that property already exists on the parent class. |
||
|
|
||
| /** | ||
| * The array of properties. | ||
| * | ||
| * @var \Drupal\Core\TypedData\TypedDataInterface[] | ||
| */ | ||
| protected $properties = array(); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that property already exists on the parent class. |
||
|
|
||
| public function __construct(DataDefinitionInterface $definition, $name, TypedDataInterface $parent, $logger_entry_context) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the constructor should not take the logger_entry array values, typed data is always set with the setValue() method. |
||
| parent::__construct($definition, $name, $parent); | ||
|
|
||
| $this->values = $this->createLoggerEntryFromContext($logger_entry_context) | ||
| } | ||
|
|
||
| // Plain copy from \Drupal\rules\Logger\RulesLog | ||
| protected function createLoggerEntryFromContext($context) { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this method is not needed. The caller can just use ->setValue() and pass in the array. Almost all properties are primitives/strings except for variables. |
||
| // Remove any backtraces since they may contain an unserializable variable. | ||
| unset($context['backtrace']); | ||
|
|
||
| // Convert PSR3-style messages to SafeMarkup::format() style, so they can be | ||
| // translated too in runtime. | ||
| $message_placeholders = $this->parser->parseMessagePlaceholders($message, $context); | ||
|
|
||
| $logger_entry = array( | ||
| 'uid' => $context['uid'], | ||
| 'type' => $context['channel'], | ||
| 'message' => $message, | ||
| 'variables' => $message_placeholders, | ||
| 'severity' => $level, | ||
| 'link' => $context['link'], | ||
| 'location' => $context['request_uri'], | ||
| 'referer' => $context['referer'], | ||
| 'hostname' => $context['ip'], | ||
| 'timestamp' => $context['timestamp'], | ||
| ); | ||
|
|
||
| return $logger_entry; | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we describe what this is? Example "Represents a log entry that is created from system log messages."