public function handlePersistDocument(PersistEvent $event)
    {
        /** @var ResourceSegmentBehavior $document */
        $document = $event->getDocument();

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

        $property = $this->getResourceSegmentProperty($document);
        // check if a property for the resource segment is available, this prevents the code from failing in case there
        // is no such property for some reason (e.g. the document doesn't have a structure)
        if ($property) {
            $this->persistDocument($document, $property);
        }
    }