public function clear(BlockManagersCollection $blockManagersCollection)
    {
        // @codeCoverageIgnoreStart
        if ($blockManagersCollection->count() == 0) {
            return null;
        }
        // @codeCoverageIgnoreEnd

        try {
            $result = null;
            $this->blockRepository->startTransaction();
            $blockManagers = $blockManagersCollection->getBlockManagers();

            foreach ($blockManagers as $blockManager) {
                $result = $blockManager->delete();
                if (false === $result) {
                    break;
                }
            }

            if (false !== $result) {
                $this->blockRepository->commit();
                $blockManagersCollection->clear();

                return $result;
            }

            $this->blockRepository->rollBack();

            return $result;
        } catch (\Exception $e) {
            $this->blockRepository->rollBack();

            throw $e;
        }
    }