NerdsAndCompany\Schematic\Services\Sections::populateSectionLocales PHP Method

populateSectionLocales() private method

Populate section locales.
private populateSectionLocales ( Craft\SectionModel $section, $localeDefinitions )
$section Craft\SectionModel
$localeDefinitions
    private function populateSectionLocales(SectionModel $section, $localeDefinitions)
    {
        $locales = $section->getLocales();
        foreach ($localeDefinitions as $localeId => $localeDef) {
            $locale = array_key_exists($localeId, $locales) ? $locales[$localeId] : new SectionLocaleModel();
            $locale->setAttributes(['locale' => $localeId, 'enabledByDefault' => $localeDef['enabledByDefault'], 'urlFormat' => $localeDef['urlFormat'], 'nestedUrlFormat' => $localeDef['nestedUrlFormat']]);
            // Todo: Is this a hack? I don't see another way.
            // Todo: Might need a sorting order as well? It's NULL at the moment.
            Craft::app()->db->createCommand()->insertOrUpdate('locales', ['locale' => $locale->locale], []);
            $locales[$localeId] = $locale;
        }
        $section->setLocales($locales);
    }