<?php

    namespace MNM\Spitzner\Plugin\Review;

    class RemoveRequiredFields
    {
        /**
         * @var \MNM\Spitzner\Helper\Data
         */
        private $helper;

        public function __construct(\MNM\Spitzner\Helper\Data $helper)
        {
            $this->helper = $helper;
        }

        /**
         * Modify validation
         *
         * @param \Magento\Checkout\Model\DefaultConfigProvider $subject
         * @param bool|string[] $errors
         *
         * @return bool|string[]
         */
        public function afterValidate(\Magento\Review\Model\Review $subject, $errors)
        {
            $errors = [];

            /*MNM
            if (!\Zend_Validate::is($this->getTitle(), 'NotEmpty')) {
                $errors[] = __('Please enter a review summary.');
            }*/

            if (!\Zend_Validate::is($subject->getNickname(), 'NotEmpty')) {
                $errors[] = __('Please enter a nickname.');
            }

            /*MNM
            if (!\Zend_Validate::is($this->getDetail(), 'NotEmpty')) {
                $errors[] = __('Please enter a review.');
            }*/

            if (empty($errors)) {
                //MNM
                $this->helper->sendMail('susanne.bisch-moser@spitzner.de', 'spitzner_email_new_review');

                return true;
            }
            return $errors;
        }
    }