<?php

namespace Benhauer\Salesmanago\Observer;

use \Magento\Framework\Event\Observer;
use \Benhauer\Salesmanago\Helper\Tagger;
use \Benhauer\Salesmanago\Observer\CustomerModified as SalesmanagoCustomerModified;

class AdminCustomerModified extends SalesmanagoCustomerModified
{
    protected $customer;

    /**
     * @return object Customer;
     */
    public function getCustomer($observer)
    {
        $this->customer = $observer->getCustomer();
        $this->setStoreViewForModel();
        return $this->customer;
    }

    /**
     * Set store view depends from which store view is customer;
     *
     * Set store view id from $this->requestPrams to each model;
     */
    public function setStoreViewForModel()
    {
        $storeId = null;

        if (isset($this->customer)) {
            $storeId = $this->customer->getStoreId();
        }

        if ($storeId != null && $storeId != 0) {
            $this->model->setScopeId($storeId);
            $this->model->setScope('store');
        }
    }
}
