if ($remote === null) { throw new Exception('Impossibile trovare la classe remota'); } if ($module->isCurrentAction('Sync')) { $force = false; $removeExtra = false; if ($http->hasPostVariable('ForceSync')) { $force = $http->postVariable('ForceSync') == 1; } if ($http->hasPostVariable('RemoveExtra')) { $removeExtra = $http->postVariable('RemoveExtra') == 1; } $tools->sync($force, $removeExtra); return $module->redirectTo('/classtools/compare/' . $id . $remoteRequestSuffix); } $tools->compare(); $result = $tools->getData(); $tpl->setVariable('locale', $locale); $tpl->setVariable('id', $id); $missingLocale = array(); foreach ($tools->getData()->missingAttributes as $item) { $missingLocale[] = new Item($item); } $tpl->setVariable('missing_in_locale', $missingLocale); $missingRemote = array(); foreach ($tools->getData()->extraAttributes as $item) { $obj = new Item($item); $missingRemote[] = $obj; } $tpl->setVariable('missing_in_remote', $missingRemote); $tpl->setVariable('missing_in_remote_details', $tools->getData()->extraDetails);
/** * @param bool $createClassIfNotExists * * @throws Exception */ protected function checkClass($createClassIfNotExists = false) { if (class_exists('OCClassTools')) { try { OCClassTools::setRemoteUrl(rtrim($this->attributes['definition']['Url'], '/') . self::SERVER_CLASSDEFINITION_PATH); $tools = new OCClassTools($this->classIdentifier, $createClassIfNotExists); if ($createClassIfNotExists) { $tools->sync(); } $tools->compare(); $result = $tools->getData(); if ($result->hasError) { throw new Exception(var_export($result->errors, 1)); } } catch (Exception $e) { throw new Exception('[Repository classi di contenuto ' . OCClassTools::getRemoteUrl() . '] ' . $e->getMessage()); } } else { throw new Exception("Libreria OCClassTools non trovata"); } $this->contentClass = eZContentClass::fetchByIdentifier($this->classIdentifier); if (!$this->contentClass instanceof eZContentClass) { throw new Exception("La classe di contenuto non esiste in questa installazione"); } }