HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/ASmits/kemi.nl/app/KommaApp/Kms/Core/Sections/AllUsedLanguagesTabsDirector.php
<?php

namespace App\KommaApp\Kms\Core\Sections;

use App\KommaApp\Kms\Core\Kms;
use App\KommaApp\Languages\Models\Language;

/**
 * This should be used when you have a multi site model
 * Then it will load all languages which are used in all defined sites
 *
 * Class AllUsedLanguagesTabsDirector
 * @package App\KommaApp\Kms\Core\Sections
 */
class AllUsedLanguagesTabsDirector extends AbstractSectionTabsDirector
{
    /**
     * @var $sectionTabBuilder AbstractSectionTabsBuilder
     */
    private $sectionTabBuilder;

    public function __construct(AbstractSectionTabsBuilder $sectionTabBuilder)
    {
        $this->sectionTabBuilder = $sectionTabBuilder;
        parent::__construct($sectionTabBuilder);
    }

    /**
     * Builds the tabs for the page section via the builder it is given.
     * Creates a general tab and tabs for each current language.
     */
    function buildTabs(): void
    {
        $this->sectionTabBuilder->getOrCreateTab(__('kms/global.general'), SectionTabGroups::General);

        // Get all used languages from the site_languages table
        $languages = Language::has('Sites')->get();
        $languages = $languages->reverse();

        foreach($languages as $language)
        {
            $this->sectionTabBuilder->getOrCreateTab($language->iso_2, SectionTabGroups::Languages);
        }
    }

    /**
     * Returns a collection that holds multiple
     *
     * @return SectionTabsCollectionInterface
     */
    function getTabsCollection(): SectionTabsCollectionInterface
    {
        return $this->sectionTabBuilder->getTabsCollection();
    }
}