/**
  * @param DataModelInterface $model
  *
  * @return array
  * @throws \Exception
  */
 protected function getConfig(DataModelInterface $model)
 {
     if (!$this->getServiceLocator()->has($model->_adapter)) {
         throw new \Exception('Wrong adapter name ' . $model->_adapter . ' in model ' . $model->getModelName());
     }
     return $this->getServiceLocator()->get($model->_adapter)->getDriver()->getConnection()->getConnectionParameters();
 }
 /**
  * @param DataModelInterface $model
  *
  * @return bool|mixed
  */
 public function isUnique(DataModelInterface $model)
 {
     $modelConfig = $this->getParsedModelConfig();
     if ($modelConfig !== null) {
         foreach ($modelConfig->unique as $_unique) {
             $_data = [];
             foreach ((array) $_unique as $_key) {
                 $_data[$_key] = $model->{$_key};
             }
             $check = $this->find($_data);
             if ($check->count() > 0 && $check->current()->id() != $model->id()) {
                 return false;
             }
         }
     }
     return true;
 }
 public function saveConfigToDbByObject(DataModelInterface $configObject)
 {
     $configArray = Arr::getDoubtField($this->getConfigPart($configObject->getModelName()), 'custom', []);
     foreach ($configArray as $config) {
         $object = clone $configObject;
         $object->exchangeArray($config);
         $this->getGatewayServiceVerify()->get($configObject->getModelName(), $configObject)->save($object);
     }
     return $this;
 }