Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function publish(Batch $batch, $bt, Page $page, $area, BlockValue $value)
return $b;

} else {
$publisher = new StandardPublisher();
$publisher = \Core::make(StandardPublisher::class);
return $publisher->publish($batch, $bt, $page, $area, $value);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function getDefaultDriver()

public function createStandardDriver()
{
return new StandardPublisher();
return $this->app->make(StandardPublisher::class);
}

public function __construct($app)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<?php
namespace PortlandLabs\Concrete5\MigrationTool\Publisher\Block;

use Concrete\Core\Database\Connection\Connection;
use Concrete\Core\Legacy\BlockRecord;
use Doctrine\DBAL\Types\Type;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\Batch;
use PortlandLabs\Concrete5\MigrationTool\Entity\Import\BlockValue\BlockValue;
use Concrete\Core\Page\Page;
Expand All @@ -10,6 +12,14 @@

class StandardPublisher implements PublisherInterface
{
/** @var Connection */
protected $connection;

public function __construct(Connection $connection)
{
$this->connection = $connection;
}

public function publish(Batch $batch, $bt, Page $page, $area, BlockValue $value)
{
$records = $value->getRecords();
Expand All @@ -35,13 +45,23 @@ public function publish(Batch $batch, $bt, Page $page, $area, BlockValue $value)
}
// Now we import the OTHER records.
if ($b) {
$sm = $this->connection->getSchemaManager();
foreach ($records as $record) {
if (strcasecmp($record->getTable(), $bt->getController()->getBlockTypeDatabaseTable()) != 0) {
$columns = $sm->listTableColumns($record->getTable());
$aar = new BlockRecord($record->getTable());
$aar->bID = $b->getBlockID();
foreach ($record->getData() as $key => $value) {
$result = $inspector->inspect($value);
$aar->{$key} = $result->getReplacedValue();
$value = $result->getReplacedValue();
foreach ($columns as $column) {
if ($column->getName() !== $key || $column->getType()->getName() !== Type::INTEGER) {
continue;
}

$value = ($column->getNotnull() || $value !== null) ? (int) $value : null;
}
$aar->{$key} = $value;
}
$aar->Save();
}
Expand Down