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
27 changes: 27 additions & 0 deletions bundle/Installer/CleanInstaller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace eZ\Bundle\EzPublishLegacyBundle\Installer;

class CleanInstaller extends DbBasedInstaller implements Installer
{
public function createConfiguration()
{
}

public function importSchema()
{
$this->runQueriesFromFile('ezpublish_legacy/kernel/sql/mysql/kernel_schema.sql');
$this->runQueriesFromFile('ezpublish_legacy/kernel/sql/mysql/cluster_dfs_schema.sql');
}

public function importData()
{
$this->runQueriesFromFile(
'ezpublish_legacy/kernel/sql/common/cleandata.sql'
);
}

public function importBinaries()
{
}
}
64 changes: 64 additions & 0 deletions bundle/Installer/DbBasedInstaller.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace eZ\Bundle\EzPublishLegacyBundle\Installer;

use Doctrine\DBAL\Connection;
use Symfony\Component\Filesystem\Filesystem;

class DbBasedInstaller
{
/** @var Connection */
protected $db;

/** @var \Symfony\Component\Console\Output\OutputInterface */
protected $output;

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

/**
* @param \Symfony\Component\Console\Output\OutputInterface $output
*/
public function setOutput($output)
{
$this->output = $output;
}

/**
* Copy and override configuration file.
*
* @param string $source
* @param string $target
*/
protected function copyConfigurationFile($source, $target)
{
$fs = new Filesystem();
$fs->copy($source, $target, true);

if (!$this->output->isQuiet()) {
$this->output->writeln("Copied $source to $target");
}
}

protected function runQueriesFromFile($file)
{
$queries = array_filter(preg_split('(;\\s*$)m', file_get_contents($file)));

if (!$this->output->isQuiet()) {
$this->output->writeln(
sprintf(
'Executing %d queries from %s on database %s',
count($queries),
$file,
$this->db->getDatabase()
)
);
}

foreach ($queries as $query) {
$this->db->exec($query);
}
}
}
35 changes: 35 additions & 0 deletions bundle/Installer/Installer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?php


namespace eZ\Bundle\EzPublishLegacyBundle\Installer;

/**
* Interface Installer.
*
* Simple SQL based installer interface for eZ Platform 1.0, will be replaced by a new interface in the future that
* uses API/SPI (via future import/export functionality) to support cluster and several different storage engines.
* Such change will also move responsibility of repository init (base schema and minimal data) to storage engine
* so this is not in installers. Further info: https://jira.ez.no/browse/EZP-25368
*/
interface Installer
{
/**
* Handle inserting of schema, schema should ideally be in ISO SQL format.
*/
public function importSchema();

/**
* Handle inserting of sql dump, sql dump should ideally be in ISO SQL format.
*/
public function importData();

/**
* @deprecated Inactive since 6.1, further info: https://jira.ez.no/browse/EZP-25369
*/
public function createConfiguration();

/**
* Handle optional import of binary files to var folder.
*/
public function importBinaries();
}
9 changes: 9 additions & 0 deletions bundle/Resources/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ parameters:

ezpublish_legacy.setup_listener.class: eZ\Bundle\EzPublishLegacyBundle\EventListener\SetupListener

ezpublish_legacy.installer.clean_installer.class: eZ\Bundle\EzPublishLegacyBundle\Installer\CleanInstaller

services:
ezpublish_legacy.kernel:
alias: ezpublish_legacy.kernel.lazy
Expand Down Expand Up @@ -333,3 +335,10 @@ services:
- "%ezpublish.siteaccess.default%"
tags:
- { name: kernel.event_subscriber }

ezpublish_legacy.installer.clean_installer:
class: "%ezpublish_legacy.installer.clean_installer.class%"
parent: ezplatform.installer.db_based_installer
tags:
- {name: ezplatform.installer, type: legacy_clean}

1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"require": {
"ezsystems/ezpublish-legacy": ">=2014.11",
"ezsystems/ezpublish-kernel": "~6.0@dev",
"ezsystems/ezplatform-xmltext-fieldtype": "^1.1",
"sensio/distribution-bundle": "^3.0|^4.0|^5.0",
"twig/twig": "^1.27 | ^2.0"
},
Expand Down