Document/Subscriber/PageSubscriber.php
public function handlePersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        $node = $event->getNode();
        $propertyName = $this->propertyEncoder->systemName(static::FIELD);
        if (!$document instanceof PageBehavior) {
            return;
        }

        $parentDocument = $document->getParent();

        $page = 1;
        foreach ($parentDocument->getChildren() as $child) {
            if (!$child instanceof PageBehavior) {
                continue;
            }

            ++$page;

            if ($child === $document) {
                break;
            }
        }

        $node->setProperty($propertyName, $page);
        $document->setPageNumber($page);
    }
public function handlePersist(PersistEvent $event)
    {
        $document = $event->getDocument();
        $node = $event->getNode();
        $propertyName = $this->propertyEncoder->systemName(static::FIELD);
        if (!$document instanceof PageBehavior) {
            return;
        }

        $parentDocument = $document->getParent();

        $page = 1;
        foreach ($parentDocument->getChildren() as $child) {
            if (!$child instanceof PageBehavior) {
                continue;
            }

            ++$page;

            if ($child === $document) {
                break;
            }
        }

        $node->setProperty($propertyName, $page);
        $document->setPageNumber($page);
    }
public function handlePersist ( PersistEvent $ event ) { $ document = $ event -> getDocument ( ) ; $ node = $ event -> getNode ( ) ; $ propertyName = $ this -> propertyEncoder -> systemName ( static :: FIELD ) ; if ( ! $ document instanceof PageBehavior ) { return ; } $ parentDocument = $ document -> getParent ( ) ; $ page = 1 ; foreach ( $ parentDocument -> getChildren ( ) as $ child ) { if ( ! $ child instanceof PageBehavior ) { continue ; } ++ $ page ; if ( $ child === $ document ) { break ; } } $ node -> setProperty ( $ propertyName , $ page ) ; $ document -> setPageNumber ( $ page ) ; }
Set the page-number to new pages.

@param PersistEvent $event
Set the page - number to new pages .