Neos\Flow\ResourceManagement\Publishing\MessageCollector::append PHP 메소드

append() 공개 메소드

public append ( string $message, string $severity = Error::SEVERITY_ERROR, integer $code = null ) : void
$message string The message to log
$severity string An integer value, one of the Error::SEVERITY_* constants
$code integer A unique error code
리턴 void
    public function append($message, $severity = Error::SEVERITY_ERROR, $code = null)
    {
        switch ($severity) {
            case Error::SEVERITY_ERROR:
                $notification = new Error($message, $code);
                break;
            case Error::SEVERITY_WARNING:
                $notification = new Warning($message, $code);
                break;
            case Error::SEVERITY_NOTICE:
                $notification = new Notice($message, $code);
                break;
            case Error::SEVERITY_OK:
                $notification = new Message($message, $code);
                break;
            default:
                throw new Exception('Invalid severity', 1455819761);
        }
        $this->messages->attach($notification);
    }

Usage Example

 /**
  * Handle missing data notification
  *
  * @param CollectionInterface $collection
  * @param ResourceMetaDataInterface $resource
  */
 protected function handleMissingData(ResourceMetaDataInterface $resource, CollectionInterface $collection)
 {
     $message = sprintf('Could not publish resource %s with SHA1 hash %s of collection %s because there seems to be no corresponding data in the storage.', $resource->getFilename(), $resource->getSha1(), $collection->getName());
     $this->messageCollector->append($message);
 }