public function onOptionSet(tubepress_api_event_EventInterface $event) { if (!$this->_logger->isEnabled()) { return; } $errors = $event->getSubject(); $optionName = $event->getArgument('optionName'); $optionValue = $event->getArgument('optionValue'); if (count($errors) === 0) { $this->_logger->debug(sprintf('(Option Logger) Accepted valid value: <code>%s</code> = <code>%s</code>', $optionName, $this->_stringUtils->redactSecrets($optionValue))); } else { $this->_logger->error(sprintf('(Option Logger) Rejecting invalid value: <code>%s</code> = <code>%s</code> (%s)', $optionName, $this->_stringUtils->redactSecrets($optionValue), $errors[0])); } }
/** * Handles the detection of a custom options. * * @param array $match The array shortcode matches * * @return array The name value pair array. */ private function _buildNameValuePairArray($match) { $toReturn = array(); $value = null; foreach ($match as $m) { if (!empty($m[1])) { $name = $m[1]; $value = $m[2]; } elseif (!empty($m[3])) { $name = $m[3]; $value = $m[4]; } elseif (!empty($m[5])) { $name = $m[5]; $value = $m[6]; } if (!isset($name) || !isset($value)) { continue; } if ($this->_shouldLog) { $this->_logger->debug(sprintf('Name-value pair detected: %s = "%s" (unfiltered)', $name, $this->_stringUtils->redactSecrets($value))); } $event = $this->_eventDispatcher->newEventInstance($value, array('optionName' => $name)); $this->_eventDispatcher->dispatch(tubepress_api_event_Events::NVP_FROM_EXTERNAL_INPUT, $event); $filtered = $event->getSubject(); $event = $this->_eventDispatcher->newEventInstance($filtered, array('optionName' => $name)); $this->_eventDispatcher->dispatch(tubepress_api_event_Events::NVP_FROM_EXTERNAL_INPUT . ".{$name}", $event); $filtered = $event->getSubject(); if ($this->_shouldLog) { $this->_logger->debug(sprintf('Name-value pair detected: %s = "%s" (filtered)', $name, $this->_stringUtils->redactSecrets($filtered))); } $toReturn[$name] = $filtered; } return $toReturn; }