public function align(Template $template, array $templateSlots)
    {
        $slots = array_flip($template->getSlots());
        if (empty($templateSlots) || empty($slots)) {
            return null;
        }

        $templateName = strtolower($template->getTemplateName());
        $templateSlots = array_intersect_key($templateSlots, $slots);

        if (null === $this->languageId) {
            $languageRepository = $this->factoryRepository->createRepository('Language');
            $language = $languageRepository->mainLanguage();
            $this->languageId = $language->getId();
        }

        if (null === $this->pageId) {
            $pageRepository = $this->factoryRepository->createRepository('Page');
            $page = $pageRepository->fromTemplateName($templateName, true);
            $this->pageId = $page->getId();
        }

        $pageBlocks = $this->blockRepository->retrieveContents(array(1, $this->languageId), array(1, $this->pageId));
        $currentSlots = $this->templateSlotsToArray($templateSlots);

        $changedSlots = array();
        foreach ($pageBlocks as $pageBlock) {
            $slotName = $pageBlock->getSlotName();
            if (array_key_exists($slotName, $currentSlots)) {
                $languageId = $pageBlock->getLanguageId();
                $pageId = $pageBlock->getPageId();
                $currentRepeatedStatus = 'page';
                if ($languageId == 1 && $pageId == 1) {
                    $currentRepeatedStatus = 'site';
                }

                if ($languageId != 1 && $pageId == 1) {
                    $currentRepeatedStatus = 'language';
                }

                if ($currentRepeatedStatus != $currentSlots[$slotName]) {
                    $changedSlots[$slotName] = $currentSlots[$slotName];
                }
            }
        }

        return ( ! empty($changedSlots)) ? $this->updateSlotStatus($templateSlots, $changedSlots) : null;
    }