src/RepositoryTrait.php
protected function runManagerAction(string $action, $objects, bool $flush)
    {
        $manager = $this->getManager();

        if (!is_iterable($objects)) {
            $objects = \array_filter([$objects]);
        }

        foreach ($objects as $object) {
            if (!$this->canBeManaged($object)) {
                throw new \InvalidArgumentException(
                    \sprintf(
                        'Managed object must be a %s. "%s" given',
                        $this->getClassName(),
                        \is_object($object) ? \get_class($object) : \gettype($object)
                    )
                );
            }

            $manager->$action($object);
        }

        // @codeCoverageIgnoreStart
        if ($objects instanceof \Traversable) {
            $objects = \iterator_to_array($objects);
        }
        // @codeCoverageIgnoreEnd

        $this->flushObjects($objects, $flush);
    }
protected function runManagerAction(string $action, $objects, bool $flush)
    {
        $manager = $this->getManager();

        if (!is_iterable($objects)) {
            $objects = \array_filter([$objects]);
        }

        foreach ($objects as $object) {
            if (!$this->canBeManaged($object)) {
                throw new \InvalidArgumentException(
                    \sprintf(
                        'Managed object must be a %s. "%s" given',
                        $this->getClassName(),
                        \is_object($object) ? \get_class($object) : \gettype($object)
                    )
                );
            }

            $manager->$action($object);
        }

        // @codeCoverageIgnoreStart
        if ($objects instanceof \Traversable) {
            $objects = \iterator_to_array($objects);
        }
        // @codeCoverageIgnoreEnd

        $this->flushObjects($objects, $flush);
    }
Run manager action.

@param string          $action
@param object|iterable $objects
@param bool            $flush

@throws \InvalidArgumentException