public function genericToggleVisibility(ModelCriteria $query, ToggleVisibilityEvent $event, EventDispatcherInterface $dispatcher = null)
    {
        if (null !== $object = $query->findPk($event->getObjectId())) {
            $newVisibility = !$object->getVisible();
            $object
                //for backward compatibility
                ->setDispatcher($dispatcher !== null ? $dispatcher : $event->getDispatcher())
                ->setVisible($newVisibility)
                ->save()
            ;

            $event->setObject($object);
        }

        return $object;
    }
public function genericToggleVisibility(ModelCriteria $query, ToggleVisibilityEvent $event, EventDispatcherInterface $dispatcher = null)
    {
        if (null !== $object = $query->findPk($event->getObjectId())) {
            $newVisibility = !$object->getVisible();
            $object
                //for backward compatibility
                ->setDispatcher($dispatcher !== null ? $dispatcher : $event->getDispatcher())
                ->setVisible($newVisibility)
                ->save()
            ;

            $event->setObject($object);
        }

        return $object;
    }
public function genericToggleVisibility ( ModelCriteria $ query , ToggleVisibilityEvent $ event , EventDispatcherInterface $ dispatcher = null ) { if ( null !== $ object = $ query -> findPk ( $ event -> getObjectId ( ) ) ) { $ newVisibility = ! $ object -> getVisible ( ) ; $ object //for backward compatibility -> setDispatcher ( $ dispatcher !== null ? $ dispatcher : $ event -> getDispatcher ( ) ) -> setVisible ( $ newVisibility ) -> save ( ) ; $ event -> setObject ( $ object ) ; } return $ object ; }
Toggle visibility for an object

@param ModelCriteria               $query
@param ToggleVisibilityEvent $event
@param EventDispatcherInterface $dispatcher

@return mixed
Toggle visibility for an object