Skip to content

Commit

Permalink
Continue pages import
Browse files Browse the repository at this point in the history
  • Loading branch information
mlocati committed Jan 28, 2025
1 parent 1bcafb4 commit c83bae5
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ private function publishPage(Batch $batch, LoggerInterface $logger, MTPage $mtPa
$ccmPage = $this->createRegularPage($batch, $ccmParentPage, $mtPage);
break;
}
$this->setAdditionalPaths($mtPage, $ccmPage);
$logger->logPublishComplete($mtPage, $ccmPage);
}
$this->setAdditionalPaths($mtPage, $ccmPage);

return $ccmPage;
}
Expand Down Expand Up @@ -107,7 +107,7 @@ private function createRegularPage(Batch $batch, ?CCMPage $ccmParentPage, MTPage
$page = $service->addHomePage($locale, $pageTemplate, $data['name'] ?? 'Home', $data['cHandle']);
$page->update([
'cDescription' => $data['cDescription'],
'cDatePublic' => $data['$cDatePublic'],
'cDatePublic' => $data['cDatePublic'],
'ptID' => $data['ptID'],
'uID' => $data['uID'],
'pkgID' => $data['pkgID'],
Expand Down Expand Up @@ -297,6 +297,7 @@ protected function getBatchParentPage(Batch $batch): CCMPage

private function updateExistingPage(Batch $batch, MTPage $mtPage, CCMPage $ccmPage): void
{
$this->setAdditionalPaths($mtPage, $ccmPage);
switch ($mtPage->getKind()) {
case MTPage::KIND_ALIAS:
break;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<?php
namespace PortlandLabs\Concrete5\MigrationTool\Publisher\Command\Handler;

use Concrete\Core\Multilingual\Page\Section\Section;
use Concrete\Core\Page\Page as CCMPage;
use Concrete\Core\Page\Type\Composer\FormLayoutSetControl;
use Doctrine\ORM\EntityManagerInterface;
use PortlandLabs\Concrete5\MigrationTool\Batch\BatchInterface;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\Batch;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\Page as MTPage;
use PortlandLabs\Concrete5\MigrationTool\Publisher\Logger\LoggerInterface;
use Doctrine\ORM\EntityManagerInterface;

defined('C5_EXECUTE') or die("Access Denied.");

Expand All @@ -16,7 +20,13 @@ class PublishPageContentCommandHandler extends AbstractPageCommandHandler
public function execute(BatchInterface $batch, LoggerInterface $logger)
{
$mtPage = $this->getPage($this->command->getPageId());
switch ($mtPage->getKind()) {
case MTPage::KIND_ALIAS:
case MTPage::KIND_EXTERNAL_LINK:
return;
}
$ccmPage = $this->getPageByPath($batch, $mtPage->getBatchPath());
$this->publishHRefLangs($batch, $mtPage, $ccmPage);
foreach ($mtPage->getAttributes() as $mtAttribute) {
$ak = $this->getTargetItem($batch, 'page_attribute', $mtAttribute->getAttribute()->getHandle());
if (is_object($ak)) {
Expand Down Expand Up @@ -116,4 +126,32 @@ public function execute(BatchInterface $batch, LoggerInterface $logger)
$ccmBlock->deleteBlock();
}
}

private function publishHRefLangs(Batch $batch, MTPage $mtPage, CCMPage $ccmPage): void
{
if ($batch->isPublishToSitemap() !== true) {
return;
}
foreach ($mtPage->getHRefLangs() as $hrefLang) {
/** @var \PortlandLabs\Concrete5\MigrationTool\Entity\Import\Page\HRefLang $hrefLang */
$destinationPage = $this->getPageByPath($batch, $hrefLang->getPathForLocale());
if ($destinationPage === null || $destinationPage->getCollectionID() == $ccmPage->getCollectionID()) {
continue;
}
$destinationSection = Section::getByID($destinationPage->getCollectionID());
if (!$destinationSection || $destinationSection->isError()) {
$destinationSection = Section::getBySectionOfSite($destinationPage);
if (!$destinationSection || $destinationSection->isError()) {
continue;
}
}
if ($destinationSection->getLocale() !== $hrefLang->getLocaleID()) {
continue;
}
if (!Section::isAssigned($ccmPage)) {
Section::registerPage($ccmPage);
}
Section::relatePage($ccmPage, $destinationPage, $destinationSection->getLocale());
}
}
}

0 comments on commit c83bae5

Please sign in to comment.