<?php

namespace KupShop\I18nBundle\Translations;

class VariationsValuesTranslation extends BaseTranslation
{
    protected $columns = [
        'value' => ['alias' => 'Hodnota', 'maxlength' => 50],
    ];

    protected $tableName = 'products_variations_choices_values';

    protected $tableAlias = 'pvcv';

    protected $nameColumn = 'value';

    public function getColumns(): array
    {
        $columns = parent::getColumns();

        if (findModule(\Modules::INDEXED_FILTER)) {
            $columns = $columns + [
                'filter_url' => ['alias' => 'URL filtru', 'maxlength' => 50],
            ];
        }

        return $columns;
    }

    public function saveSingleObject(string $languageID, $objectID, array $values, ?string $sourceLanguageID = null): bool
    {
        $result = parent::saveSingleObject($languageID, $objectID, $values, $sourceLanguageID);

        (new VariationsTranslation())->variationsLabelsTranslation(null, $objectID);

        return $result;
    }
}
