Use new 4.x namespaced ORM

See https://github.com/silverstripe/silverstripe-framework/issues/5738
This commit is contained in:
Ingo Schommer 2016-07-01 16:48:12 +12:00
parent 85526e7076
commit e4a54170a1
12 changed files with 112 additions and 12 deletions

9
.upgrade.yml Normal file
View File

@ -0,0 +1,9 @@
mappings:
PostgreSQLConnector: SilverStripe\PostgreSQL\PostgreSQLConnector
PostgreSQLDatabase: SilverStripe\PostgreSQL\PostgreSQLDatabase
PostgreSQLDatabaseConfigurationHelper: SilverStripe\PostgreSQL\PostgreSQLDatabaseConfigurationHelper
PostgreSQLQuery: SilverStripe\PostgreSQL\PostgreSQLQuery
PostgreSQLQueryBuilder: SilverStripe\PostgreSQL\PostgreSQLQueryBuilder
PostgreSQLSchemaManager: SilverStripe\PostgreSQL\PostgreSQLSchemaManager
PostgreSQLConnectorTest: SilverStripe\PostgreSQL\Test\PostgreSQLConnectorTest
PostgreSQLDatabaseTest: SilverStripe\PostgreSQL\Test\PostgreSQLDatabaseTest

View File

@ -3,14 +3,21 @@ name: postgresqlconnectors
--- ---
Injector: Injector:
PostgrePDODatabase: PostgrePDODatabase:
class: 'PostgreSQLDatabase' class: 'SilverStripe\PostgreSQL\PostgreSQLDatabase'
properties: properties:
connector: %$PDOConnector connector: %$PDOConnector
schemaManager: %$PostgreSQLSchemaManager schemaManager: %$PostgreSQLSchemaManager
queryBuilder: %$PostgreSQLQueryBuilder queryBuilder: %$PostgreSQLQueryBuilder
PostgreSQLDatabase: PostgreSQLDatabase:
class: 'PostgreSQLDatabase' class: 'SilverStripe\PostgreSQL\PostgreSQLDatabase'
properties: properties:
connector: %$PostgreSQLConnector connector: %$PostgreSQLConnector
schemaManager: %$PostgreSQLSchemaManager schemaManager: %$PostgreSQLSchemaManager
queryBuilder: %$PostgreSQLQueryBuilder queryBuilder: %$PostgreSQLQueryBuilder
PostgreSQLConnector:
class: 'SilverStripe\PostgreSQL\PostgreSQLConnector'
type: prototype
PostgreSQLSchemaManager:
class: 'SilverStripe\PostgreSQL\PostgreSQLSchemaManager'
PostgreSQLQueryBuilder:
class: 'SilverStripe\PostgreSQL\PostgreSQLQueryBuilder'

View File

@ -2,7 +2,7 @@
// PDO Postgre database // PDO Postgre database
DatabaseAdapterRegistry::register(array( DatabaseAdapterRegistry::register(array(
'class' => 'PostgrePDODatabase', 'class' => 'SilverStripe\\PostgreSQL\PostgrePDODatabase',
'title' => 'PostgreSQL 8.3+ (using PDO)', 'title' => 'PostgreSQL 8.3+ (using PDO)',
'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php', 'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php',
'supported' => (class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers())), 'supported' => (class_exists('PDO') && in_array('postgresql', PDO::getAvailableDrivers())),
@ -15,7 +15,7 @@ DatabaseAdapterRegistry::register(array(
// PDO Postgre database // PDO Postgre database
DatabaseAdapterRegistry::register(array( DatabaseAdapterRegistry::register(array(
'class' => 'PostgreSQLDatabase', 'class' => 'SilverStripe\\PostgreSQL\PostgreSQLDatabase',
'title' => 'PostgreSQL 8.3+ (using pg_connect)', 'title' => 'PostgreSQL 8.3+ (using pg_connect)',
'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php', 'helperPath' => dirname(__FILE__).'/code/PostgreSQLDatabaseConfigurationHelper.php',
'supported' => function_exists('pg_connect'), 'supported' => function_exists('pg_connect'),

View File

@ -1,5 +1,13 @@
<?php <?php
namespace SilverStripe\PostgreSQL;
use ErrorException;
use SilverStripe\ORM\Connect\DBConnector;
/** /**
* PostgreSQL connector class using the PostgreSQL specific api * PostgreSQL connector class using the PostgreSQL specific api
* *

View File

@ -1,5 +1,21 @@
<?php <?php
namespace SilverStripe\PostgreSQL;
use SilverStripe\ORM\Connect\SS_Database;
use Config;
use ErrorException;
use Exception;
use PaginatedList;
use SilverStripe\ORM\DB;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\ArrayList;
/** /**
* PostgreSQL connector class. * PostgreSQL connector class.
* *
@ -35,7 +51,7 @@ class PostgreSQLDatabase extends SS_Database
*/ */
public static function default_fts_cluster_method() public static function default_fts_cluster_method()
{ {
return Config::inst()->get('PostgreSQLDatabase', 'default_fts_cluster_method'); return Config::inst()->get('SilverStripe\\PostgreSQL\\PostgreSQLDatabase', 'default_fts_cluster_method');
} }
/** /**
@ -45,7 +61,7 @@ class PostgreSQLDatabase extends SS_Database
*/ */
public static function default_fts_search_method() public static function default_fts_search_method()
{ {
return Config::inst()->get('PostgreSQLDatabase', 'default_fts_search_method'); return Config::inst()->get('SilverStripe\\PostgreSQL\\PostgreSQLDatabase', 'default_fts_search_method');
} }
/** /**
@ -61,7 +77,7 @@ class PostgreSQLDatabase extends SS_Database
*/ */
public static function allow_query_master_postgres() public static function allow_query_master_postgres()
{ {
return Config::inst()->get('PostgreSQLDatabase', 'allow_query_master_postgres'); return Config::inst()->get('SilverStripe\\PostgreSQL\\PostgreSQLDatabase', 'allow_query_master_postgres');
} }
/** /**
@ -76,7 +92,7 @@ class PostgreSQLDatabase extends SS_Database
*/ */
public static function model_schema_as_database() public static function model_schema_as_database()
{ {
return Config::inst()->get('PostgreSQLDatabase', 'model_schema_as_database'); return Config::inst()->get('SilverStripe\\PostgreSQL\\PostgreSQLDatabase', 'model_schema_as_database');
} }
/** /**
@ -88,7 +104,7 @@ class PostgreSQLDatabase extends SS_Database
*/ */
public static function search_language() public static function search_language()
{ {
return Config::inst()->get('PostgreSQLDatabase', 'search_language'); return Config::inst()->get('SilverStripe\\PostgreSQL\\PostgreSQLDatabase', 'search_language');
} }
/** /**

View File

@ -1,4 +1,12 @@
<?php <?php
namespace SilverStripe\PostgreSQL;
use DatabaseConfigurationHelper;
use PDO;
use Exception;
use DatabaseAdapterRegistry;
/** /**
* This is a helper class for the SS installer. * This is a helper class for the SS installer.
* *

View File

@ -1,8 +1,15 @@
<?php <?php
namespace SilverStripe\PostgreSQL;
use SilverStripe\ORM\Connect\SS_Query;
/** /**
* A result-set from a PostgreSQL database. * A result-set from a PostgreSQL database.
* *
* @package sapphire * @package sapphire
* @subpackage model * @subpackage model
*/ */

View File

@ -1,5 +1,15 @@
<?php <?php
namespace SilverStripe\PostgreSQL;
use InvalidArgumentException;
use SilverStripe\ORM\Queries\SQLSelect;
use SilverStripe\ORM\Connect\DBQueryBuilder;
class PostgreSQLQueryBuilder extends DBQueryBuilder class PostgreSQLQueryBuilder extends DBQueryBuilder
{ {
/** /**

View File

@ -1,8 +1,16 @@
<?php <?php
namespace SilverStripe\PostgreSQL;
use Deprecation;
use Database;
use SilverStripe\ORM\Connect\DBSchemaManager;
/** /**
* PostgreSQL schema manager * PostgreSQL schema manager
*
* @package sapphire * @package sapphire
* @subpackage model * @subpackage model
*/ */

View File

@ -16,5 +16,10 @@
"branch-alias": { "branch-alias": {
"dev-master": "2.0.x-dev" "dev-master": "2.0.x-dev"
} }
},
"autoload": {
"psr-4": {
"SilverStripe\\PostgreSQL\\": "code/"
}
} }
} }

View File

@ -1,5 +1,13 @@
<?php <?php
namespace SilverStripe\PostgreSQL\Test;
use SapphireTest;
use SilverStripe\PostgreSQL\PostgreSQLConnector;
/** /**
* Description of PostgreSQLConnectorTest * Description of PostgreSQLConnectorTest
* *

View File

@ -1,4 +1,18 @@
<?php <?php
namespace SilverStripe\PostgreSQL\Test;
use SapphireTest;
use Page;
use Exception;
use SilverStripe\ORM\DB;
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
use SilverStripe\ORM\DataObject;
/** /**
* @package postgresql * @package postgresql
* @subpackage tests * @subpackage tests