File: D:/HostingSpaces/SBogers10/shop.komma.nl/vendor/komma/kms/src/Core/TranslationServiceInterface.php
<?php declare(strict_types=1);
namespace Komma\KMS\Core;
use Komma\KMS\Globalization\Languages\Models\Language;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Query\Builder;
interface TranslationServiceInterface extends AbstractModelHandlerInterface
{
/**
* Make and injects empty but linked translations into a translatable
* for each kms site language so that you can assume their presence. If the database already has a translation
* it will be loaded instead of making an empty translation
* Notice that they are not saved to the database. You need to save them yourself.
*
* @param Model $model
* @return Model
*/
public function makeAndInjectEmptyTranslationsIntoTranslatableIfNeeded(Model $model): Model;
/**
* Gets the model query
*
* @return Builder
*/
public function translationModels(): Builder;
/**
* Save the translations of the given AbstractTranslatableModel if they contain some data.
* Also links translations and translatable model with eachother
* If the force save callback returns true the translation will be saved, even if it does not have data.
* This because something else depends on the translation existing.
*
* @param Model $model
* @return Model
*/
public function saveModelTranslations(Model $model): Model;
/**
* Uses a model that must have a translations method, creates a new translation for it if it does not exists and associates it with the language given.
* Returns the translation
*
* @param AbstractTranslatableModel $model
* @param Language $language
* @return AbstractTranslationModel|null The translation
*/
public function getTranslationModelForModelByLanguage(
AbstractTranslatableModel &$model,
Language $language
): ?AbstractTranslationModel;
/**
* @param string $modelClassName
*/
public function setModelClassName(string $modelClassName): void;
/**
* Forces saving the models translations when the closure returns true for a specific translation.
* The closures receives the translation model in its parameters for each model's translation.
*
* @param AbstractTranslatableModel $model
* @param \Closure $closure
*
* @return mixed
*/
public function forceSaveWhenTrue(AbstractTranslatableModel $model, \Closure $closure);
}