public function checkCollection($collection, $notification, $redirectURL, $expected = 1) {

        if (null === $collection || (false === is_array($collection) && false === ($collection instanceof Countable))) {
            throw new InvalidArgumentException("The collection must be a countable");
        }
        if ($expected <= count($collection)) {
            return;
        }

        $eventName = NotificationEvents::NOTIFICATION_WARNING;

        if (null !== $this->getEventDispatcher() && true === $this->getEventDispatcher()->hasListeners($eventName)) {

            $notification = NotificationFactory::newWarningNotification($notification);
            $event        = new NotificationEvent($eventName, $notification);

            $this->getEventDispatcher()->dispatch($eventName, $event);
        }

        throw new RedirectResponseException($redirectURL, null);
    }
public function checkCollection($collection, $notification, $redirectURL, $expected = 1) {

        if (null === $collection || (false === is_array($collection) && false === ($collection instanceof Countable))) {
            throw new InvalidArgumentException("The collection must be a countable");
        }
        if ($expected <= count($collection)) {
            return;
        }

        $eventName = NotificationEvents::NOTIFICATION_WARNING;

        if (null !== $this->getEventDispatcher() && true === $this->getEventDispatcher()->hasListeners($eventName)) {

            $notification = NotificationFactory::newWarningNotification($notification);
            $event        = new NotificationEvent($eventName, $notification);

            $this->getEventDispatcher()->dispatch($eventName, $event);
        }

        throw new RedirectResponseException($redirectURL, null);
    }
public function checkCollection ( $ collection , $ notification , $ redirectURL , $ expected = 1 ) { if ( null === $ collection || ( false === is_array ( $ collection ) && false === ( $ collection instanceof Countable ) ) ) { throw new InvalidArgumentException ( "The collection must be a countable" ) ; } if ( $ expected <= count ( $ collection ) ) { return ; } $ eventName = NotificationEvents :: NOTIFICATION_WARNING ; if ( null !== $ this -> getEventDispatcher ( ) && true === $ this -> getEventDispatcher ( ) -> hasListeners ( $ eventName ) ) { $ notification = NotificationFactory :: newWarningNotification ( $ notification ) ; $ event = new NotificationEvent ( $ eventName , $ notification ) ; $ this -> getEventDispatcher ( ) -> dispatch ( $ eventName , $ event ) ; } throw new RedirectResponseException ( $ redirectURL , null ) ; }
Check a collection.

@param Countable $collection The collection.
@param string $notification The notification.
@param string $redirectURL The redirect URL.
@param int $expected The expected count.
@throws InvalidArgumentException Throws an invalid argument exception if collection is null.
@throws RedirectResponseException Throws a redirect response exception if the collection is less than $expected.
Check a collection .