-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
48 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 38 additions & 1 deletion
39
...ation_tool/src/PortlandLabs/Concrete5/MigrationTool/Publisher/Validator/PageValidator.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,47 @@ | ||
<?php | ||
namespace PortlandLabs\Concrete5\MigrationTool\Publisher\Validator; | ||
|
||
use PortlandLabs\Concrete5\MigrationTool\Batch\ContentMapper\Item\Item; | ||
use PortlandLabs\Concrete5\MigrationTool\Entity\ContentMapper\IgnoredTargetItem; | ||
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\Page; | ||
use PortlandLabs\Concrete5\MigrationTool\Publisher\PublishableInterface; | ||
use PortlandLabs\Concrete5\MigrationTool\Publisher\Routine\CreatePageStructureRoutine; | ||
use PortlandLabs\Concrete5\MigrationTool\Publisher\Routine\CreatePageStructureRoutineAction; | ||
|
||
class PageValidator extends AbstractValidator | ||
{ | ||
|
||
protected $skip = false; | ||
|
||
public function __construct(PublishableInterface $object) | ||
{ | ||
parent::__construct($object); | ||
|
||
$em = \Database::connection()->getEntityManager(); | ||
$page = $this->object; | ||
/** | ||
* @var $page Page | ||
*/ | ||
$r = $em->getRepository('\PortlandLabs\Concrete5\MigrationTool\Entity\Import\Batch'); | ||
$collection = $page->getCollection(); | ||
$batch = $r->findFromCollection($collection); | ||
|
||
// This code checks to see if the page type for the current page is being ignored globally. | ||
// If it is, then we ignore this page. | ||
$mappers = \Core::make('migration/manager/mapping'); | ||
$mapper = $mappers->driver('page_type'); | ||
$list = $mappers->createTargetItemList($batch, $mapper); | ||
$item = new Item($page->getType()); | ||
$targetItem = $list->getSelectedTargetItem($item); | ||
|
||
if ($targetItem instanceof IgnoredTargetItem) { | ||
$this->skip = true; | ||
} | ||
|
||
} | ||
|
||
public function skipItem() | ||
{ | ||
return false; | ||
return $this->skip; | ||
} | ||
} |