File: D:/HostingSpaces/SBogers10/inzigd.komma.pro/app/Komma/Kms/Core/Sections/SectionServiceInterface.php
<?php
/**
* Created by PhpStorm.
* User: julesgraus
* Date: 23/02/2018
* Time: 13:38
*/
namespace App\Komma\Kms\Core\Sections;
use App\Komma\Kms\Core\AbstractTranslatableModel;
use App\Komma\Kms\Core\AbstractTranslationModel;
use App\Komma\Kms\Core\Tree\NestedSets\Nodes\TreeModelInterface;
use App\Komma\Globalization\Languages\Models\Language;
use Illuminate\Database\Eloquent\Collection;
use Illuminate\Database\Eloquent\Model;
/**
* @see PageRepository Based of the deprecated PageRepository and KmsRepository
*
* Class SectionService
* @package App\Komma\Shop\
*/
interface SectionServiceInterface
{
/**
* This method will get a model based on the id.
* When the id is NULL or the model does not exist, we will generate a new.
*
* @see KmsSection::loadModel()
* @param int $modelId
* @return Model
*/
public function getModel($modelId = null): Model;
/**
* Gets the name of the model the service does its work for.
* WARNING! Prevent usage of this method.
*
* @return string
*/
public function getForModelName(): string;
/**
* Gets the name of the model the service does its work for.
* WARNING! Prevent usage of this method.
*
* @return string
*/
public function getForTranslationModelName(): string;
/**
* This method will create a new TranslatableModelInterface instance with its translations.
*
* @param null $siteId
* @return Model
*/
public function newModel($siteId = null): Model;
/**
* Gets the model query
*
* @return \Illuminate\Database\Query\Builder
*/
public function models();
/**
* Gets the model query
*
* @return \Illuminate\Database\Query\Builder
*/
public function translationModels();
/**
* Get model tree
*
* @return TreeModelInterface
*/
public function getModelTree($siteId = null): TreeModelInterface;
/**
* Returns all models for the sidebar menu in the backend
*
* @return array
*/
public function getModelsForSideBar(): array;
/**
* Return the root model
*/
public function getRootModelForTree(): ?Model;
/**
* This method will save an model
*
* @param Model $model or null
* @param Collection $sectionTabItems These must be filled with data. This is something you need to do yourself.
*
* @return mixed
*/
public function saveModel(Model $model = null, Collection $sectionTabItems): Model;
/**
* Returns true when the section has a sortable items list to the left side of the screen or false if not.
*
* @return boolean
*/
public function getSortable();
/**
* @param bool $allowNullableSelectOption
* @return \Illuminate\Support\Collection containing selectOptions
*/
public function getOptionsForSelect(bool $allowNullableSelectOption = false): \Illuminate\Support\Collection;
/**
* Fills attributes with data from a model in this way:
*
* 1. First it looks if it needs to get the value from a translationModel.
* If so, gets it, fills the attribute and fills the next attribute if any
* 2. Then it looks if it needs to get the value from it's model.
* If so, gets it, fills the attribute and fills the next attribute if any
* 4. Then it looks if it needs to get the value from the images associated with it.
* If so, gets it, fills the attribute and fills the next attribute if any
* Please notice that if cases 1, 2 and 3 where true the value you may have set with setValue is overwritten.
*
* @param Collection $sectionTabItems A collection containing implementations AbstractSectionTabItem's
* @param Model $model
* @return Collection
*/
public function fillAttributesWithData(Collection $sectionTabItems, Model $model);
/**
* This method will remove an TranslatableModelInterface instance
*
* @param $model
* @throws \Exception
*/
public function destroyModel(Model $model);
/**
* Generate an unique slug for an Abstract translatable model
*
* @param AbstractTranslationModel $translation
* @param string $name
* @param int $uniquifier
* @return string
*/
function createOrGetUniqueSlug(AbstractTranslationModel $translation, string $name, int $uniquifier = 0): string;
/**
* 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;
/**
* Creates Injects empty but linked translations into a translatable
* for each kms site language so that you can assume their presence.
* 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);
/**
* @param Model $model
* @param Collection $sectionTabItems
* @param $componentAreaAttributeKeyFrom
* @param $componentAreaAttributeKeyTo
* @return mixed
*/
public function copyComponentArea(Model $model, Collection $sectionTabItems, string $componentAreaAttributeKeyFrom, string $componentAreaAttributeKeyTo);
}