1   2   3   4   5   6   7   8   9  10  11  12  13  14  15  16  17  18  19  20  21  22  23  24  25  26  27  28  29  30  31  32  33  34  35  36  37  38  39  40  41  42  43  44  45  46  47  48  49  50  51  52  53  54  55  56  57  58  59  60  61  62  63  64  65  66  67  68  69  70  71  72  73  74  75  76  77  78  79  80  81  82  83  84  85  86  87  88  89  90  91  92  93  94  95  96  97  98  99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 
<?php

/* --------------------------------------------------------------
   AbstractCreateAccountProcess.inc.php 2015-03-13 gm
   Gambio GmbH
   http://www.gambio.de
   Copyright (c) 2015 Gambio GmbH
   Released under the GNU General Public License (Version 2)
   [http://www.gnu.org/licenses/gpl-2.0.html]
   --------------------------------------------------------------
*/

/**
 * Class AbstractCreateAccountProcess
 * 
 * @category System
 * @package Extensions
 * @subpackage Customers
 */
abstract class AbstractCreateAccountProcess
{
    /**
     * @var KeyValueCollection $customerCollection
     */
    protected $customerCollection;

    /**
     * @var CustomerService $customerWriteService
     */
    protected $customerWriteService;

    /**
     * @var CountryService $countryService
     */
    protected $countryService;

    /**
     * @var econda $econda
     * @deprecated econda will be removed in the near future
     */
    protected $econda;


    /**
     * @param CustomerWriteServiceInterface $customerWriteService
     * @param CountryServiceInterface       $countryService
     * @param econda                        $econda
     */
    public function __construct(CustomerWriteServiceInterface $customerWriteService,
                                CountryServiceInterface $countryService,
                                econda $econda = null)
    {
        $this->customerWriteService = $customerWriteService;
        $this->countryService       = $countryService;
        $this->econda               = $econda;
    }


    /**
     * @param KeyValueCollection $customerCollection
     * @param GMLogoManager      $logoManager
     *
     * @throws InvalidCustomerDataException
     */
    public function proceedRegistree(KeyValueCollection $customerCollection, GMLogoManager $logoManager)
    {
        $this->customerCollection = $customerCollection;

        $this->_validateRegistree();
        $this->_saveRegistree();
        $this->_login();
        $this->_proceedVoucher();
        $this->_proceedTracking();
        $this->_proceedMail($logoManager);
    }


    /**
     * @param KeyValueCollection $customerCollection
     *
     * @throws InvalidCustomerDataException
     */
    public function proceedGuest(KeyValueCollection $customerCollection)
    {
        $this->customerCollection = $customerCollection;

        $this->_validateGuest();
        $this->_saveGuest();
        $this->_login();
    }


    /**
     * @throws InvalidCustomerDataException
     */
    abstract protected function _validateRegistree();


    /**
     * @throws InvalidCustomerDataException
     */
    abstract protected function _validateGuest();


    abstract protected function _saveRegistree();


    abstract protected function _saveGuest();


    abstract protected function _login();


    abstract protected function _proceedVoucher();


    abstract protected function _proceedTracking();


    /**
     * @param GMLogoManager $logoManager
     */
    abstract protected function _proceedMail(GMLogoManager $logoManager);
}