public function setTitleOnDocument(AbstractMappingEvent $event)
    {
        $document = $event->getDocument();

        if (!$this->supports($document)) {
            return;
        }

        if ($document instanceof LocalizedTitleBehavior) {
            if (!$event->getLocale()) {
                return;
            }

            $document->setTitle(
                $event->getNode()->getPropertyValueWithDefault(
                    $this->propertyEncoder->localizedContentName(static::PROPERTY_NAME, $event->getLocale()),
                    ''
                )
            );
        } else {
            $document->setTitle(
                $event->getNode()->getPropertyValueWithDefault(
                    $this->propertyEncoder->contentName(static::PROPERTY_NAME),
                    ''
                )
            );
        }
    }