mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Apply Framework\ORM Namespace to model
This commit is contained in:
parent
fd9f29c515
commit
80d4af6b6e
122
.upgrade.yml
Normal file
122
.upgrade.yml
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
fileExtensions:
|
||||||
|
- php
|
||||||
|
mappings:
|
||||||
|
ArrayList: SilverStripe\ORM\ArrayList
|
||||||
|
DatabaseAdmin: SilverStripe\ORM\DatabaseAdmin
|
||||||
|
DataExtension: SilverStripe\ORM\DataExtension
|
||||||
|
DataList: SilverStripe\ORM\DataList
|
||||||
|
DataModel: SilverStripe\ORM\DataModel
|
||||||
|
DataObject: SilverStripe\ORM\DataObject
|
||||||
|
DataObjectInterface: SilverStripe\ORM\DataObjectInterface
|
||||||
|
DataObjectSchema: SilverStripe\ORM\DataObjectSchema
|
||||||
|
DataQuery: SilverStripe\ORM\DataQuery
|
||||||
|
DataQuery_SubGroup: SilverStripe\ORM\DataQuery_SubGroup
|
||||||
|
DB: SilverStripe\ORM\DB
|
||||||
|
SS_Filterable: SilverStripe\ORM\SS_Filterable
|
||||||
|
GroupedList: SilverStripe\ORM\GroupedList
|
||||||
|
HasManyList: SilverStripe\ORM\HasManyList
|
||||||
|
HiddenClass: SilverStripe\ORM\HiddenClass
|
||||||
|
SS_Limitable: SilverStripe\ORM\SS_Limitable
|
||||||
|
SS_List: SilverStripe\ORM\SS_List
|
||||||
|
SS_ListDecorator: SilverStripe\ORM\SS_ListDecorator
|
||||||
|
ManyManyList: SilverStripe\ORM\ManyManyList
|
||||||
|
SS_Map: SilverStripe\ORM\SS_Map
|
||||||
|
SS_Map_Iterator: SilverStripe\ORM\SS_Map_Iterator
|
||||||
|
PolymorphicHasManyList: SilverStripe\ORM\PolymorphicHasManyList
|
||||||
|
SilverStripe\Model\Relation: SilverStripe\ORM\Relation
|
||||||
|
RelationList: SilverStripe\ORM\RelationList
|
||||||
|
SS_Sortable: SilverStripe\ORM\SS_Sortable
|
||||||
|
UnsavedRelationList: SilverStripe\ORM\UnsavedRelationList
|
||||||
|
ValidationException: SilverStripe\ORM\ValidationException
|
||||||
|
ValidationResult: SilverStripe\ORM\ValidationResult
|
||||||
|
SQLAssignmentRow: SilverStripe\ORM\Queries\SQLAssignmentRow
|
||||||
|
SQLConditionalExpression: SilverStripe\ORM\Queries\SQLConditionalExpression
|
||||||
|
SQLConditionGroup: SilverStripe\ORM\Queries\SQLConditionGroup
|
||||||
|
SQLDelete: SilverStripe\ORM\Queries\SQLDelete
|
||||||
|
SQLExpression: SilverStripe\ORM\Queries\SQLExpression
|
||||||
|
SQLInsert: SilverStripe\ORM\Queries\SQLInsert
|
||||||
|
SQLSelect: SilverStripe\ORM\Queries\SQLSelect
|
||||||
|
SQLUpdate: SilverStripe\ORM\Queries\SQLUpdate
|
||||||
|
SQLWriteExpression: SilverStripe\ORM\Queries\SQLWriteExpression
|
||||||
|
SS_Database: SilverStripe\ORM\Connect\SS_Database
|
||||||
|
SS_DatabaseException: SilverStripe\ORM\Connect\SS_DatabaseException
|
||||||
|
DBConnector: SilverStripe\ORM\Connect\DBConnector
|
||||||
|
DBQueryBuilder: SilverStripe\ORM\Connect\DBQueryBuilder
|
||||||
|
DBSchemaManager: SilverStripe\ORM\Connect\DBSchemaManager
|
||||||
|
MySQLDatabase: SilverStripe\ORM\Connect\MySQLDatabase
|
||||||
|
MySQLiConnector: SilverStripe\ORM\Connect\MySQLiConnector
|
||||||
|
MySQLQuery: SilverStripe\ORM\Connect\MySQLQuery
|
||||||
|
MySQLQueryBuilder: SilverStripe\ORM\Connect\MySQLQueryBuilder
|
||||||
|
MySQLSchemaManager: SilverStripe\ORM\Connect\MySQLSchemaManager
|
||||||
|
MySQLStatement: SilverStripe\ORM\Connect\MySQLStatement
|
||||||
|
PDOConnector: SilverStripe\ORM\Connect\PDOConnector
|
||||||
|
PDOQuery: SilverStripe\ORM\Connect\PDOQuery
|
||||||
|
SS_Query: SilverStripe\ORM\Connect\SS_Query
|
||||||
|
DBBoolean: SilverStripe\ORM\FieldType\DBBoolean
|
||||||
|
DBClassName: SilverStripe\ORM\FieldType\DBClassName
|
||||||
|
DBComposite: SilverStripe\ORM\FieldType\DBComposite
|
||||||
|
DBCurrency: SilverStripe\ORM\FieldType\DBCurrency
|
||||||
|
DBDate: SilverStripe\ORM\FieldType\DBDate
|
||||||
|
DBDatetime: SilverStripe\ORM\FieldType\DBDatetime
|
||||||
|
DBDecimal: SilverStripe\ORM\FieldType\DBDecimal
|
||||||
|
DBDouble: SilverStripe\ORM\FieldType\DBDouble
|
||||||
|
DBEnum: SilverStripe\ORM\FieldType\DBEnum
|
||||||
|
DBField: SilverStripe\ORM\FieldType\DBField
|
||||||
|
DBFloat: SilverStripe\ORM\FieldType\DBFloat
|
||||||
|
DBForeignKey: SilverStripe\ORM\FieldType\DBForeignKey
|
||||||
|
DBHTMLText: SilverStripe\ORM\FieldType\DBHTMLText
|
||||||
|
DBHTMLVarchar: SilverStripe\ORM\FieldType\DBHTMLVarchar
|
||||||
|
DBInt: SilverStripe\ORM\FieldType\DBInt
|
||||||
|
DBLocale: SilverStripe\ORM\FieldType\DBLocale
|
||||||
|
DBMoney: SilverStripe\ORM\FieldType\DBMoney
|
||||||
|
DBMultiEnum: SilverStripe\ORM\FieldType\DBMultiEnum
|
||||||
|
DBPercentage: SilverStripe\ORM\FieldType\DBPercentage
|
||||||
|
DBPolymorphicForeignKey: SilverStripe\ORM\FieldType\DBPolymorphicForeignKey
|
||||||
|
DBPrimaryKey: SilverStripe\ORM\FieldType\DBPrimaryKey
|
||||||
|
DBString: SilverStripe\ORM\FieldType\DBString
|
||||||
|
DBText: SilverStripe\ORM\FieldType\DBText
|
||||||
|
DBTime: SilverStripe\ORM\FieldType\DBTime
|
||||||
|
DBVarchar: SilverStripe\ORM\FieldType\DBVarchar
|
||||||
|
DBYear: SilverStripe\ORM\FieldType\DBYear
|
||||||
|
SS_Datetime: SilverStripe\ORM\FieldType\DBDatetime
|
||||||
|
SilverStripe\Model\FieldType\DBBoolean: SilverStripe\ORM\FieldType\DBBoolean
|
||||||
|
SilverStripe\Model\FieldType\DBClassName: SilverStripe\ORM\FieldType\DBClassName
|
||||||
|
SilverStripe\Model\FieldType\DBComposite: SilverStripe\ORM\FieldType\DBComposite
|
||||||
|
SilverStripe\Model\FieldType\DBCurrency: SilverStripe\ORM\FieldType\DBCurrency
|
||||||
|
SilverStripe\Model\FieldType\DBDate: SilverStripe\ORM\FieldType\DBDate
|
||||||
|
SilverStripe\Model\FieldType\DBDatetime: SilverStripe\ORM\FieldType\DBDatetime
|
||||||
|
SilverStripe\Model\FieldType\DBDecimal: SilverStripe\ORM\FieldType\DBDecimal
|
||||||
|
SilverStripe\Model\FieldType\DBDouble: SilverStripe\ORM\FieldType\DBDouble
|
||||||
|
SilverStripe\Model\FieldType\DBEnum: SilverStripe\ORM\FieldType\DBEnum
|
||||||
|
SilverStripe\Model\FieldType\DBField: SilverStripe\ORM\FieldType\DBField
|
||||||
|
SilverStripe\Model\FieldType\DBFloat: SilverStripe\ORM\FieldType\DBFloat
|
||||||
|
SilverStripe\Model\FieldType\DBForeignKey: SilverStripe\ORM\FieldType\DBForeignKey
|
||||||
|
SilverStripe\Model\FieldType\DBHTMLText: SilverStripe\ORM\FieldType\DBHTMLText
|
||||||
|
SilverStripe\Model\FieldType\DBHTMLVarchar: SilverStripe\ORM\FieldType\DBHTMLVarchar
|
||||||
|
SilverStripe\Model\FieldType\DBInt: SilverStripe\ORM\FieldType\DBInt
|
||||||
|
SilverStripe\Model\FieldType\DBLocale: SilverStripe\ORM\FieldType\DBLocale
|
||||||
|
SilverStripe\Model\FieldType\DBMoney: SilverStripe\ORM\FieldType\DBMoney
|
||||||
|
SilverStripe\Model\FieldType\DBMultiEnum: SilverStripe\ORM\FieldType\DBMultiEnum
|
||||||
|
SilverStripe\Model\FieldType\DBPercentage: SilverStripe\ORM\FieldType\DBPercentage
|
||||||
|
SilverStripe\Model\FieldType\DBPolymorphicForeignKey: SilverStripe\ORM\FieldType\DBPolymorphicForeignKey
|
||||||
|
SilverStripe\Model\FieldType\DBPrimaryKey: SilverStripe\ORM\FieldType\DBPrimaryKey
|
||||||
|
SilverStripe\Model\FieldType\DBString: SilverStripe\ORM\FieldType\DBString
|
||||||
|
SilverStripe\Model\FieldType\DBText: SilverStripe\ORM\FieldType\DBText
|
||||||
|
SilverStripe\Model\FieldType\DBTime: SilverStripe\ORM\FieldType\DBTime
|
||||||
|
SilverStripe\Model\FieldType\DBVarchar: SilverStripe\ORM\FieldType\DBVarchar
|
||||||
|
SilverStripe\Model\FieldType\DBYear: SilverStripe\ORM\FieldType\DBYear
|
||||||
|
SilverStripe\Model\FieldType\SS_Datetime: SilverStripe\ORM\FieldType\DBDatetime
|
||||||
|
ChangeSet: SilverStripe\ORM\Versioning\ChangeSet
|
||||||
|
ChangeSetItem: SilverStripe\ORM\Versioning\ChangeSetItem
|
||||||
|
DataDifferencer: SilverStripe\ORM\Versioning\DataDifferencer
|
||||||
|
VersionableExtension: SilverStripe\ORM\Versioning\VersionableExtension
|
||||||
|
Versioned: SilverStripe\ORM\Versioning\Versioned
|
||||||
|
Versioned_Version: SilverStripe\ORM\Versioning\Versioned_Version
|
||||||
|
VersionedGridFieldDetailForm: SilverStripe\ORM\Versioning\VersionedGridFieldDetailForm
|
||||||
|
VersionedGridFieldItemRequest: SilverStripe\ORM\Versioning\VersionedGridFieldItemRequest
|
||||||
|
Hierarchy: SilverStripe\ORM\Hierarchy\Hierarchy
|
||||||
|
skipConfigs:
|
||||||
|
- db
|
||||||
|
- casting
|
||||||
|
- table_name
|
||||||
|
- fixed_fields
|
@ -1,4 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use ViewableData;
|
||||||
|
use ArrayData;
|
||||||
|
use ArrayIterator;
|
||||||
|
use Debug;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use LogicException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list object that wraps around an array of objects or arrays.
|
* A list object that wraps around an array of objects or arrays.
|
||||||
*
|
*
|
||||||
@ -14,7 +24,7 @@
|
|||||||
* - exclude
|
* - exclude
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
class ArrayList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
||||||
|
|
@ -1,10 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use SQLFormatter;
|
||||||
|
use Config;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an object responsible for wrapping DB connector api
|
* Represents an object responsible for wrapping DB connector api
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class DBConnector {
|
abstract class DBConnector {
|
||||||
|
|
@ -1,10 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use SilverStripe\ORM\Queries\SQLExpression;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\Queries\SQLDelete;
|
||||||
|
use SilverStripe\ORM\Queries\SQLInsert;
|
||||||
|
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||||
|
use SilverStripe\ORM\Queries\SQLConditionalExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a SQL query string from a SQLExpression object
|
* Builds a SQL query string from a SQLExpression object
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBQueryBuilder {
|
class DBQueryBuilder {
|
||||||
|
|
@ -1,10 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Config;
|
||||||
|
use Object;
|
||||||
|
use Director;
|
||||||
|
use SilverStripe\ORM\FieldType\DBPrimaryKey;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents and handles all schema management for a database
|
* Represents and handles all schema management for a database
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class DBSchemaManager {
|
abstract class DBSchemaManager {
|
||||||
|
|
||||||
@ -304,7 +312,7 @@ abstract class DBSchemaManager {
|
|||||||
$this->transCreateTable($table, $options, $extensions);
|
$this->transCreateTable($table, $options, $extensions);
|
||||||
$this->alterationMessage("Table $table: created", "created");
|
$this->alterationMessage("Table $table: created", "created");
|
||||||
} else {
|
} else {
|
||||||
if (Config::inst()->get('DBSchemaManager', 'check_and_repair_on_build')) {
|
if (Config::inst()->get('SilverStripe\ORM\Connect\DBSchemaManager', 'check_and_repair_on_build')) {
|
||||||
$this->checkAndRepairTable($table, $options);
|
$this->checkAndRepairTable($table, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -349,7 +357,7 @@ abstract class DBSchemaManager {
|
|||||||
|
|
||||||
$fieldObj->setTable($table);
|
$fieldObj->setTable($table);
|
||||||
|
|
||||||
if($fieldObj instanceof PrimaryKey) {
|
if($fieldObj instanceof DBPrimaryKey) {
|
||||||
$fieldObj->setAutoIncrement($hasAutoIncPK);
|
$fieldObj->setAutoIncrement($hasAutoIncPK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -940,4 +948,101 @@ abstract class DBSchemaManager {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'boolean' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function boolean($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'date' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function date($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'decimal' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function decimal($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'set' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function enum($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'set' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function set($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'float' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function float($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'int' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function int($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'datetime' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function datetime($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'text' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function text($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'time' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function time($values);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns data type for 'varchar' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function varchar($values);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns data type for 'year' column
|
||||||
|
*
|
||||||
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
abstract public function year($values);
|
||||||
|
|
||||||
}
|
}
|
@ -1,11 +1,22 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use Director;
|
||||||
|
use Debug;
|
||||||
|
use BadMethodCallException;
|
||||||
|
use Exception;
|
||||||
|
use Deprecation;
|
||||||
|
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||||
|
use SilverStripe\ORM\Queries\SQLInsert;
|
||||||
|
use SilverStripe\ORM\Queries\SQLExpression;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract database connectivity class.
|
* Abstract database connectivity class.
|
||||||
* Sub-classes of this implement the actual database connection libraries
|
* Sub-classes of this implement the actual database connection libraries
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class SS_Database {
|
abstract class SS_Database {
|
||||||
|
|
@ -1,10 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error class for database exceptions
|
* Error class for database exceptions
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SS_DatabaseException extends Exception {
|
class SS_DatabaseException extends Exception {
|
||||||
|
|
@ -1,12 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use Exception;
|
||||||
|
use PaginatedList;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MySQL connector class.
|
* MySQL connector class.
|
||||||
*
|
*
|
||||||
* Supported indexes for {@link requireTable()}:
|
* Supported indexes for {@link requireTable()}:
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class MySQLDatabase extends SS_Database {
|
class MySQLDatabase extends SS_Database {
|
||||||
|
|
||||||
@ -26,14 +34,14 @@ class MySQLDatabase extends SS_Database {
|
|||||||
|
|
||||||
// Set charset
|
// Set charset
|
||||||
if( empty($parameters['charset'])
|
if( empty($parameters['charset'])
|
||||||
&& ($charset = Config::inst()->get('MySQLDatabase', 'connection_charset'))
|
&& ($charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_charset'))
|
||||||
) {
|
) {
|
||||||
$parameters['charset'] = $charset;
|
$parameters['charset'] = $charset;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set collation
|
// Set collation
|
||||||
if( empty($parameters['collation'])
|
if( empty($parameters['collation'])
|
||||||
&& ($collation = Config::inst()->get('MySQLDatabase', 'connection_collation'))
|
&& ($collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_collation'))
|
||||||
) {
|
) {
|
||||||
$parameters['collation'] = $collation;
|
$parameters['collation'] = $collation;
|
||||||
}
|
}
|
||||||
@ -158,7 +166,7 @@ class MySQLDatabase extends SS_Database {
|
|||||||
$baseClasses[$class] = '"' . $class . '"';
|
$baseClasses[$class] = '"' . $class . '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
|
|
||||||
// Make column selection lists
|
// Make column selection lists
|
||||||
$select = array(
|
$select = array(
|
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A result-set from a MySQL database (using MySQLiConnector)
|
* A result-set from a MySQL database (using MySQLiConnector)
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class MySQLQuery extends SS_Query {
|
class MySQLQuery extends SS_Query {
|
||||||
|
|
@ -1,10 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds a SQL query string from a SQLExpression object
|
* Builds a SQL query string from a SQLExpression object
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class MySQLQueryBuilder extends DBQueryBuilder {
|
class MySQLQueryBuilder extends DBQueryBuilder {
|
||||||
|
|
@ -1,10 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use Convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents schema management object for MySQL
|
* Represents schema management object for MySQL
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class MySQLSchemaManager extends DBSchemaManager {
|
class MySQLSchemaManager extends DBSchemaManager {
|
||||||
|
|
||||||
@ -12,7 +17,7 @@ class MySQLSchemaManager extends DBSchemaManager {
|
|||||||
* Identifier for this schema, used for configuring schema-specific table
|
* Identifier for this schema, used for configuring schema-specific table
|
||||||
* creation options
|
* creation options
|
||||||
*/
|
*/
|
||||||
const ID = 'MySQLDatabase';
|
const ID = 'SilverStripe\ORM\Connect\MySQLDatabase';
|
||||||
|
|
||||||
public function createTable($table, $fields = null, $indexes = null, $options = null, $advancedOptions = null) {
|
public function createTable($table, $fields = null, $indexes = null, $options = null, $advancedOptions = null) {
|
||||||
$fieldSchemas = $indexSchemas = "";
|
$fieldSchemas = $indexSchemas = "";
|
||||||
@ -195,8 +200,8 @@ class MySQLSchemaManager extends DBSchemaManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function createDatabase($name) {
|
public function createDatabase($name) {
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
$this->query("CREATE DATABASE \"$name\" DEFAULT CHARACTER SET {$charset} DEFAULT COLLATE {$collation}");
|
$this->query("CREATE DATABASE \"$name\" DEFAULT CHARACTER SET {$charset} DEFAULT COLLATE {$collation}");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -436,8 +441,8 @@ class MySQLSchemaManager extends DBSchemaManager {
|
|||||||
//DB::requireField($this->tableName, $this->name, "enum('" . implode("','", $this->enum) . "') character set
|
//DB::requireField($this->tableName, $this->name, "enum('" . implode("','", $this->enum) . "') character set
|
||||||
// utf8 collate utf8_general_ci default '{$this->default}'");
|
// utf8 collate utf8_general_ci default '{$this->default}'");
|
||||||
$valuesString = implode(",", Convert::raw2sql($values['enums'], true));
|
$valuesString = implode(",", Convert::raw2sql($values['enums'], true));
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
return "enum($valuesString) character set {$charset} collate {$collation}" . $this->defaultClause($values);
|
return "enum($valuesString) character set {$charset} collate {$collation}" . $this->defaultClause($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -454,8 +459,8 @@ class MySQLSchemaManager extends DBSchemaManager {
|
|||||||
//DB::requireField($this->tableName, $this->name, "enum('" . implode("','", $this->enum) . "') character set
|
//DB::requireField($this->tableName, $this->name, "enum('" . implode("','", $this->enum) . "') character set
|
||||||
//utf8 collate utf8_general_ci default '{$this->default}'");
|
//utf8 collate utf8_general_ci default '{$this->default}'");
|
||||||
$valuesString = implode(",", Convert::raw2sql($values['enums'], true));
|
$valuesString = implode(",", Convert::raw2sql($values['enums'], true));
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
return "set($valuesString) character set {$charset} collate {$collation}" . $this->defaultClause($values);
|
return "set($valuesString) character set {$charset} collate {$collation}" . $this->defaultClause($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +498,7 @@ class MySQLSchemaManager extends DBSchemaManager {
|
|||||||
* @param array $values Contains a tokenised list of info about this data type
|
* @param array $values Contains a tokenised list of info about this data type
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function ss_datetime($values) {
|
public function datetime($values) {
|
||||||
//For reference, this is what typically gets passed to this function:
|
//For reference, this is what typically gets passed to this function:
|
||||||
//$parts=Array('datatype'=>'datetime');
|
//$parts=Array('datatype'=>'datetime');
|
||||||
//DB::requireField($this->tableName, $this->name, $values);
|
//DB::requireField($this->tableName, $this->name, $values);
|
||||||
@ -510,8 +515,8 @@ class MySQLSchemaManager extends DBSchemaManager {
|
|||||||
//For reference, this is what typically gets passed to this function:
|
//For reference, this is what typically gets passed to this function:
|
||||||
//$parts=Array('datatype'=>'mediumtext', 'character set'=>'utf8', 'collate'=>'utf8_general_ci');
|
//$parts=Array('datatype'=>'mediumtext', 'character set'=>'utf8', 'collate'=>'utf8_general_ci');
|
||||||
//DB::requireField($this->tableName, $this->name, "mediumtext character set utf8 collate utf8_general_ci");
|
//DB::requireField($this->tableName, $this->name, "mediumtext character set utf8 collate utf8_general_ci");
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
return 'mediumtext character set ' . $charset . ' collate ' . $collation . $this->defaultClause($values);
|
return 'mediumtext character set ' . $charset . ' collate ' . $collation . $this->defaultClause($values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -542,8 +547,8 @@ class MySQLSchemaManager extends DBSchemaManager {
|
|||||||
//DB::requireField($this->tableName, $this->name, "varchar($this->size) character set utf8 collate
|
//DB::requireField($this->tableName, $this->name, "varchar($this->size) character set utf8 collate
|
||||||
// utf8_general_ci");
|
// utf8_general_ci");
|
||||||
$default = $this->defaultClause($values);
|
$default = $this->defaultClause($values);
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
return "varchar({$values['precision']}) character set {$charset} collate {$collation}{$default}";
|
return "varchar({$values['precision']}) character set {$charset} collate {$collation}{$default}";
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a record-view for mysqli statements
|
* Provides a record-view for mysqli statements
|
||||||
*
|
*
|
||||||
@ -7,7 +9,7 @@
|
|||||||
* buffer itself and sacrifice any potential performance benefit.
|
* buffer itself and sacrifice any potential performance benefit.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class MySQLStatement extends SS_Query {
|
class MySQLStatement extends SS_Query {
|
||||||
|
|
@ -1,9 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use MySQLi;
|
||||||
|
use mysqli_stmt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Connector for MySQL using the MySQLi method
|
* Connector for MySQL using the MySQLi method
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class MySQLiConnector extends DBConnector {
|
class MySQLiConnector extends DBConnector {
|
||||||
|
|
||||||
@ -57,8 +63,8 @@ class MySQLiConnector extends DBConnector {
|
|||||||
$selectedDB = ($selectDB && !empty($parameters['database'])) ? $parameters['database'] : null;
|
$selectedDB = ($selectDB && !empty($parameters['database'])) ? $parameters['database'] : null;
|
||||||
|
|
||||||
// Connection charset and collation
|
// Connection charset and collation
|
||||||
$connCharset = Config::inst()->get('MySQLDatabase', 'connection_charset');
|
$connCharset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_charset');
|
||||||
$connCollation = Config::inst()->get('MySQLDatabase', 'connection_collation');
|
$connCollation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_collation');
|
||||||
|
|
||||||
if(!empty($parameters['port'])) {
|
if(!empty($parameters['port'])) {
|
||||||
$this->dbConn = new MySQLi(
|
$this->dbConn = new MySQLi(
|
@ -1,9 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use PDO;
|
||||||
|
use Config;
|
||||||
|
use PDOStatement;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PDO driver database connector
|
* PDO driver database connector
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class PDOConnector extends DBConnector {
|
class PDOConnector extends DBConnector {
|
||||||
|
|
||||||
@ -89,7 +95,7 @@ class PDOConnector extends DBConnector {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static function is_emulate_prepare() {
|
public static function is_emulate_prepare() {
|
||||||
return Config::inst()->get('PDOConnector', 'emulate_prepare');
|
return Config::inst()->get('SilverStripe\ORM\Connect\PDOConnector', 'emulate_prepare');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function connect($parameters, $selectDB = false) {
|
public function connect($parameters, $selectDB = false) {
|
||||||
@ -135,8 +141,8 @@ class PDOConnector extends DBConnector {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Connection charset and collation
|
// Connection charset and collation
|
||||||
$connCharset = Config::inst()->get('MySQLDatabase', 'connection_charset');
|
$connCharset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_charset');
|
||||||
$connCollation = Config::inst()->get('MySQLDatabase', 'connection_collation');
|
$connCollation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'connection_collation');
|
||||||
|
|
||||||
// Set charset if given and not null. Can explicitly set to empty string to omit
|
// Set charset if given and not null. Can explicitly set to empty string to omit
|
||||||
if($parameters['driver'] !== 'sqlsrv') {
|
if($parameters['driver'] !== 'sqlsrv') {
|
@ -1,9 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use PDOStatement;
|
||||||
|
use PDO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A result-set from a PDO database.
|
* A result-set from a PDO database.
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class PDOQuery extends SS_Query {
|
class PDOQuery extends SS_Query {
|
||||||
/**
|
/**
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Connect;
|
||||||
|
|
||||||
|
use Iterator;
|
||||||
|
use Convert;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract query-result class.
|
* Abstract query-result class.
|
||||||
* Once again, this should be subclassed by an actual database implementation. It will only
|
* Once again, this should be subclassed by an actual database implementation. It will only
|
||||||
@ -10,7 +15,7 @@
|
|||||||
* on providing the specific data-access methods that are required: {@link nextRecord()}, {@link numRecords()}
|
* on providing the specific data-access methods that are required: {@link nextRecord()}, {@link numRecords()}
|
||||||
* and {@link seek()}
|
* and {@link seek()}
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class SS_Query implements Iterator {
|
abstract class SS_Query implements Iterator {
|
||||||
|
|
@ -1,10 +1,23 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Deprecation;
|
||||||
|
use Director;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Config;
|
||||||
|
use LogicException;
|
||||||
|
use Cookie;
|
||||||
|
use Injector;
|
||||||
|
use SilverStripe\ORM\Queries\SQLExpression;
|
||||||
|
use SilverStripe\ORM\Connect\SS_Database;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global database interface, complete with static methods.
|
* Global database interface, complete with static methods.
|
||||||
* Use this class for interacting with the database.
|
* Use this class for interacting with the database.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DB {
|
class DB {
|
||||||
|
|
@ -1,11 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Extension;
|
||||||
|
use Exception;
|
||||||
|
use FieldList;
|
||||||
|
use Config;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An extension that adds additional functionality to a {@link DataObject}.
|
* An extension that adds additional functionality to a {@link DataObject}.
|
||||||
*
|
*
|
||||||
* @property DataObject $owner
|
* @property DataObject $owner
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class DataExtension extends Extension {
|
abstract class DataExtension extends Extension {
|
||||||
|
|
@ -1,4 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use ViewableData;
|
||||||
|
use Exception;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Injector;
|
||||||
|
use LogicException;
|
||||||
|
use Debug;
|
||||||
|
use ArrayIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implements a "lazy loading" DataObjectSet.
|
* Implements a "lazy loading" DataObjectSet.
|
||||||
* Uses {@link DataQuery} to do the actual query generation.
|
* Uses {@link DataQuery} to do the actual query generation.
|
||||||
@ -20,7 +31,7 @@
|
|||||||
* Subclasses of DataList may add other methods that have the same effect.
|
* Subclasses of DataList may add other methods that have the same effect.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
class DataList extends ViewableData implements SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
||||||
/**
|
/**
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Representation of a DataModel - a collection of DataLists for each different
|
* Representation of a DataModel - a collection of DataLists for each different
|
||||||
* data type.
|
* data type.
|
||||||
@ -11,7 +13,7 @@
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DataModel {
|
class DataModel {
|
||||||
|
|
@ -1,9 +1,35 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
namespace SilverStripe\ORM;
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
use SilverStripe\Model\FieldType\DBComposite;
|
use ViewableData;
|
||||||
use SilverStripe\Model\FieldType\DBClassName;
|
use i18nEntityProvider;
|
||||||
|
use Injector;
|
||||||
|
use HTTP;
|
||||||
|
use ClassInfo;
|
||||||
|
use i18n;
|
||||||
|
use Deprecation;
|
||||||
|
use Config;
|
||||||
|
use Debug;
|
||||||
|
use LogicException;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use BadMethodCallException;
|
||||||
|
use Exception;
|
||||||
|
use SearchContext;
|
||||||
|
use FieldList;
|
||||||
|
use FormField;
|
||||||
|
use FormScaffolder;
|
||||||
|
use Member;
|
||||||
|
use Permission;
|
||||||
|
use Object;
|
||||||
|
use SearchFilter;
|
||||||
|
use SilverStripe\ORM\Queries\SQLInsert;
|
||||||
|
use SilverStripe\ORM\Queries\SQLDelete;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\FieldType\DBComposite;
|
||||||
|
use SilverStripe\ORM\FieldType\DBClassName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single database record & abstract class for the data-access-model.
|
* A single database record & abstract class for the data-access-model.
|
||||||
@ -70,7 +96,7 @@ use SilverStripe\Model\FieldType\DBClassName;
|
|||||||
* and defineMethods()
|
* and defineMethods()
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*
|
*
|
||||||
* @property integer ID ID of the DataObject, 0 if the DataObject doesn't exist in database.
|
* @property integer ID ID of the DataObject, 0 if the DataObject doesn't exist in database.
|
||||||
* @property string ClassName Class name of the DataObject
|
* @property string ClassName Class name of the DataObject
|
||||||
@ -204,8 +230,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
private static $fixed_fields = array(
|
private static $fixed_fields = array(
|
||||||
'ID' => 'PrimaryKey',
|
'ID' => 'PrimaryKey',
|
||||||
'ClassName' => 'DBClassName',
|
'ClassName' => 'DBClassName',
|
||||||
'LastEdited' => 'SS_Datetime',
|
'LastEdited' => 'DBDatetime',
|
||||||
'Created' => 'SS_Datetime',
|
'Created' => 'DBDatetime',
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -243,7 +269,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @return DataObjectSchema
|
* @return DataObjectSchema
|
||||||
*/
|
*/
|
||||||
public static function getSchema() {
|
public static function getSchema() {
|
||||||
return Injector::inst()->get('DataObjectSchema');
|
return Injector::inst()->get('SilverStripe\ORM\DataObjectSchema');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -381,7 +407,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
// Identify fields that should be lazy loaded, but only on existing records
|
// Identify fields that should be lazy loaded, but only on existing records
|
||||||
if(!empty($record['ID'])) {
|
if(!empty($record['ID'])) {
|
||||||
$currentObj = get_class($this);
|
$currentObj = get_class($this);
|
||||||
while($currentObj != 'DataObject') {
|
while($currentObj != 'SilverStripe\ORM\DataObject') {
|
||||||
$fields = self::custom_database_fields($currentObj);
|
$fields = self::custom_database_fields($currentObj);
|
||||||
foreach($fields as $field => $type) {
|
foreach($fields as $field => $type) {
|
||||||
if(!array_key_exists($field, $record)) $this->record[$field.'_Lazy'] = $currentObj;
|
if(!array_key_exists($field, $record)) $this->record[$field.'_Lazy'] = $currentObj;
|
||||||
@ -528,7 +554,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*/
|
*/
|
||||||
public function setClassName($className) {
|
public function setClassName($className) {
|
||||||
$className = trim($className);
|
$className = trim($className);
|
||||||
if(!$className || !is_subclass_of($className, 'DataObject')) return;
|
if(!$className || !is_subclass_of($className, 'SilverStripe\ORM\DataObject')) return;
|
||||||
|
|
||||||
$this->class = $className;
|
$this->class = $className;
|
||||||
$this->setField("ClassName", $className);
|
$this->setField("ClassName", $className);
|
||||||
@ -589,7 +615,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->class == 'DataObject') return;
|
if($this->class == 'SilverStripe\ORM\DataObject') return;
|
||||||
|
|
||||||
// Set up accessors for joined items
|
// Set up accessors for joined items
|
||||||
if($manyMany = $this->manyMany()) {
|
if($manyMany = $this->manyMany()) {
|
||||||
@ -677,7 +703,8 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
*/
|
*/
|
||||||
public function singular_name() {
|
public function singular_name() {
|
||||||
if(!$name = $this->stat('singular_name')) {
|
if(!$name = $this->stat('singular_name')) {
|
||||||
$name = ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $this->class))));
|
$reflection = new \ReflectionClass($this);
|
||||||
|
$name = ucwords(trim(strtolower(preg_replace('/_?([A-Z])/', ' $1', $reflection->getShortName()))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $name;
|
return $name;
|
||||||
@ -1098,7 +1125,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
$manyManyJoin->setByIdList($fieldValue);
|
$manyManyJoin->setByIdList($fieldValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($class == 'DataObject') {
|
if($class == 'SilverStripe\ORM\DataObject') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1121,7 +1148,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Config::inst()->get('DataObject', 'validation_enabled')) {
|
if(Config::inst()->get('SilverStripe\ORM\DataObject', 'validation_enabled')) {
|
||||||
$result = $this->validate();
|
$result = $this->validate();
|
||||||
if (!$result->valid()) {
|
if (!$result->valid()) {
|
||||||
return new ValidationException(
|
return new ValidationException(
|
||||||
@ -1455,7 +1482,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
$joinID = $this->getField($joinField);
|
$joinID = $this->getField($joinField);
|
||||||
|
|
||||||
// Extract class name for polymorphic relations
|
// Extract class name for polymorphic relations
|
||||||
if($class === 'DataObject') {
|
if($class === 'SilverStripe\ORM\DataObject') {
|
||||||
$class = $this->getField($componentName . 'Class');
|
$class = $this->getField($componentName . 'Class');
|
||||||
if(empty($class)) return null;
|
if(empty($class)) return null;
|
||||||
}
|
}
|
||||||
@ -1640,7 +1667,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
$remoteRelation
|
$remoteRelation
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
if($class === 'DataObject') {
|
if($class === 'SilverStripe\ORM\DataObject') {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new InvalidArgumentException(sprintf(
|
||||||
"%s cannot generate opposite component of relation %s.%s as it is polymorphic. " .
|
"%s cannot generate opposite component of relation %s.%s as it is polymorphic. " .
|
||||||
"This method does not support polymorphic relationships",
|
"This method does not support polymorphic relationships",
|
||||||
@ -1795,7 +1822,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Inspect resulting found relation
|
// Inspect resulting found relation
|
||||||
if($remoteRelations[$remoteField] === 'DataObject') {
|
if($remoteRelations[$remoteField] === 'SilverStripe\ORM\DataObject') {
|
||||||
$polymorphic = true;
|
$polymorphic = true;
|
||||||
return $remoteField; // Composite polymorphic field does not include 'ID' suffix
|
return $remoteField; // Composite polymorphic field does not include 'ID' suffix
|
||||||
} else {
|
} else {
|
||||||
@ -2737,7 +2764,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function has_own_table($dataClass) {
|
public static function has_own_table($dataClass) {
|
||||||
if(!is_subclass_of($dataClass, 'DataObject')) {
|
if(!is_subclass_of($dataClass, 'SilverStripe\ORM\DataObject')) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$fields = static::database_fields($dataClass);
|
$fields = static::database_fields($dataClass);
|
||||||
@ -3069,15 +3096,15 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @return DataList The objects matching the filter, in the class specified by $containerClass
|
* @return DataList The objects matching the filter, in the class specified by $containerClass
|
||||||
*/
|
*/
|
||||||
public static function get($callerClass = null, $filter = "", $sort = "", $join = "", $limit = null,
|
public static function get($callerClass = null, $filter = "", $sort = "", $join = "", $limit = null,
|
||||||
$containerClass = 'DataList') {
|
$containerClass = 'SilverStripe\ORM\DataList') {
|
||||||
|
|
||||||
if($callerClass == null) {
|
if($callerClass == null) {
|
||||||
$callerClass = get_called_class();
|
$callerClass = get_called_class();
|
||||||
if($callerClass == 'DataObject') {
|
if($callerClass == 'SilverStripe\ORM\DataObject') {
|
||||||
throw new \InvalidArgumentException('Call <classname>::get() instead of DataObject::get()');
|
throw new \InvalidArgumentException('Call <classname>::get() instead of DataObject::get()');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($filter || $sort || $join || $limit || ($containerClass != 'DataList')) {
|
if($filter || $sort || $join || $limit || ($containerClass != 'SilverStripe\ORM\DataList')) {
|
||||||
throw new \InvalidArgumentException('If calling <classname>::get() then you shouldn\'t pass any other'
|
throw new \InvalidArgumentException('If calling <classname>::get() then you shouldn\'t pass any other'
|
||||||
. ' arguments');
|
. ' arguments');
|
||||||
}
|
}
|
||||||
@ -3155,7 +3182,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @return DataObject $this
|
* @return DataObject $this
|
||||||
*/
|
*/
|
||||||
public function flushCache($persistent = true) {
|
public function flushCache($persistent = true) {
|
||||||
if($this->class == 'DataObject') {
|
if($this->class == 'SilverStripe\ORM\DataObject') {
|
||||||
self::$_cache_get_one = array();
|
self::$_cache_get_one = array();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
@ -3314,7 +3341,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(get_parent_class($this) == "DataObject") {
|
if(get_parent_class($this) == 'SilverStripe\ORM\DataObject') {
|
||||||
$indexes['ClassName'] = true;
|
$indexes['ClassName'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3337,7 +3364,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
// Validate relationship configuration
|
// Validate relationship configuration
|
||||||
$this->validateModelDefinitions();
|
$this->validateModelDefinitions();
|
||||||
if($fields) {
|
if($fields) {
|
||||||
$hasAutoIncPK = get_parent_class($this) === 'DataObject';
|
$hasAutoIncPK = get_parent_class($this) === 'SilverStripe\ORM\DataObject';
|
||||||
DB::require_table(
|
DB::require_table(
|
||||||
$table, $fields, $indexes, $hasAutoIncPK, $this->stat('create_table_options'), $extensions
|
$table, $fields, $indexes, $hasAutoIncPK, $this->stat('create_table_options'), $extensions
|
||||||
);
|
);
|
||||||
@ -3730,7 +3757,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
|||||||
* @config
|
* @config
|
||||||
*/
|
*/
|
||||||
private static $create_table_options = array(
|
private static $create_table_options = array(
|
||||||
'MySQLDatabase' => 'ENGINE=InnoDB'
|
'SilverStripe\ORM\Connect\MySQLDatabase' => 'ENGINE=InnoDB'
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
@ -1,11 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataObjectInterface is an interface that other data systems in your application can implement in order to behave in
|
* DataObjectInterface is an interface that other data systems in your application can implement in order to behave in
|
||||||
* a manner similar to DataObject.
|
* a manner similar to DataObject.
|
||||||
*
|
*
|
||||||
* In addition to the methods defined below, the data of the object should be directly accessible as fields.
|
* In addition to the methods defined below, the data of the object should be directly accessible as fields.
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface DataObjectInterface {
|
interface DataObjectInterface {
|
||||||
/**
|
/**
|
@ -1,8 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use ClassInfo;
|
||||||
|
use LogicException;
|
||||||
|
use Config;
|
||||||
|
use Object;
|
||||||
use SilverStripe\Framework\Core\Configurable;
|
use SilverStripe\Framework\Core\Configurable;
|
||||||
use SilverStripe\Framework\Core\Injectable;
|
use SilverStripe\Framework\Core\Injectable;
|
||||||
use SilverStripe\Model\FieldType\DBComposite;
|
use SilverStripe\ORM\FieldType\DBComposite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides dataobject and database schema mapping functionality
|
* Provides dataobject and database schema mapping functionality
|
||||||
@ -110,7 +117,7 @@ class DataObjectSchema {
|
|||||||
$class = ClassInfo::class_name($class);
|
$class = ClassInfo::class_name($class);
|
||||||
$current = $class;
|
$current = $class;
|
||||||
while ($next = get_parent_class($current)) {
|
while ($next = get_parent_class($current)) {
|
||||||
if ($next === 'DataObject') {
|
if ($next === 'SilverStripe\ORM\DataObject') {
|
||||||
return $current;
|
return $current;
|
||||||
}
|
}
|
||||||
$current = $next;
|
$current = $next;
|
||||||
@ -161,8 +168,8 @@ class DataObjectSchema {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$this->tableNames = [];
|
$this->tableNames = [];
|
||||||
foreach(ClassInfo::subclassesFor('DataObject') as $class) {
|
foreach(ClassInfo::subclassesFor('SilverStripe\ORM\DataObject') as $class) {
|
||||||
if($class === 'DataObject') {
|
if($class === 'SilverStripe\ORM\DataObject') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$table = $this->buildTableName($class);
|
$table = $this->buildTableName($class);
|
||||||
@ -208,7 +215,7 @@ class DataObjectSchema {
|
|||||||
*/
|
*/
|
||||||
public function databaseFields($class) {
|
public function databaseFields($class) {
|
||||||
$class = ClassInfo::class_name($class);
|
$class = ClassInfo::class_name($class);
|
||||||
if($class === 'DataObject') {
|
if($class === 'SilverStripe\ORM\DataObject') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$this->cacheDatabaseFields($class);
|
$this->cacheDatabaseFields($class);
|
||||||
@ -230,7 +237,7 @@ class DataObjectSchema {
|
|||||||
*/
|
*/
|
||||||
public function compositeFields($class, $aggregated = true) {
|
public function compositeFields($class, $aggregated = true) {
|
||||||
$class = ClassInfo::class_name($class);
|
$class = ClassInfo::class_name($class);
|
||||||
if($class === 'DataObject') {
|
if($class === 'SilverStripe\ORM\DataObject') {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
$this->cacheDatabaseFields($class);
|
$this->cacheDatabaseFields($class);
|
||||||
@ -262,7 +269,7 @@ class DataObjectSchema {
|
|||||||
|
|
||||||
// Ensure fixed fields appear at the start
|
// Ensure fixed fields appear at the start
|
||||||
$fixedFields = DataObject::config()->fixed_fields;
|
$fixedFields = DataObject::config()->fixed_fields;
|
||||||
if(get_parent_class($class) === 'DataObject') {
|
if(get_parent_class($class) === 'SilverStripe\ORM\DataObject') {
|
||||||
// Merge fixed with ClassName spec and custom db fields
|
// Merge fixed with ClassName spec and custom db fields
|
||||||
$dbFields = $fixedFields;
|
$dbFields = $fixedFields;
|
||||||
} else {
|
} else {
|
||||||
@ -283,7 +290,7 @@ class DataObjectSchema {
|
|||||||
// Add in all has_ones
|
// Add in all has_ones
|
||||||
$hasOne = Config::inst()->get($class, 'has_one', Config::UNINHERITED) ?: array();
|
$hasOne = Config::inst()->get($class, 'has_one', Config::UNINHERITED) ?: array();
|
||||||
foreach($hasOne as $fieldName => $hasOneClass) {
|
foreach($hasOne as $fieldName => $hasOneClass) {
|
||||||
if($hasOneClass === 'DataObject') {
|
if($hasOneClass === 'SilverStripe\ORM\DataObject') {
|
||||||
$compositeFields[$fieldName] = 'PolymorphicForeignKey';
|
$compositeFields[$fieldName] = 'PolymorphicForeignKey';
|
||||||
} else {
|
} else {
|
||||||
$dbFields["{$fieldName}ID"] = 'ForeignKey';
|
$dbFields["{$fieldName}ID"] = 'ForeignKey';
|
||||||
@ -339,7 +346,7 @@ class DataObjectSchema {
|
|||||||
public function classForField($candidateClass, $fieldName) {
|
public function classForField($candidateClass, $fieldName) {
|
||||||
// normalise class name
|
// normalise class name
|
||||||
$candidateClass = ClassInfo::class_name($candidateClass);
|
$candidateClass = ClassInfo::class_name($candidateClass);
|
||||||
if($candidateClass === 'DataObject') {
|
if($candidateClass === 'SilverStripe\ORM\DataObject') {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Injector;
|
||||||
|
use ClassInfo;
|
||||||
|
use Convert;
|
||||||
|
use Object;
|
||||||
|
use SilverStripe\ORM\Queries\SQLConditionGroup;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object representing a query of data from the DataObject's supporting database.
|
* An object representing a query of data from the DataObject's supporting database.
|
||||||
* Acts as a wrapper over {@link SQLSelect} and performs all of the query generation.
|
* Acts as a wrapper over {@link SQLSelect} and performs all of the query generation.
|
||||||
@ -8,7 +18,7 @@
|
|||||||
* Unlike DataList, modifiers on DataQuery modify the object rather than returning a clone.
|
* Unlike DataList, modifiers on DataQuery modify the object rather than returning a clone.
|
||||||
* DataList is immutable, DataQuery is mutable.
|
* DataList is immutable, DataQuery is mutable.
|
||||||
*
|
*
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
* @package framework
|
* @package framework
|
||||||
*/
|
*/
|
||||||
class DataQuery {
|
class DataQuery {
|
||||||
@ -752,7 +762,7 @@ class DataQuery {
|
|||||||
throw new InvalidArgumentException("Could not find a has_one relationship {$localField} on {$localClass}");
|
throw new InvalidArgumentException("Could not find a has_one relationship {$localField} on {$localClass}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($foreignClass === 'DataObject') {
|
if ($foreignClass === 'SilverStripe\ORM\DataObject') {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
"Could not join polymorphic has_one relationship {$localField} on {$localClass}"
|
"Could not join polymorphic has_one relationship {$localField} on {$localClass}"
|
||||||
);
|
);
|
||||||
@ -797,7 +807,7 @@ class DataQuery {
|
|||||||
* @param string $foreignClass Class to join
|
* @param string $foreignClass Class to join
|
||||||
*/
|
*/
|
||||||
protected function joinHasManyRelation($localClass, $localField, $foreignClass) {
|
protected function joinHasManyRelation($localClass, $localField, $foreignClass) {
|
||||||
if(!$foreignClass || $foreignClass === 'DataObject') {
|
if(!$foreignClass || $foreignClass === 'SilverStripe\ORM\DataObject') {
|
||||||
throw new InvalidArgumentException("Could not find a has_many relationship {$localField} on {$localClass}");
|
throw new InvalidArgumentException("Could not find a has_many relationship {$localField} on {$localClass}");
|
||||||
}
|
}
|
||||||
$schema = DataObject::getSchema();
|
$schema = DataObject::getSchema();
|
@ -1,6 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Controller;
|
||||||
|
use SapphireTest;
|
||||||
|
use Director;
|
||||||
|
use Security;
|
||||||
|
use Permission;
|
||||||
|
use SS_ClassLoader;
|
||||||
|
use ClassInfo;
|
||||||
|
use TestOnly;
|
||||||
|
use Deprecation;
|
||||||
|
|
||||||
// Include the DB class
|
// Include the DB class
|
||||||
require_once("model/DB.php");
|
require_once("DB.php");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DatabaseAdmin class
|
* DatabaseAdmin class
|
||||||
@ -9,7 +22,7 @@ require_once("model/DB.php");
|
|||||||
* via URL, e.g. http://www.yourdomain.com/db/build.
|
* via URL, e.g. http://www.yourdomain.com/db/build.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DatabaseAdmin extends Controller {
|
class DatabaseAdmin extends Controller {
|
||||||
|
|
||||||
@ -53,13 +66,13 @@ class DatabaseAdmin extends Controller {
|
|||||||
// Get all root data objects
|
// Get all root data objects
|
||||||
$allClasses = get_declared_classes();
|
$allClasses = get_declared_classes();
|
||||||
foreach($allClasses as $class) {
|
foreach($allClasses as $class) {
|
||||||
if(get_parent_class($class) == "DataObject")
|
if(get_parent_class($class) == 'SilverStripe\ORM\DataObject')
|
||||||
$rootClasses[$class] = array();
|
$rootClasses[$class] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assign every other data object one of those
|
// Assign every other data object one of those
|
||||||
foreach($allClasses as $class) {
|
foreach($allClasses as $class) {
|
||||||
if(!isset($rootClasses[$class]) && is_subclass_of($class, "DataObject")) {
|
if(!isset($rootClasses[$class]) && is_subclass_of($class, 'SilverStripe\ORM\DataObject')) {
|
||||||
foreach($rootClasses as $rootClass => $dummy) {
|
foreach($rootClasses as $rootClass => $dummy) {
|
||||||
if(is_subclass_of($class, $rootClass)) {
|
if(is_subclass_of($class, $rootClass)) {
|
||||||
$rootClasses[$rootClass][] = $class;
|
$rootClasses[$rootClass][] = $class;
|
||||||
@ -125,7 +138,7 @@ class DatabaseAdmin extends Controller {
|
|||||||
* Check if database needs to be built, and build it if it does.
|
* Check if database needs to be built, and build it if it does.
|
||||||
*/
|
*/
|
||||||
public static function autoBuild() {
|
public static function autoBuild() {
|
||||||
$dataClasses = ClassInfo::subclassesFor('DataObject');
|
$dataClasses = ClassInfo::subclassesFor('SilverStripe\ORM\DataObject');
|
||||||
$lastBuilt = self::lastBuilt();
|
$lastBuilt = self::lastBuilt();
|
||||||
foreach($dataClasses as $class) {
|
foreach($dataClasses as $class) {
|
||||||
if(filemtime(getClassFile($class)) > $lastBuilt) {
|
if(filemtime(getClassFile($class)) > $lastBuilt) {
|
||||||
@ -141,7 +154,7 @@ class DatabaseAdmin extends Controller {
|
|||||||
* DataObject classes
|
* DataObject classes
|
||||||
*/
|
*/
|
||||||
public function buildDefaults() {
|
public function buildDefaults() {
|
||||||
$dataClasses = ClassInfo::subclassesFor('DataObject');
|
$dataClasses = ClassInfo::subclassesFor('SilverStripe\ORM\DataObject');
|
||||||
array_shift($dataClasses);
|
array_shift($dataClasses);
|
||||||
foreach($dataClasses as $dataClass){
|
foreach($dataClasses as $dataClass){
|
||||||
singleton($dataClass)->requireDefaultRecords();
|
singleton($dataClass)->requireDefaultRecords();
|
||||||
@ -215,7 +228,7 @@ class DatabaseAdmin extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build the database. Most of the hard work is handled by DataObject
|
// Build the database. Most of the hard work is handled by DataObject
|
||||||
$dataClasses = ClassInfo::subclassesFor('DataObject');
|
$dataClasses = ClassInfo::subclassesFor('SilverStripe\ORM\DataObject');
|
||||||
array_shift($dataClasses);
|
array_shift($dataClasses);
|
||||||
|
|
||||||
if(!$quiet) {
|
if(!$quiet) {
|
||||||
@ -299,7 +312,7 @@ class DatabaseAdmin extends Controller {
|
|||||||
public function cleanup() {
|
public function cleanup() {
|
||||||
$allClasses = get_declared_classes();
|
$allClasses = get_declared_classes();
|
||||||
foreach($allClasses as $class) {
|
foreach($allClasses as $class) {
|
||||||
if(get_parent_class($class) == 'DataObject') {
|
if(get_parent_class($class) == 'SilverStripe\ORM\DataObject') {
|
||||||
$baseClasses[] = $class;
|
$baseClasses[] = $class;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,16 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use CheckboxField;
|
use CheckboxField;
|
||||||
use DropdownField;
|
use DropdownField;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a boolean field.
|
* Represents a boolean field.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBBoolean extends DBField {
|
class DBBoolean extends DBField {
|
||||||
|
|
@ -1,17 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use DataObject;
|
|
||||||
use ClassInfo;
|
use ClassInfo;
|
||||||
use Config;
|
use Config;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a classname selector, which respects obsolete clasess.
|
* Represents a classname selector, which respects obsolete clasess.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBClassName extends DBEnum {
|
class DBClassName extends DBEnum {
|
||||||
|
|
||||||
@ -101,7 +102,7 @@ class DBClassName extends DBEnum {
|
|||||||
return $baseClass;
|
return $baseClass;
|
||||||
}
|
}
|
||||||
// Fallback to global default
|
// Fallback to global default
|
||||||
return 'DataObject';
|
return 'SilverStripe\ORM\DataObject';
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +123,7 @@ class DBClassName extends DBEnum {
|
|||||||
*/
|
*/
|
||||||
public function getEnum() {
|
public function getEnum() {
|
||||||
$classNames = ClassInfo::subclassesFor($this->getBaseClass());
|
$classNames = ClassInfo::subclassesFor($this->getBaseClass());
|
||||||
unset($classNames['DataObject']);
|
unset($classNames['SilverStripe\ORM\DataObject']);
|
||||||
return $classNames;
|
return $classNames;
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use Object;
|
use Object;
|
||||||
use DataObject;
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Apply this interface to any {@link DBField} that doesn't have a 1-1 mapping with a database field.
|
* Apply this interface to any {@link DBField} that doesn't have a 1-1 mapping with a database field.
|
||||||
@ -23,7 +24,7 @@ use DataObject;
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class DBComposite extends DBField {
|
abstract class DBComposite extends DBField {
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use Deprecation;
|
use Deprecation;
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ use Deprecation;
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBCurrency extends DBDecimal {
|
class DBCurrency extends DBDecimal {
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use Member;
|
use Member;
|
||||||
use Zend_Date;
|
use Zend_Date;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use DateField;
|
use DateField;
|
||||||
use Convert;
|
use Convert;
|
||||||
use Exception;
|
use Exception;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a date field.
|
* Represents a date field.
|
||||||
@ -27,17 +27,17 @@ use Exception;
|
|||||||
* @todo Add localization support, see http://open.silverstripe.com/ticket/2931
|
* @todo Add localization support, see http://open.silverstripe.com/ticket/2931
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBDate extends DBField {
|
class DBDate extends DBField {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @config
|
* @config
|
||||||
* @see SS_DateTime::nice_format
|
* @see DBDateTime::nice_format
|
||||||
* @see Time::nice_format
|
* @see Time::nice_format
|
||||||
*/
|
*/
|
||||||
private static $nice_format = 'd/m/Y';
|
private static $nice_format = 'd/m/Y';
|
||||||
|
|
||||||
public function setValue($value, $record = null, $markChanged = true) {
|
public function setValue($value, $record = null, $markChanged = true) {
|
||||||
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
||||||
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be
|
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be
|
||||||
@ -78,7 +78,7 @@ class DBDate extends DBField {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date in the format specified by the config value nice_format, or dd/mm/yy by default
|
* Returns the date in the format specified by the config value nice_format, or dd/mm/yy by default
|
||||||
*/
|
*/
|
||||||
public function Nice() {
|
public function Nice() {
|
||||||
if($this->value) return $this->Format($this->config()->nice_format);
|
if($this->value) return $this->Format($this->config()->nice_format);
|
||||||
}
|
}
|
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use Convert;
|
use Convert;
|
||||||
use Member;
|
use Member;
|
||||||
use DatetimeField;
|
use DatetimeField;
|
||||||
use Zend_Date;
|
use Zend_Date;
|
||||||
use TemplateGlobalProvider;
|
use TemplateGlobalProvider;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a date-time field.
|
* Represents a date-time field.
|
||||||
@ -25,14 +25,14 @@ use DateTime;
|
|||||||
* Example definition via {@link DataObject::$db}:
|
* Example definition via {@link DataObject::$db}:
|
||||||
* <code>
|
* <code>
|
||||||
* static $db = array(
|
* static $db = array(
|
||||||
* "Expires" => "SS_Datetime",
|
* "Expires" => "DBDatetime",
|
||||||
* );
|
* );
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @todo Add localization support, see http://open.silverstripe.com/ticket/2931
|
* @todo Add localization support, see http://open.silverstripe.com/ticket/2931
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
||||||
|
|
||||||
@ -42,7 +42,7 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
|||||||
* @see Time::nice_format
|
* @see Time::nice_format
|
||||||
*/
|
*/
|
||||||
private static $nice_format = 'd/m/Y g:ia';
|
private static $nice_format = 'd/m/Y g:ia';
|
||||||
|
|
||||||
public function setValue($value, $record = null, $markChanged = true) {
|
public function setValue($value, $record = null, $markChanged = true) {
|
||||||
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
if($value === false || $value === null || (is_string($value) && !strlen($value))) {
|
||||||
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be
|
// don't try to evaluate empty values with strtotime() below, as it returns "1970-01-01" when it should be
|
||||||
@ -72,7 +72,7 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the date and time in the format specified by the config value nice_format, or 'd/m/Y g:ia'
|
* Returns the date and time in the format specified by the config value nice_format, or 'd/m/Y g:ia'
|
||||||
* by default (e.g. '31/01/2014 2:23pm').
|
* by default (e.g. '31/01/2014 2:23pm').
|
||||||
* @return string Formatted date and time.
|
* @return string Formatted date and time.
|
||||||
*/
|
*/
|
||||||
@ -137,7 +137,7 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
public function requireField() {
|
public function requireField() {
|
||||||
$parts=Array('datatype'=>'datetime', 'arrayValue'=>$this->arrayValue);
|
$parts=Array('datatype'=>'datetime', 'arrayValue'=>$this->arrayValue);
|
||||||
$values=Array('type'=>'SS_Datetime', 'parts'=>$parts);
|
$values=Array('type'=>'datetime', 'parts'=>$parts);
|
||||||
DB::require_field($this->tableName, $this->name, $values);
|
DB::require_field($this->tableName, $this->name, $values);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,13 +180,13 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
|||||||
* Returns either the current system date as determined
|
* Returns either the current system date as determined
|
||||||
* by date(), or a mocked date through {@link set_mock_now()}.
|
* by date(), or a mocked date through {@link set_mock_now()}.
|
||||||
*
|
*
|
||||||
* @return SS_Datetime
|
* @return static
|
||||||
*/
|
*/
|
||||||
public static function now() {
|
public static function now() {
|
||||||
if(self::$mock_now) {
|
if(self::$mock_now) {
|
||||||
return self::$mock_now;
|
return self::$mock_now;
|
||||||
} else {
|
} else {
|
||||||
return DBField::create_field('SS_Datetime', date('Y-m-d H:i:s'));
|
return DBField::create_field('SilverStripe\ORM\FieldType\DBDatetime', date('Y-m-d H:i:s'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,14 +195,14 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
|||||||
* Use {@link clear_mock_now()} to revert to the current system date.
|
* Use {@link clear_mock_now()} to revert to the current system date.
|
||||||
* Caution: This sets a fixed date that doesn't increment with time.
|
* Caution: This sets a fixed date that doesn't increment with time.
|
||||||
*
|
*
|
||||||
* @param SS_Datetime|string $datetime Either in object format, or as a SS_Datetime compatible string.
|
* @param DBDatetime|string $datetime Either in object format, or as a DBDatetime compatible string.
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public static function set_mock_now($datetime) {
|
public static function set_mock_now($datetime) {
|
||||||
if($datetime instanceof SS_Datetime) {
|
if($datetime instanceof DBDatetime) {
|
||||||
self::$mock_now = $datetime;
|
self::$mock_now = $datetime;
|
||||||
} elseif(is_string($datetime)) {
|
} elseif(is_string($datetime)) {
|
||||||
self::$mock_now = DBField::create_field('SS_Datetime', $datetime);
|
self::$mock_now = DBField::create_field('SilverStripe\ORM\FieldType\DBDatetime', $datetime);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception('DBDatetime::set_mock_now(): Wrong format: ' . $datetime);
|
throw new Exception('DBDatetime::set_mock_now(): Wrong format: ' . $datetime);
|
||||||
}
|
}
|
||||||
@ -218,7 +218,7 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
public static function get_template_global_variables() {
|
public static function get_template_global_variables() {
|
||||||
return array(
|
return array(
|
||||||
'Now' => array('method' => 'now', 'casting' => 'SS_Datetime'),
|
'Now' => array('method' => 'now', 'casting' => 'SilverStripe\ORM\FieldType\DBDatetime'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use NumericField;
|
use NumericField;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Decimal field.
|
* Represents a Decimal field.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBDecimal extends DBField {
|
class DBDecimal extends DBField {
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
use SilverStripe\ORM\DB;
|
||||||
use MySQLDatabase;
|
use SilverStripe\ORM\Connect\MySQLDatabase;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBDouble extends DBFloat {
|
class DBDouble extends DBFloat {
|
||||||
|
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use ArrayLib;
|
use ArrayLib;
|
||||||
use DropdownField;
|
use DropdownField;
|
||||||
use Config;
|
use Config;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Enum represents an enumeration of a set of strings.
|
* Class Enum represents an enumeration of a set of strings.
|
||||||
@ -13,7 +13,7 @@ use Config;
|
|||||||
* See {@link DropdownField} for a {@link FormField} to select enum values.
|
* See {@link DropdownField} for a {@link FormField} to select enum values.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBEnum extends DBString {
|
class DBEnum extends DBString {
|
||||||
|
|
||||||
@ -82,8 +82,8 @@ class DBEnum extends DBString {
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function requireField() {
|
public function requireField() {
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
|
|
||||||
$parts = array(
|
$parts = array(
|
||||||
'datatype' => 'enum',
|
'datatype' => 'enum',
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use ViewableData;
|
use ViewableData;
|
||||||
use Convert;
|
use Convert;
|
||||||
@ -40,7 +40,7 @@ use TextField;
|
|||||||
* @todo remove MySQL specific code from subclasses
|
* @todo remove MySQL specific code from subclasses
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class DBField extends ViewableData {
|
abstract class DBField extends ViewableData {
|
||||||
|
|
@ -1,15 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use NumericField;
|
use NumericField;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a floating point field.
|
* Represents a floating point field.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBFloat extends DBField {
|
class DBFloat extends DBField {
|
||||||
|
|
@ -1,12 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DataList;
|
|
||||||
use UploadField;
|
use UploadField;
|
||||||
use DropdownField;
|
use DropdownField;
|
||||||
use NumericField;
|
use NumericField;
|
||||||
use DataObject;
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special type Int field used for foreign keys in has_one relationships.
|
* A special type Int field used for foreign keys in has_one relationships.
|
||||||
@ -19,7 +19,7 @@ use DataObject;
|
|||||||
* @param DataObject $object The object that the foreign key is stored on (should have a relation with $name)
|
* @param DataObject $object The object that the foreign key is stored on (should have a relation with $name)
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBForeignKey extends DBInt {
|
class DBForeignKey extends DBInt {
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use Injector;
|
use Injector;
|
||||||
use HTTP;
|
use HTTP;
|
||||||
@ -19,7 +19,7 @@ use Exception;
|
|||||||
* @see Varchar
|
* @see Varchar
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBHTMLText extends DBText {
|
class DBHTMLText extends DBText {
|
||||||
private static $escape_type = 'xml';
|
private static $escape_type = 'xml';
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use ShortcodeParser;
|
use ShortcodeParser;
|
||||||
use HTMLEditorField;
|
use HTMLEditorField;
|
||||||
@ -11,7 +11,7 @@ use TextField;
|
|||||||
*
|
*
|
||||||
* This behaves similarly to Varchar, but the template processor won't escape any HTML content within it.
|
* This behaves similarly to Varchar, but the template processor won't escape any HTML content within it.
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBHTMLVarchar extends DBVarchar {
|
class DBHTMLVarchar extends DBVarchar {
|
||||||
|
|
@ -1,17 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use NumericField;
|
use NumericField;
|
||||||
use ArrayList;
|
|
||||||
use ArrayData;
|
use ArrayData;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a signed 32 bit integer field.
|
* Represents a signed 32 bit integer field.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBInt extends DBField {
|
class DBInt extends DBField {
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use i18n;
|
use i18n;
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ use i18n;
|
|||||||
* @todo Allowing showing locale values in different languages through Nice()
|
* @todo Allowing showing locale values in different languages through Nice()
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage i18n
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBLocale extends DBVarchar {
|
class DBLocale extends DBVarchar {
|
||||||
|
|
@ -1,12 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use i18n;
|
use i18n;
|
||||||
use Zend_Currency;
|
use Zend_Currency;
|
||||||
use MoneyField;
|
use MoneyField;
|
||||||
use DataObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Partially based on Zend_Currency.
|
* Partially based on Zend_Currency.
|
||||||
@ -29,7 +27,7 @@ require_once 'Zend/Currency.php';
|
|||||||
* @todo Model validation for $allowedCurrencies
|
* @todo Model validation for $allowedCurrencies
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBMoney extends DBComposite {
|
class DBMoney extends DBComposite {
|
||||||
|
|
@ -1,19 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use CheckboxSetField;
|
use CheckboxSetField;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
/**
|
|
||||||
* @package framework
|
|
||||||
* @subpackage model
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an multi-select enumeration field.
|
* Represents an multi-select enumeration field.
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBMultiEnum extends DBEnum {
|
class DBMultiEnum extends DBEnum {
|
||||||
public function __construct($name, $enum = NULL, $default = NULL) {
|
public function __construct($name, $enum = NULL, $default = NULL) {
|
||||||
@ -36,8 +31,8 @@ class DBMultiEnum extends DBEnum {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function requireField(){
|
public function requireField(){
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
$values=array(
|
$values=array(
|
||||||
'type'=>'set',
|
'type'=>'set',
|
||||||
'parts'=>array(
|
'parts'=>array(
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a decimal field from 0-1 containing a percentage value.
|
* Represents a decimal field from 0-1 containing a percentage value.
|
||||||
@ -14,7 +14,7 @@ namespace SilverStripe\Model\FieldType;
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBPercentage extends DBDecimal {
|
class DBPercentage extends DBDecimal {
|
||||||
|
|
@ -1,22 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
use SilverStripe\ORM\DataObject;
|
||||||
use DataObject;
|
|
||||||
use ClassInfo;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special ForeignKey class that handles relations with arbitrary class types
|
* A special ForeignKey class that handles relations with arbitrary class types
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBPolymorphicForeignKey extends DBComposite {
|
class DBPolymorphicForeignKey extends DBComposite {
|
||||||
|
|
||||||
private static $composite_db = array(
|
private static $composite_db = array(
|
||||||
'ID' => 'Int',
|
'ID' => 'Int',
|
||||||
'Class' => 'DBClassName("DataObject")'
|
'Class' => "DBClassName('SilverStripe\\ORM\\DataObject')"
|
||||||
);
|
);
|
||||||
|
|
||||||
public function scaffoldFormField($title = null, $params = null) {
|
public function scaffoldFormField($title = null, $params = null) {
|
||||||
@ -79,7 +77,7 @@ class DBPolymorphicForeignKey extends DBComposite {
|
|||||||
public function getValue() {
|
public function getValue() {
|
||||||
$id = $this->getIDValue();
|
$id = $this->getIDValue();
|
||||||
$class = $this->getClassValue();
|
$class = $this->getClassValue();
|
||||||
if($id && $class && is_subclass_of($class, 'DataObject')) {
|
if($id && $class && is_subclass_of($class, 'SilverStripe\ORM\DataObject')) {
|
||||||
return DataObject::get_by_id($class, $id);
|
return DataObject::get_by_id($class, $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
use DataList;
|
|
||||||
use DropdownField;
|
|
||||||
use DB;
|
|
||||||
use DataObject;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A special type Int field used for primary keys.
|
* A special type Int field used for primary keys.
|
||||||
@ -13,7 +12,7 @@ use DataObject;
|
|||||||
* @todo Allow for custom limiting/filtering of scaffoldFormField dropdown
|
* @todo Allow for custom limiting/filtering of scaffoldFormField dropdown
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBPrimaryKey extends DBInt {
|
class DBPrimaryKey extends DBInt {
|
||||||
/**
|
/**
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use Convert;
|
use Convert;
|
||||||
|
|
||||||
@ -8,7 +8,7 @@ use Convert;
|
|||||||
* An abstract base class for the string field types (i.e. Varchar and Text)
|
* An abstract base class for the string field types (i.e. Varchar and Text)
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class DBString extends DBField {
|
abstract class DBString extends DBField {
|
||||||
|
|
@ -1,14 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use HTTP;
|
use HTTP;
|
||||||
use Convert;
|
use Convert;
|
||||||
use NullableField;
|
use NullableField;
|
||||||
use TextareaField;
|
use TextareaField;
|
||||||
use TextField;
|
use TextField;
|
||||||
use Config;
|
use Config;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a variable-length string of up to 2 megabytes, designed to store raw text
|
* Represents a variable-length string of up to 2 megabytes, designed to store raw text
|
||||||
@ -25,7 +25,7 @@ use Config;
|
|||||||
* @see Varchar
|
* @see Varchar
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBText extends DBString {
|
class DBText extends DBString {
|
||||||
|
|
||||||
@ -48,8 +48,8 @@ class DBText extends DBString {
|
|||||||
* @see DBField::requireField()
|
* @see DBField::requireField()
|
||||||
*/
|
*/
|
||||||
public function requireField() {
|
public function requireField() {
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
|
|
||||||
$parts = array(
|
$parts = array(
|
||||||
'datatype' => 'mediumtext',
|
'datatype' => 'mediumtext',
|
@ -1,12 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use Convert;
|
use Convert;
|
||||||
use Zend_Date;
|
use Zend_Date;
|
||||||
use TimeField;
|
use TimeField;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a column in the database with the type 'Time'.
|
* Represents a column in the database with the type 'Time'.
|
||||||
@ -21,14 +20,14 @@ use TimeField;
|
|||||||
* @todo Add localization support, see http://open.silverstripe.com/ticket/2931
|
* @todo Add localization support, see http://open.silverstripe.com/ticket/2931
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBTime extends DBField {
|
class DBTime extends DBField {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @config
|
* @config
|
||||||
* @see Date::nice_format
|
* @see Date::nice_format
|
||||||
* @see SS_DateTime::nice_format
|
* @see DBDateTime::nice_format
|
||||||
*/
|
*/
|
||||||
private static $nice_format = 'g:ia';
|
private static $nice_format = 'g:ia';
|
||||||
|
|
||||||
@ -42,7 +41,7 @@ class DBTime extends DBField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the time in the format specified by the config value nice_format, or 12 hour format by default
|
* Returns the time in the format specified by the config value nice_format, or 12 hour format by default
|
||||||
* e.g. "3:15pm"
|
* e.g. "3:15pm"
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
@ -1,11 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use NullableField;
|
use NullableField;
|
||||||
use TextField;
|
use TextField;
|
||||||
use Config;
|
use Config;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Varchar represents a variable-length string of up to 255 characters, designed to store raw text
|
* Class Varchar represents a variable-length string of up to 255 characters, designed to store raw text
|
||||||
@ -15,7 +15,7 @@ use Config;
|
|||||||
* @see Text
|
* @see Text
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBVarchar extends DBString {
|
class DBVarchar extends DBString {
|
||||||
|
|
||||||
@ -58,8 +58,8 @@ class DBVarchar extends DBString {
|
|||||||
* @see DBField::requireField()
|
* @see DBField::requireField()
|
||||||
*/
|
*/
|
||||||
public function requireField() {
|
public function requireField() {
|
||||||
$charset = Config::inst()->get('MySQLDatabase', 'charset');
|
$charset = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'charset');
|
||||||
$collation = Config::inst()->get('MySQLDatabase', 'collation');
|
$collation = Config::inst()->get('SilverStripe\ORM\Connect\MySQLDatabase', 'collation');
|
||||||
|
|
||||||
$parts = array(
|
$parts = array(
|
||||||
'datatype'=>'varchar',
|
'datatype'=>'varchar',
|
8
model/FieldType/DBYear.php → ORM/FieldType/DBYear.php
Executable file → Normal file
8
model/FieldType/DBYear.php → ORM/FieldType/DBYear.php
Executable file → Normal file
@ -1,20 +1,20 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model\FieldType;
|
namespace SilverStripe\ORM\FieldType;
|
||||||
|
|
||||||
use DB;
|
|
||||||
use DropdownField;
|
use DropdownField;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a single year field.
|
* Represents a single year field.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DBYear extends DBField {
|
class DBYear extends DBField {
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional interface for {@link SS_List} classes that are filterable.
|
* Additional interface for {@link SS_List} classes that are filterable.
|
||||||
*
|
*
|
||||||
@ -8,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* @see SS_List, SS_Sortable, SS_Limitable
|
* @see SS_List, SS_Sortable, SS_Limitable
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface SS_Filterable extends SS_List {
|
interface SS_Filterable extends SS_List {
|
||||||
|
|
@ -1,10 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use ArrayData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list decorator that allows a list to be grouped into sub-lists by common
|
* A list decorator that allows a list to be grouped into sub-lists by common
|
||||||
* values of a field.
|
* values of a field.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class GroupedList extends SS_ListDecorator {
|
class GroupedList extends SS_ListDecorator {
|
||||||
|
|
@ -1,10 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of {@link DataList} representing a has_many relation.
|
* Subclass of {@link DataList} representing a has_many relation.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class HasManyList extends RelationList {
|
class HasManyList extends RelationList {
|
||||||
|
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Anything that implements HiddenClass won't be shown in user-interface elements. For example,
|
* Anything that implements HiddenClass won't be shown in user-interface elements. For example,
|
||||||
* DataObjects that implement HiddenClass won't be showing in the "new page" dropdown.
|
* DataObjects that implement HiddenClass won't be showing in the "new page" dropdown.
|
@ -1,10 +1,24 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Hierarchy;
|
||||||
|
|
||||||
|
use Config;
|
||||||
|
use Exception;
|
||||||
|
use Controller;
|
||||||
|
use LeftAndMain;
|
||||||
|
use ClassInfo;
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataObjects that use the Hierarchy extension can be be organised as a hierarchy, with children and parents. The most
|
* DataObjects that use the Hierarchy extension can be be organised as a hierarchy, with children and parents. The most
|
||||||
* obvious example of this is SiteTree.
|
* obvious example of this is SiteTree.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*
|
*
|
||||||
* @property int ParentID
|
* @property int ParentID
|
||||||
* @property DataObject owner
|
* @property DataObject owner
|
||||||
@ -133,7 +147,7 @@ class Hierarchy extends DataExtension {
|
|||||||
$nodeCountThreshold = null, $nodeCountCallback = null) {
|
$nodeCountThreshold = null, $nodeCountCallback = null) {
|
||||||
|
|
||||||
if(!is_numeric($nodeCountThreshold)) {
|
if(!is_numeric($nodeCountThreshold)) {
|
||||||
$nodeCountThreshold = Config::inst()->get('Hierarchy', 'node_threshold_total');
|
$nodeCountThreshold = Config::inst()->get('SilverStripe\ORM\Hierarchy\Hierarchy', 'node_threshold_total');
|
||||||
}
|
}
|
||||||
|
|
||||||
if($limitToMarked && $rootCall) {
|
if($limitToMarked && $rootCall) {
|
||||||
@ -534,7 +548,7 @@ class Hierarchy extends DataExtension {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$idList[] = $child->ID;
|
$idList[] = $child->ID;
|
||||||
$ext = $child->getExtensionInstance('Hierarchy');
|
$ext = $child->getExtensionInstance('SilverStripe\ORM\Hierarchy\Hierarchy');
|
||||||
$ext->setOwner($child);
|
$ext->setOwner($child);
|
||||||
$ext->loadDescendantIDListInto($idList);
|
$ext->loadDescendantIDListInto($idList);
|
||||||
$ext->clearOwner();
|
$ext->clearOwner();
|
||||||
@ -598,7 +612,7 @@ class Hierarchy extends DataExtension {
|
|||||||
$stageChildren = $this->owner->stageChildren(true);
|
$stageChildren = $this->owner->stageChildren(true);
|
||||||
|
|
||||||
// Add live site content that doesn't exist on the stage site, if required.
|
// Add live site content that doesn't exist on the stage site, if required.
|
||||||
if($this->owner->hasExtension('Versioned')) {
|
if($this->owner->hasExtension('SilverStripe\ORM\Versioning\Versioned')) {
|
||||||
// Next, go through the live children. Only some of these will be listed
|
// Next, go through the live children. Only some of these will be listed
|
||||||
$liveChildren = $this->owner->liveChildren(true, true);
|
$liveChildren = $this->owner->liveChildren(true, true);
|
||||||
if($liveChildren) {
|
if($liveChildren) {
|
||||||
@ -626,7 +640,7 @@ class Hierarchy extends DataExtension {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function AllHistoricalChildren() {
|
public function AllHistoricalChildren() {
|
||||||
if(!$this->owner->hasExtension('Versioned')) {
|
if(!$this->owner->hasExtension('SilverStripe\ORM\Versioning\Versioned')) {
|
||||||
throw new Exception('Hierarchy->AllHistoricalChildren() only works with Versioned extension applied');
|
throw new Exception('Hierarchy->AllHistoricalChildren() only works with Versioned extension applied');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -646,7 +660,7 @@ class Hierarchy extends DataExtension {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function numHistoricalChildren() {
|
public function numHistoricalChildren() {
|
||||||
if(!$this->owner->hasExtension('Versioned')) {
|
if(!$this->owner->hasExtension('SilverStripe\ORM\Versioning\Versioned')) {
|
||||||
throw new Exception('Hierarchy->AllHistoricalChildren() only works with Versioned extension applied');
|
throw new Exception('Hierarchy->AllHistoricalChildren() only works with Versioned extension applied');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -721,7 +735,7 @@ class Hierarchy extends DataExtension {
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
public function liveChildren($showAll = false, $onlyDeletedFromStage = false) {
|
public function liveChildren($showAll = false, $onlyDeletedFromStage = false) {
|
||||||
if(!$this->owner->hasExtension('Versioned')) {
|
if(!$this->owner->hasExtension('SilverStripe\ORM\Versioning\Versioned')) {
|
||||||
throw new Exception('Hierarchy->liveChildren() only works with Versioned extension applied');
|
throw new Exception('Hierarchy->liveChildren() only works with Versioned extension applied');
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional interface for {@link SS_List} classes that are limitable - able to have a subset of the list extracted.
|
* Additional interface for {@link SS_List} classes that are limitable - able to have a subset of the list extracted.
|
||||||
*
|
*
|
||||||
@ -8,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* @see SS_List, SS_Sortable, SS_Filterable
|
* @see SS_List, SS_Sortable, SS_Filterable
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface SS_Limitable extends SS_List {
|
interface SS_Limitable extends SS_List {
|
||||||
|
|
@ -1,9 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use ArrayAccess;
|
||||||
|
use Countable;
|
||||||
|
use IteratorAggregate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An interface that a class can implement to be treated as a list container.
|
* An interface that a class can implement to be treated as a list container.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface SS_List extends ArrayAccess, Countable, IteratorAggregate {
|
interface SS_List extends ArrayAccess, Countable, IteratorAggregate {
|
||||||
|
|
@ -1,11 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use ViewableData;
|
||||||
|
use LogicException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A base class for decorators that wrap around a list to provide additional
|
* A base class for decorators that wrap around a list to provide additional
|
||||||
* functionality. It passes through list methods to the underlying list
|
* functionality. It passes through list methods to the underlying list
|
||||||
* implementation.
|
* implementation.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sortable, SS_Filterable, SS_Limitable {
|
abstract class SS_ListDecorator extends ViewableData implements SS_List, SS_Sortable, SS_Filterable, SS_Limitable {
|
||||||
|
|
@ -1,12 +1,19 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBComposite;
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Object;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Exception;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\Queries\SQLDelete;
|
||||||
|
use SilverStripe\ORM\FieldType\DBComposite;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Subclass of {@link DataList} representing a many_many relation.
|
* Subclass of {@link DataList} representing a many_many relation.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class ManyManyList extends RelationList {
|
class ManyManyList extends RelationList {
|
||||||
|
|
@ -1,10 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use ArrayAccess;
|
||||||
|
use Countable;
|
||||||
|
use IteratorAggregate;
|
||||||
|
use Iterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a map from an SS_List by defining a key column and a value column.
|
* Creates a map from an SS_List by defining a key column and a value column.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
||||||
|
|
||||||
@ -266,7 +273,7 @@ class SS_Map implements ArrayAccess, Countable, IteratorAggregate {
|
|||||||
* Builds a map iterator around an Iterator. Called by SS_Map
|
* Builds a map iterator around an Iterator. Called by SS_Map
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SS_Map_Iterator implements Iterator {
|
class SS_Map_Iterator implements Iterator {
|
||||||
|
|
@ -1,10 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Convert;
|
||||||
|
use ClassInfo;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a has_many list linked against a polymorphic relationship
|
* Represents a has_many list linked against a polymorphic relationship
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class PolymorphicHasManyList extends HasManyList {
|
class PolymorphicHasManyList extends HasManyList {
|
||||||
|
|
@ -1,10 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a list of updates / inserts made to a single row in a table
|
* Represents a list of updates / inserts made to a single row in a table
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SQLAssignmentRow {
|
class SQLAssignmentRow {
|
||||||
|
|
@ -1,12 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a where condition that is dynamically generated. Maybe be stored
|
* Represents a where condition that is dynamically generated. Maybe be stored
|
||||||
* within a list of conditions, altered, and be allowed to affect the result
|
* within a list of conditions, altered, and be allowed to affect the result
|
||||||
* of the parent sql query during future execution.
|
* of the parent sql query during future execution.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface SQLConditionGroup {
|
interface SQLConditionGroup {
|
||||||
|
|
@ -1,11 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
|
use Deprecation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a SQL query for an expression which interacts with existing rows
|
* Represents a SQL query for an expression which interacts with existing rows
|
||||||
* (SELECT / DELETE / UPDATE) with a WHERE clause
|
* (SELECT / DELETE / UPDATE) with a WHERE clause
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class SQLConditionalExpression extends SQLExpression {
|
abstract class SQLConditionalExpression extends SQLExpression {
|
||||||
|
|
@ -1,11 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
|
use Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representing a SQL DELETE query.
|
* Object representing a SQL DELETE query.
|
||||||
* The various parts of the SQL query can be manipulated individually.
|
* The various parts of the SQL query can be manipulated individually.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SQLDelete extends SQLConditionalExpression {
|
class SQLDelete extends SQLConditionalExpression {
|
||||||
|
|
@ -1,11 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use Convert;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract base class for an object representing an SQL query.
|
* Abstract base class for an object representing an SQL query.
|
||||||
* The various parts of the SQL query can be manipulated individually.
|
* The various parts of the SQL query can be manipulated individually.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class SQLExpression {
|
abstract class SQLExpression {
|
||||||
|
|
@ -1,11 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
|
use Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representing a SQL INSERT query.
|
* Object representing a SQL INSERT query.
|
||||||
* The various parts of the SQL query can be manipulated individually.
|
* The various parts of the SQL query can be manipulated individually.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SQLInsert extends SQLExpression implements SQLWriteExpression {
|
class SQLInsert extends SQLExpression implements SQLWriteExpression {
|
||||||
|
|
@ -1,11 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
|
use Injector;
|
||||||
|
use Deprecation;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representing a SQL SELECT query.
|
* Object representing a SQL SELECT query.
|
||||||
* The various parts of the SQL query can be manipulated individually.
|
* The various parts of the SQL query can be manipulated individually.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SQLSelect extends SQLConditionalExpression {
|
class SQLSelect extends SQLConditionalExpression {
|
||||||
|
|
@ -1,11 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
|
use Injector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Object representing a SQL UPDATE query.
|
* Object representing a SQL UPDATE query.
|
||||||
* The various parts of the SQL query can be manipulated individually.
|
* The various parts of the SQL query can be manipulated individually.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class SQLUpdate extends SQLConditionalExpression implements SQLWriteExpression {
|
class SQLUpdate extends SQLConditionalExpression implements SQLWriteExpression {
|
||||||
|
|
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Queries;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a SQL expression which may have field values assigned
|
* Represents a SQL expression which may have field values assigned
|
||||||
* (UPDATE/INSERT Expressions)
|
* (UPDATE/INSERT Expressions)
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface SQLWriteExpression {
|
interface SQLWriteExpression {
|
||||||
|
|
@ -1,18 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace SilverStripe\Model;
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
use DBField;
|
|
||||||
use SS_Filterable;
|
|
||||||
use SS_Limitable;
|
|
||||||
use SS_List;
|
|
||||||
use SS_Sortable;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract representation of a DB relation field, either saved or in memory
|
* Abstract representation of a DB relation field, either saved or in memory
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface Relation extends SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
interface Relation extends SS_List, SS_Filterable, SS_Sortable, SS_Limitable {
|
||||||
|
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\Relation;
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A DataList that represents a relation.
|
* A DataList that represents a relation.
|
||||||
@ -8,7 +10,7 @@ use SilverStripe\Model\Relation;
|
|||||||
* Adds the notion of a foreign ID that can be optionally set.
|
* Adds the notion of a foreign ID that can be optionally set.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
abstract class RelationList extends DataList implements Relation {
|
abstract class RelationList extends DataList implements Relation {
|
||||||
|
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Additional interface for {@link SS_List} classes that are sortable.
|
* Additional interface for {@link SS_List} classes that are sortable.
|
||||||
*
|
*
|
||||||
@ -8,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
* @see SS_List, SS_Filterable, SS_Limitable
|
* @see SS_List, SS_Filterable, SS_Limitable
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
interface SS_Sortable extends SS_List {
|
interface SS_Sortable extends SS_List {
|
||||||
|
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\Relation;
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use ArrayIterator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An {@link ArrayList} that represents an unsaved relation.
|
* An {@link ArrayList} that represents an unsaved relation.
|
||||||
@ -14,7 +17,7 @@ use SilverStripe\Model\Relation;
|
|||||||
* into an instance of {@link RelationList}.
|
* into an instance of {@link RelationList}.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class UnsavedRelationList extends ArrayList implements Relation {
|
class UnsavedRelationList extends ArrayList implements Relation {
|
||||||
|
|
@ -1,11 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown by {@link DataObject}::write if validation fails. By throwing an
|
* Exception thrown by {@link DataObject}::write if validation fails. By throwing an
|
||||||
* exception rather than a user error, the exception can be caught in unit tests and as such
|
* exception rather than a user error, the exception can be caught in unit tests and as such
|
||||||
* can be used as a successful test.
|
* can be used as a successful test.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage validation
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class ValidationException extends Exception {
|
class ValidationException extends Exception {
|
||||||
|
|
@ -1,10 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM;
|
||||||
|
|
||||||
|
use Object;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that combined as a boolean result with an optional list of error messages.
|
* A class that combined as a boolean result with an optional list of error messages.
|
||||||
* This is used for returning validation results from validators
|
* This is used for returning validation results from validators
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage core
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class ValidationResult extends Object {
|
class ValidationResult extends Object {
|
||||||
/**
|
/**
|
@ -1,6 +1,18 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// namespace SilverStripe\Framework\Model\Versioning
|
namespace SilverStripe\ORM\Versioning;
|
||||||
|
|
||||||
|
use Member;
|
||||||
|
use Permission;
|
||||||
|
use FieldList;
|
||||||
|
use TextField;
|
||||||
|
use ReadonlyField;
|
||||||
|
use i18n;
|
||||||
|
use BadMethodCallException;
|
||||||
|
use LogicException;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ChangeSet model tracks several VersionedAndStaged objects for later publication as a single
|
* The ChangeSet model tracks several VersionedAndStaged objects for later publication as a single
|
||||||
@ -12,7 +24,7 @@
|
|||||||
* @property string $State
|
* @property string $State
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class ChangeSet extends DataObject {
|
class ChangeSet extends DataObject {
|
||||||
|
|
||||||
@ -29,13 +41,15 @@ class ChangeSet extends DataObject {
|
|||||||
/** A changeset which is published and closed */
|
/** A changeset which is published and closed */
|
||||||
const STATE_PUBLISHED = 'published';
|
const STATE_PUBLISHED = 'published';
|
||||||
|
|
||||||
|
private static $table_name = 'ChangeSet';
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Name' => 'Varchar',
|
'Name' => 'Varchar',
|
||||||
'State' => "Enum('open,published,reverted','open')",
|
'State' => "Enum('open,published,reverted','open')",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
'Changes' => 'ChangeSetItem',
|
'Changes' => 'SilverStripe\ORM\Versioning\ChangeSetItem',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $defaults = array(
|
private static $defaults = array(
|
@ -1,9 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// namespace SilverStripe\Framework\Model\Versioning
|
namespace SilverStripe\ORM\Versioning;
|
||||||
|
|
||||||
|
use Exception;
|
||||||
|
use BadMethodCallException;
|
||||||
|
use Member;
|
||||||
|
use Permission;
|
||||||
|
use CMSPreviewable;
|
||||||
|
use Controller;
|
||||||
use SilverStripe\Filesystem\Thumbnail;
|
use SilverStripe\Filesystem\Thumbnail;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A single line in a changeset
|
* A single line in a changeset
|
||||||
@ -33,6 +39,8 @@ class ChangeSetItem extends DataObject implements Thumbnail {
|
|||||||
/** Represents an object which hasn't been changed directly, but owns a modified many_many relationship. */
|
/** Represents an object which hasn't been changed directly, but owns a modified many_many relationship. */
|
||||||
//const CHANGE_MANYMANY = 'manymany';
|
//const CHANGE_MANYMANY = 'manymany';
|
||||||
|
|
||||||
|
private static $table_name = 'ChangeSetItem';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents that an object has not yet been changed, but
|
* Represents that an object has not yet been changed, but
|
||||||
* should be included in this changeset as soon as any changes exist
|
* should be included in this changeset as soon as any changes exist
|
||||||
@ -46,12 +54,12 @@ class ChangeSetItem extends DataObject implements Thumbnail {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'ChangeSet' => 'ChangeSet',
|
'ChangeSet' => 'SilverStripe\ORM\Versioning\ChangeSet',
|
||||||
'Object' => 'DataObject',
|
'Object' => 'SilverStripe\ORM\DataObject',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'ReferencedBy' => 'ChangeSetItem'
|
'ReferencedBy' => 'SilverStripe\ORM\Versioning\ChangeSetItem'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $belongs_many_many = array(
|
private static $belongs_many_many = array(
|
@ -1,6 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
namespace SilverStripe\ORM\Versioning;
|
||||||
|
|
||||||
|
use ViewableData;
|
||||||
|
use Diff;
|
||||||
|
use Image;
|
||||||
|
use Convert;
|
||||||
|
use ArrayData;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class to render views of the differences between two data objects (or two versions of the
|
* Utility class to render views of the differences between two data objects (or two versions of the
|
||||||
@ -36,7 +45,7 @@ use SilverStripe\Model\FieldType\DBField;
|
|||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage misc
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class DataDifferencer extends ViewableData {
|
class DataDifferencer extends ViewableData {
|
||||||
protected $fromRecord;
|
protected $fromRecord;
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Versioning;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Minimum level extra fields required by extensions that are versonable
|
* Minimum level extra fields required by extensions that are versonable
|
||||||
*/
|
*/
|
@ -1,6 +1,30 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
// namespace SilverStripe\Framework\Model\Versioning
|
namespace SilverStripe\ORM\Versioning;
|
||||||
|
|
||||||
|
use TemplateGlobalProvider;
|
||||||
|
use Session;
|
||||||
|
use Deprecation;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
use Config;
|
||||||
|
use LogicException;
|
||||||
|
use Member;
|
||||||
|
use ClassInfo;
|
||||||
|
use Object;
|
||||||
|
use Permission;
|
||||||
|
use Director;
|
||||||
|
use Cookie;
|
||||||
|
use FieldList;
|
||||||
|
use ViewableData;
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Versioned extension allows your DataObjects to have several versions,
|
* The Versioned extension allows your DataObjects to have several versions,
|
||||||
@ -11,7 +35,7 @@
|
|||||||
* @property DataObject|Versioned $owner
|
* @property DataObject|Versioned $owner
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*/
|
*/
|
||||||
class Versioned extends DataExtension implements TemplateGlobalProvider {
|
class Versioned extends DataExtension implements TemplateGlobalProvider {
|
||||||
|
|
||||||
@ -415,7 +439,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add all <basetable>_versions columns
|
// Add all <basetable>_versions columns
|
||||||
foreach(Config::inst()->get('Versioned', 'db_for_versions_table') as $name => $type) {
|
foreach(Config::inst()->get('SilverStripe\ORM\Versioning\Versioned', 'db_for_versions_table') as $name => $type) {
|
||||||
$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, $name), $name);
|
$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, $name), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,11 +642,11 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
if($isRootClass) {
|
if($isRootClass) {
|
||||||
// Create table for all versions
|
// Create table for all versions
|
||||||
$versionFields = array_merge(
|
$versionFields = array_merge(
|
||||||
Config::inst()->get('Versioned', 'db_for_versions_table'),
|
Config::inst()->get('SilverStripe\ORM\Versioning\Versioned', 'db_for_versions_table'),
|
||||||
(array)$fields
|
(array)$fields
|
||||||
);
|
);
|
||||||
$versionIndexes = array_merge(
|
$versionIndexes = array_merge(
|
||||||
Config::inst()->get('Versioned', 'indexes_for_versions_table'),
|
Config::inst()->get('SilverStripe\ORM\Versioning\Versioned', 'indexes_for_versions_table'),
|
||||||
(array)$nonUniqueIndexes
|
(array)$nonUniqueIndexes
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
@ -871,7 +895,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
// If we're editing Live, then use (table)_Live instead of (table)
|
// If we're editing Live, then use (table)_Live instead of (table)
|
||||||
if($this->hasStages() && static::get_stage() === static::LIVE) {
|
if($this->hasStages() && static::get_stage() === static::LIVE) {
|
||||||
$this->augmentWriteStaged($manipulation, $class, $id);
|
$this->augmentWriteStaged($manipulation, $table, $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1000,9 +1024,9 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
protected function lookupReverseOwners() {
|
protected function lookupReverseOwners() {
|
||||||
// Find all classes with 'owns' config
|
// Find all classes with 'owns' config
|
||||||
$lookup = array();
|
$lookup = array();
|
||||||
foreach(ClassInfo::subclassesFor('DataObject') as $class) {
|
foreach(ClassInfo::subclassesFor('SilverStripe\ORM\DataObject') as $class) {
|
||||||
// Ensure this class is versioned
|
// Ensure this class is versioned
|
||||||
if(!Object::has_extension($class, 'Versioned')) {
|
if(!Object::has_extension($class, 'SilverStripe\ORM\Versioning\Versioned')) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1021,7 +1045,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
if(!$ownedClass) {
|
if(!$ownedClass) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if($ownedClass === 'DataObject') {
|
if($ownedClass === 'SilverStripe\ORM\DataObject') {
|
||||||
throw new LogicException(sprintf(
|
throw new LogicException(sprintf(
|
||||||
"Relation %s on class %s cannot be owned as it is polymorphic",
|
"Relation %s on class %s cannot be owned as it is polymorphic",
|
||||||
$owned, $class
|
$owned, $class
|
||||||
@ -1115,7 +1139,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
$itemKey = $item->class . '/' . $item->ID;
|
$itemKey = $item->class . '/' . $item->ID;
|
||||||
|
|
||||||
// Skip unsaved, unversioned, or already checked objects
|
// Skip unsaved, unversioned, or already checked objects
|
||||||
if(!$item->isInDB() || !$item->has_extension('Versioned') || isset($list[$itemKey])) {
|
if(!$item->isInDB() || !$item->has_extension('SilverStripe\ORM\Versioning\Versioned') || isset($list[$itemKey])) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1372,7 +1396,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
*/
|
*/
|
||||||
public function canBeVersioned($class) {
|
public function canBeVersioned($class) {
|
||||||
return ClassInfo::exists($class)
|
return ClassInfo::exists($class)
|
||||||
&& is_subclass_of($class, 'DataObject')
|
&& is_subclass_of($class, 'SilverStripe\ORM\DataObject')
|
||||||
&& DataObject::has_own_table($class);
|
&& DataObject::has_own_table($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1820,7 +1844,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add all <basetable>_versions columns
|
// Add all <basetable>_versions columns
|
||||||
foreach(Config::inst()->get('Versioned', 'db_for_versions_table') as $name => $type) {
|
foreach(Config::inst()->get('SilverStripe\ORM\Versioning\Versioned', 'db_for_versions_table') as $name => $type) {
|
||||||
$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, $name), $name);
|
$query->selectField(sprintf('"%s_versions"."%s"', $baseTable, $name), $name);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2105,7 +2129,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
* @param array $idList
|
* @param array $idList
|
||||||
*/
|
*/
|
||||||
public static function prepopulate_versionnumber_cache($class, $stage, $idList = null) {
|
public static function prepopulate_versionnumber_cache($class, $stage, $idList = null) {
|
||||||
if (!Config::inst()->get('Versioned', 'prepopulate_versionnumber_cache')) {
|
if (!Config::inst()->get('SilverStripe\ORM\Versioning\Versioned', 'prepopulate_versionnumber_cache')) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$filter = "";
|
$filter = "";
|
||||||
@ -2149,7 +2173,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
* @return DataList A modified DataList designated to the specified stage
|
* @return DataList A modified DataList designated to the specified stage
|
||||||
*/
|
*/
|
||||||
public static function get_by_stage(
|
public static function get_by_stage(
|
||||||
$class, $stage, $filter = '', $sort = '', $join = '', $limit = null, $containerClass = 'DataList'
|
$class, $stage, $filter = '', $sort = '', $join = '', $limit = null, $containerClass = 'SilverStripe\ORM\DataList'
|
||||||
) {
|
) {
|
||||||
$result = DataObject::get($class, $filter, $sort, $join, $limit, $containerClass);
|
$result = DataObject::get($class, $filter, $sort, $join, $limit, $containerClass);
|
||||||
return $result->setDataQueryParam(array(
|
return $result->setDataQueryParam(array(
|
||||||
@ -2437,7 +2461,7 @@ class Versioned extends DataExtension implements TemplateGlobalProvider {
|
|||||||
* Represents a single version of a record.
|
* Represents a single version of a record.
|
||||||
*
|
*
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage model
|
* @subpackage orm
|
||||||
*
|
*
|
||||||
* @see Versioned
|
* @see Versioned
|
||||||
*/
|
*/
|
@ -1,13 +1,17 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Versioning;
|
||||||
|
|
||||||
|
use Extension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Extends {@see GridFieldDetailForm}
|
* Extends {@see GridFieldDetailForm}
|
||||||
*/
|
*/
|
||||||
class VersionedGridFieldDetailForm extends Extension {
|
class VersionedGridFieldDetailForm extends Extension {
|
||||||
public function updateItemRequestClass(&$class, $gridField, $record, $requestHandler) {
|
public function updateItemRequestClass(&$class, $gridField, $record, $requestHandler) {
|
||||||
// Conditionally use a versioned item handler
|
// Conditionally use a versioned item handler
|
||||||
if($record && $record->has_extension('Versioned')) {
|
if($record && $record->has_extension('SilverStripe\ORM\Versioning\Versioned')) {
|
||||||
$class = 'VersionedGridFieldItemRequest';
|
$class = 'SilverStripe\ORM\Versioning\VersionedGridFieldItemRequest';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace SilverStripe\ORM\Versioning;
|
||||||
|
|
||||||
|
use GridFieldDetailForm_ItemRequest;
|
||||||
|
use FormAction;
|
||||||
|
use Convert;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides versioned dataobject support to {@see GridFieldDetailForm_ItemRequest}
|
* Provides versioned dataobject support to {@see GridFieldDetailForm_ItemRequest}
|
||||||
*
|
*
|
||||||
@ -12,7 +19,7 @@ class VersionedGridFieldItemRequest extends GridFieldDetailForm_ItemRequest {
|
|||||||
|
|
||||||
// Check if record is versionable
|
// Check if record is versionable
|
||||||
$record = $this->getRecord();
|
$record = $this->getRecord();
|
||||||
if(!$record || !$record->has_extension('Versioned')) {
|
if(!$record || !$record->has_extension('SilverStripe\ORM\Versioning\Versioned')) {
|
||||||
return $actions;
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
@ -7,7 +7,7 @@ Injector:
|
|||||||
Upload:
|
Upload:
|
||||||
# Replace an existing file rather than renaming the new one.
|
# Replace an existing file rather than renaming the new one.
|
||||||
replaceFile: false
|
replaceFile: false
|
||||||
MySQLDatabase:
|
SilverStripe\ORM\Connect\MySQLDatabase:
|
||||||
# You are advised to backup your tables if changing settings on an existing database
|
# You are advised to backup your tables if changing settings on an existing database
|
||||||
# `connection_charset` and `charset` should be equal, similarly so should `connection_collation` and `collation`
|
# `connection_charset` and `charset` should be equal, similarly so should `connection_collation` and `collation`
|
||||||
connection_charset: utf8
|
connection_charset: utf8
|
||||||
|
@ -3,20 +3,24 @@ name: databaseconnectors
|
|||||||
---
|
---
|
||||||
Injector:
|
Injector:
|
||||||
MySQLPDODatabase:
|
MySQLPDODatabase:
|
||||||
class: 'MySQLDatabase'
|
class: 'SilverStripe\ORM\Connect\MySQLDatabase'
|
||||||
properties:
|
properties:
|
||||||
connector: %$PDOConnector
|
connector: %$PDOConnector
|
||||||
schemaManager: %$MySQLSchemaManager
|
schemaManager: %$MySQLSchemaManager
|
||||||
queryBuilder: %$MySQLQueryBuilder
|
queryBuilder: %$MySQLQueryBuilder
|
||||||
MySQLDatabase:
|
MySQLDatabase:
|
||||||
class: 'MySQLDatabase'
|
class: 'SilverStripe\ORM\Connect\MySQLDatabase'
|
||||||
properties:
|
properties:
|
||||||
connector: %$MySQLiConnector
|
connector: %$MySQLiConnector
|
||||||
schemaManager: %$MySQLSchemaManager
|
schemaManager: %$MySQLSchemaManager
|
||||||
queryBuilder: %$MySQLQueryBuilder
|
queryBuilder: %$MySQLQueryBuilder
|
||||||
MySQLiConnector:
|
MySQLiConnector:
|
||||||
class: 'MySQLiConnector'
|
class: 'SilverStripe\ORM\Connect\MySQLiConnector'
|
||||||
type: prototype
|
type: prototype
|
||||||
PDOConnector:
|
PDOConnector:
|
||||||
class: 'PDOConnector'
|
class: 'SilverStripe\ORM\Connect\PDOConnector'
|
||||||
type: prototype
|
type: prototype
|
||||||
|
MySQLSchemaManager:
|
||||||
|
class: 'SilverStripe\ORM\Connect\MySQLSchemaManager'
|
||||||
|
MySQLQueryBuilder:
|
||||||
|
class: 'SilverStripe\ORM\Connect\MySQLQueryBuilder'
|
||||||
|
@ -1,53 +1,53 @@
|
|||||||
Injector:
|
Injector:
|
||||||
Boolean:
|
Boolean:
|
||||||
class: SilverStripe\Model\FieldType\DBBoolean
|
class: SilverStripe\ORM\FieldType\DBBoolean
|
||||||
Currency:
|
Currency:
|
||||||
class: SilverStripe\Model\FieldType\DBCurrency
|
class: SilverStripe\ORM\FieldType\DBCurrency
|
||||||
DBClassName:
|
DBClassName:
|
||||||
class: SilverStripe\Model\FieldType\DBClassName
|
class: SilverStripe\ORM\FieldType\DBClassName
|
||||||
Date:
|
Date:
|
||||||
class: SilverStripe\Model\FieldType\DBDate
|
class: SilverStripe\ORM\FieldType\DBDate
|
||||||
Datetime:
|
Datetime:
|
||||||
class: SilverStripe\Model\FieldType\DBDatetime
|
class: SilverStripe\ORM\FieldType\DBDatetime
|
||||||
SS_Datetime:
|
DBDatetime:
|
||||||
class: SilverStripe\Model\FieldType\DBDatetime
|
class: SilverStripe\ORM\FieldType\DBDatetime
|
||||||
Decimal:
|
Decimal:
|
||||||
class: SilverStripe\Model\FieldType\DBDecimal
|
class: SilverStripe\ORM\FieldType\DBDecimal
|
||||||
Double:
|
Double:
|
||||||
class: SilverStripe\Model\FieldType\DBDouble
|
class: SilverStripe\ORM\FieldType\DBDouble
|
||||||
Enum:
|
Enum:
|
||||||
class: SilverStripe\Model\FieldType\DBEnum
|
class: SilverStripe\ORM\FieldType\DBEnum
|
||||||
DBFile:
|
DBFile:
|
||||||
class: SilverStripe\Filesystem\Storage\DBFile
|
class: SilverStripe\Filesystem\Storage\DBFile
|
||||||
Float:
|
Float:
|
||||||
class: SilverStripe\Model\FieldType\DBFloat
|
class: SilverStripe\ORM\FieldType\DBFloat
|
||||||
ForeignKey:
|
ForeignKey:
|
||||||
class: SilverStripe\Model\FieldType\DBForeignKey
|
class: SilverStripe\ORM\FieldType\DBForeignKey
|
||||||
HTMLText:
|
HTMLText:
|
||||||
class: SilverStripe\Model\FieldType\DBHTMLText
|
class: SilverStripe\ORM\FieldType\DBHTMLText
|
||||||
HTMLVarchar:
|
HTMLVarchar:
|
||||||
class: SilverStripe\Model\FieldType\DBHTMLVarchar
|
class: SilverStripe\ORM\FieldType\DBHTMLVarchar
|
||||||
Int:
|
Int:
|
||||||
class: SilverStripe\Model\FieldType\DBInt
|
class: SilverStripe\ORM\FieldType\DBInt
|
||||||
Locale:
|
Locale:
|
||||||
class: SilverStripe\Model\FieldType\DBLocale
|
class: SilverStripe\ORM\FieldType\DBLocale
|
||||||
DBLocale:
|
DBLocale:
|
||||||
class: SilverStripe\Model\FieldType\DBLocale
|
class: SilverStripe\ORM\FieldType\DBLocale
|
||||||
Money:
|
Money:
|
||||||
class: SilverStripe\Model\FieldType\DBMoney
|
class: SilverStripe\ORM\FieldType\DBMoney
|
||||||
MultiEnum:
|
MultiEnum:
|
||||||
class: SilverStripe\Model\FieldType\DBMultiEnum
|
class: SilverStripe\ORM\FieldType\DBMultiEnum
|
||||||
Percentage:
|
Percentage:
|
||||||
class: SilverStripe\Model\FieldType\DBPercentage
|
class: SilverStripe\ORM\FieldType\DBPercentage
|
||||||
PolymorphicForeignKey:
|
PolymorphicForeignKey:
|
||||||
class: SilverStripe\Model\FieldType\DBPolymorphicForeignKey
|
class: SilverStripe\ORM\FieldType\DBPolymorphicForeignKey
|
||||||
PrimaryKey:
|
PrimaryKey:
|
||||||
class: SilverStripe\Model\FieldType\DBPrimaryKey
|
class: SilverStripe\ORM\FieldType\DBPrimaryKey
|
||||||
Text:
|
Text:
|
||||||
class: SilverStripe\Model\FieldType\DBText
|
class: SilverStripe\ORM\FieldType\DBText
|
||||||
Time:
|
Time:
|
||||||
class: SilverStripe\Model\FieldType\DBTime
|
class: SilverStripe\ORM\FieldType\DBTime
|
||||||
Varchar:
|
Varchar:
|
||||||
class: SilverStripe\Model\FieldType\DBVarchar
|
class: SilverStripe\ORM\FieldType\DBVarchar
|
||||||
Year:
|
Year:
|
||||||
class: SilverStripe\Model\FieldType\DBYear
|
class: SilverStripe\ORM\FieldType\DBYear
|
||||||
|
@ -3,4 +3,4 @@ Name: versioning
|
|||||||
---
|
---
|
||||||
GridFieldDetailForm:
|
GridFieldDetailForm:
|
||||||
extensions:
|
extensions:
|
||||||
- VersionedGridFieldDetailForm
|
- SilverStripe\ORM\Versioning\VersionedGridFieldDetailForm
|
||||||
|
@ -6,7 +6,7 @@ $frameworkPath = defined('FRAMEWORK_PATH') ? FRAMEWORK_PATH : FRAMEWORK_NAME;
|
|||||||
// Use MySQLi as default
|
// Use MySQLi as default
|
||||||
DatabaseAdapterRegistry::register(
|
DatabaseAdapterRegistry::register(
|
||||||
array(
|
array(
|
||||||
'class' => 'MySQLDatabase',
|
'class' => 'SilverStripe\\ORM\\Connect\\MySQLDatabase',
|
||||||
'title' => 'MySQL 5.0+ (using MySQLi)',
|
'title' => 'MySQL 5.0+ (using MySQLi)',
|
||||||
'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php',
|
'helperPath' => $frameworkPath . '/dev/install/MySQLDatabaseConfigurationHelper.php',
|
||||||
'supported' => class_exists('MySQLi'),
|
'supported' => class_exists('MySQLi'),
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Framework\Core\Injectable;
|
use SilverStripe\Framework\Core\Injectable;
|
||||||
use SilverStripe\Model\FieldType\DBHTMLText;
|
|
||||||
|
use SilverStripe\ORM\Versioning\ChangeSet;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Versioning\ChangeSetItem;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -97,7 +101,7 @@ class AddToCampaignHandler {
|
|||||||
$id = (int)$id;
|
$id = (int)$id;
|
||||||
$class = ClassInfo::class_name($class);
|
$class = ClassInfo::class_name($class);
|
||||||
|
|
||||||
if (!$class || !is_subclass_of($class, 'DataObject') || !Object::has_extension($class, 'Versioned')) {
|
if (!$class || !is_subclass_of($class, 'SilverStripe\\ORM\\DataObject') || !Object::has_extension($class, 'SilverStripe\\ORM\\Versioning\\Versioned')) {
|
||||||
$this->editForm->httpError(400, _t(
|
$this->editForm->httpError(400, _t(
|
||||||
'AddToCampaign.ErrorGeneral',
|
'AddToCampaign.ErrorGeneral',
|
||||||
'We apologise, but there was an error'
|
'We apologise, but there was an error'
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage admin
|
* @subpackage admin
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class representing back actions.
|
* A class representing back actions.
|
||||||
* See CMSMain.BatchActions.js on how to add custom javascript
|
* See CMSMain.BatchActions.js on how to add custom javascript
|
||||||
@ -148,7 +152,7 @@ abstract class CMSBatchAction extends Object {
|
|||||||
}
|
}
|
||||||
$onlyOnLive = array_keys($onlyOnLive);
|
$onlyOnLive = array_keys($onlyOnLive);
|
||||||
|
|
||||||
if($checkLivePages && $onlyOnLive && Object::has_extension($managedClass, 'Versioned')) {
|
if($checkLivePages && $onlyOnLive && Object::has_extension($managedClass, 'SilverStripe\\ORM\\Versioning\\Versioned')) {
|
||||||
// Get the pages that only exist on live (deleted from stage)
|
// Get the pages that only exist on live (deleted from stage)
|
||||||
$livePages = Versioned::get_by_stage($managedClass, "Live")->byIDs($onlyOnLive);
|
$livePages = Versioned::get_by_stage($managedClass, "Live")->byIDs($onlyOnLive);
|
||||||
foreach($livePages as $obj) {
|
foreach($livePages as $obj) {
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Special request handler for admin/batchaction
|
* Special request handler for admin/batchaction
|
||||||
*
|
*
|
||||||
@ -273,7 +278,7 @@ class CMSBatchActionHandler extends RequestHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Bypass versioned filter
|
// Bypass versioned filter
|
||||||
if($recordClass::has_extension('Versioned')) {
|
if($recordClass::has_extension('SilverStripe\\ORM\\Versioning\\Versioned')) {
|
||||||
// Workaround for get_including_deleted not supporting byIDs filter very well
|
// Workaround for get_including_deleted not supporting byIDs filter very well
|
||||||
// Ensure we select both stage / live records
|
// Ensure we select both stage / live records
|
||||||
$pages = Versioned::get_including_deleted($recordClass, array(
|
$pages = Versioned::get_including_deleted($recordClass, array(
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage admin
|
* @subpackage admin
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Versioning\ChangeSet;
|
||||||
|
use SilverStripe\ORM\Versioning\ChangeSetItem;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Campaign section of the CMS
|
* Campaign section of the CMS
|
||||||
*
|
*
|
||||||
@ -23,7 +27,7 @@ class CampaignAdmin extends LeftAndMain implements PermissionProvider {
|
|||||||
|
|
||||||
private static $menu_title = 'Campaigns';
|
private static $menu_title = 'Campaigns';
|
||||||
|
|
||||||
private static $tree_class = 'ChangeSet';
|
private static $tree_class = 'SilverStripe\\ORM\\Versioning\\ChangeSet';
|
||||||
|
|
||||||
private static $url_handlers = [
|
private static $url_handlers = [
|
||||||
'GET sets' => 'readCampaigns',
|
'GET sets' => 'readCampaigns',
|
||||||
|
@ -6,7 +6,16 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
use SilverStripe\Forms\Schema\FormSchema;
|
use SilverStripe\Forms\Schema\FormSchema;
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* LeftAndMain is the parent class of all the two-pane views in the CMS.
|
* LeftAndMain is the parent class of all the two-pane views in the CMS.
|
||||||
@ -900,7 +909,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
|||||||
));
|
));
|
||||||
$record = $this->currentPage();
|
$record = $this->currentPage();
|
||||||
if($record && $record->exists()) {
|
if($record && $record->exists()) {
|
||||||
if($record->hasExtension('Hierarchy')) {
|
if($record->hasExtension('SilverStripe\\ORM\\Hierarchy\\Hierarchy')) {
|
||||||
$ancestors = $record->getAncestors();
|
$ancestors = $record->getAncestors();
|
||||||
$ancestors = new ArrayList(array_reverse($ancestors->toArray()));
|
$ancestors = new ArrayList(array_reverse($ancestors->toArray()));
|
||||||
$ancestors->push($record);
|
$ancestors->push($record);
|
||||||
@ -1022,7 +1031,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
|||||||
// Limit the amount of nodes shown for performance reasons.
|
// Limit the amount of nodes shown for performance reasons.
|
||||||
// Skip the check if we're filtering the tree, since its not clear how many children will
|
// Skip the check if we're filtering the tree, since its not clear how many children will
|
||||||
// match the filter criteria until they're queried (and matched up with previously marked nodes).
|
// match the filter criteria until they're queried (and matched up with previously marked nodes).
|
||||||
$nodeThresholdLeaf = Config::inst()->get('Hierarchy', 'node_threshold_leaf');
|
$nodeThresholdLeaf = Config::inst()->get('SilverStripe\\ORM\\Hierarchy\\Hierarchy', 'node_threshold_leaf');
|
||||||
if($nodeThresholdLeaf && !$filterFunction) {
|
if($nodeThresholdLeaf && !$filterFunction) {
|
||||||
$nodeCountCallback = function($parent, $numChildren) use(&$controller, $className, $nodeThresholdLeaf) {
|
$nodeCountCallback = function($parent, $numChildren) use(&$controller, $className, $nodeThresholdLeaf) {
|
||||||
if($className == 'SiteTree' && $parent->ID && $numChildren > $nodeThresholdLeaf) {
|
if($className == 'SiteTree' && $parent->ID && $numChildren > $nodeThresholdLeaf) {
|
||||||
@ -1417,7 +1426,7 @@ class LeftAndMain extends Controller implements PermissionProvider {
|
|||||||
|
|
||||||
$tree_class = $this->stat('tree_class');
|
$tree_class = $this->stat('tree_class');
|
||||||
if(
|
if(
|
||||||
$tree_class::has_extension('Hierarchy')
|
$tree_class::has_extension('SilverStripe\\ORM\\Hierarchy\\Hierarchy')
|
||||||
&& !$fields->dataFieldByName('ParentID')
|
&& !$fields->dataFieldByName('ParentID')
|
||||||
) {
|
) {
|
||||||
$fields->push(new HiddenField('ParentID'));
|
$fields->push(new HiddenField('ParentID'));
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Generates a three-pane UI for editing model classes, with an
|
* Generates a three-pane UI for editing model classes, with an
|
||||||
* automatically generated search panel, tabular results and edit forms.
|
* automatically generated search panel, tabular results and edit forms.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -299,7 +301,7 @@ class LeftAndMainTest_Object extends DataObject implements TestOnly {
|
|||||||
private static $default_sort = '"Sort"';
|
private static $default_sort = '"Sort"';
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Hierarchy'
|
'SilverStripe\\ORM\\Hierarchy\\Hierarchy'
|
||||||
);
|
);
|
||||||
|
|
||||||
public function CMSTreeClasses() {}
|
public function CMSTreeClasses() {}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class ModelAdminTest extends FunctionalTest {
|
class ModelAdminTest extends FunctionalTest {
|
||||||
protected static $fixture_file = 'ModelAdminTest.yml';
|
protected static $fixture_file = 'ModelAdminTest.yml';
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
/**
|
/**
|
||||||
* A DataFormatter object handles transformation of data from SilverStripe model objects to a particular output
|
* A DataFormatter object handles transformation of data from SilverStripe model objects to a particular output
|
||||||
* format, and vice versa. This is most commonly used in developing RESTful APIs.
|
* format, and vice versa. This is most commonly used in developing RESTful APIs.
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage formatters
|
* @subpackage formatters
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* RSSFeed class
|
* RSSFeed class
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage formatters
|
* @subpackage formatters
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* File similar to main.php designed for command-line scripts
|
* File similar to main.php designed for command-line scripts
|
||||||
*
|
*
|
||||||
@ -77,7 +80,7 @@ global $databaseConfig;
|
|||||||
// We don't have a session in cli-script, but this prevents errors
|
// We don't have a session in cli-script, but this prevents errors
|
||||||
$_SESSION = null;
|
$_SESSION = null;
|
||||||
|
|
||||||
require_once("model/DB.php");
|
require_once("ORM/DB.php");
|
||||||
|
|
||||||
|
|
||||||
// Connect to database
|
// Connect to database
|
||||||
|
@ -92,8 +92,9 @@ if(!isset($database) || !$database) {
|
|||||||
|
|
||||||
if(defined('SS_DATABASE_USERNAME') && defined('SS_DATABASE_PASSWORD')) {
|
if(defined('SS_DATABASE_USERNAME') && defined('SS_DATABASE_PASSWORD')) {
|
||||||
global $databaseConfig;
|
global $databaseConfig;
|
||||||
|
/** @skipUpgrade */
|
||||||
$databaseConfig = array(
|
$databaseConfig = array(
|
||||||
"type" => defined('SS_DATABASE_CLASS') ? SS_DATABASE_CLASS : "MySQLDatabase",
|
"type" => defined('SS_DATABASE_CLASS') ? SS_DATABASE_CLASS : 'MySQLDatabase',
|
||||||
"server" => defined('SS_DATABASE_SERVER') ? SS_DATABASE_SERVER : 'localhost',
|
"server" => defined('SS_DATABASE_SERVER') ? SS_DATABASE_SERVER : 'localhost',
|
||||||
"username" => SS_DATABASE_USERNAME,
|
"username" => SS_DATABASE_USERNAME,
|
||||||
"password" => SS_DATABASE_PASSWORD,
|
"password" => SS_DATABASE_PASSWORD,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controllers are the cornerstone of all site functionality in SilverStripe. The {@link Director}
|
* Controllers are the cornerstone of all site functionality in SilverStripe. The {@link Director}
|
||||||
* selects a controller to pass control to, and then calls {@link run()}. This method will execute
|
* selects a controller to pass control to, and then calls {@link run()}. This method will execute
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A default backend for the setting and getting of cookies
|
* A default backend for the setting and getting of cookies
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
/**
|
/**
|
||||||
* Director is responsible for processing URLs, and providing environment information.
|
* Director is responsible for processing URLs, and providing environment information.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
/**
|
/**
|
||||||
* Triggers a call to flush() on all implementors of Flushable.
|
* Triggers a call to flush() on all implementors of Flushable.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A request filter is an object that's executed before and after a
|
* A request filter is an object that's executed before and after a
|
||||||
* request occurs. By returning 'false' from the preRequest method,
|
* request occurs. By returning 'false' from the preRequest method,
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is the base class of any SilverStripe object that can be used to handle HTTP requests.
|
* This class is the base class of any SilverStripe object that can be used to handle HTTP requests.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a request processer that delegates pre and post request handling to nested request filters
|
* Represents a request processer that delegates pre and post request handling to nested request filters
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialises the versioned stage when a request is made.
|
* Initialises the versioned stage when a request is made.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides introspection information about the class tree.
|
* Provides introspection information about the class tree.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
/**
|
/**
|
||||||
* Library of conversion functions, implemented as static methods.
|
* Library of conversion functions, implemented as static methods.
|
||||||
*
|
*
|
||||||
|
@ -6,6 +6,7 @@ use ClassInfo;
|
|||||||
use Config;
|
use Config;
|
||||||
use Extension;
|
use Extension;
|
||||||
use Injector;
|
use Injector;
|
||||||
|
use InvalidArgumentException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Allows an object to have extensions applied to it.
|
* Allows an object to have extensions applied to it.
|
||||||
@ -205,8 +206,8 @@ trait Extensible {
|
|||||||
Injector::inst()->unregisterNamedObject($class);
|
Injector::inst()->unregisterNamedObject($class);
|
||||||
|
|
||||||
// load statics now for DataObject classes
|
// load statics now for DataObject classes
|
||||||
if(is_subclass_of($class, 'DataObject')) {
|
if(is_subclass_of($class, 'SilverStripe\\ORM\\DataObject')) {
|
||||||
if(!is_subclass_of($extensionClass, 'DataExtension')) {
|
if(!is_subclass_of($extensionClass, 'SilverStripe\\ORM\\DataExtension')) {
|
||||||
user_error("$extensionClass cannot be applied to $class without being a DataExtension", E_USER_ERROR);
|
user_error("$extensionClass cannot be applied to $class without being a DataExtension", E_USER_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -315,6 +316,10 @@ trait Extensible {
|
|||||||
list($extensionClass, $extensionArgs) = \Object::parse_class_spec($extension);
|
list($extensionClass, $extensionArgs) = \Object::parse_class_spec($extension);
|
||||||
$sources[] = $extensionClass;
|
$sources[] = $extensionClass;
|
||||||
|
|
||||||
|
if (!class_exists($extensionClass)) {
|
||||||
|
throw new InvalidArgumentException("$class references nonexistent $extensionClass in \$extensions");
|
||||||
|
}
|
||||||
|
|
||||||
call_user_func(array($extensionClass, 'add_to_class'), $class, $extensionClass, $extensionArgs);
|
call_user_func(array($extensionClass, 'add_to_class'), $class, $extensionClass, $extensionArgs);
|
||||||
|
|
||||||
foreach(array_reverse(ClassInfo::ancestry($extensionClass)) as $extensionClassParent) {
|
foreach(array_reverse(ClassInfo::ancestry($extensionClass)) as $extensionClassParent) {
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\SS_ListDecorator;
|
||||||
/**
|
/**
|
||||||
* A decorator that wraps around a data list in order to provide pagination.
|
* A decorator that wraps around a data list in order to provide pagination.
|
||||||
*
|
*
|
||||||
|
@ -19,11 +19,11 @@ class SS_Backtrace {
|
|||||||
array('PDO', '__construct'),
|
array('PDO', '__construct'),
|
||||||
array('mysqli', 'mysqli'),
|
array('mysqli', 'mysqli'),
|
||||||
array('mysqli', 'select_db'),
|
array('mysqli', 'select_db'),
|
||||||
array('DB', 'connect'),
|
array('SilverStripe\\ORM\\DB', 'connect'),
|
||||||
array('Security', 'check_default_admin'),
|
array('Security', 'check_default_admin'),
|
||||||
array('Security', 'encrypt_password'),
|
array('Security', 'encrypt_password'),
|
||||||
array('Security', 'setDefaultAdmin'),
|
array('Security', 'setDefaultAdmin'),
|
||||||
array('DB', 'createDatabase'),
|
array('SilverStripe\\ORM\\DB', 'createDatabase'),
|
||||||
array('Member', 'checkPassword'),
|
array('Member', 'checkPassword'),
|
||||||
array('Member', 'changePassword'),
|
array('Member', 'changePassword'),
|
||||||
array('MemberPassword', 'checkPassword'),
|
array('MemberPassword', 'checkPassword'),
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* A base for bulk loaders of content into the SilverStripe database.
|
* A base for bulk loaders of content into the SilverStripe database.
|
||||||
* Bulk loaders give SilverStripe authors the ability to do large-scale uploads into their SilverStripe databases.
|
* Bulk loaders give SilverStripe authors the ability to do large-scale uploads into their SilverStripe databases.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Utility class to facilitate complex CSV-imports by defining column-mappings
|
* Utility class to facilitate complex CSV-imports by defining column-mappings
|
||||||
* and custom converters.
|
* and custom converters.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supports debugging and core error handling.
|
* Supports debugging and core error handling.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DatabaseAdmin;
|
||||||
|
|
||||||
class DevBuildController extends Controller {
|
class DevBuildController extends Controller {
|
||||||
|
|
||||||
private static $url_handlers = array(
|
private static $url_handlers = array(
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DatabaseAdmin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for development tools.
|
* Base class for development tools.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* A blueprint on how to create instances of a certain {@link DataObject} subclass.
|
* A blueprint on how to create instances of a certain {@link DataObject} subclass.
|
||||||
*
|
*
|
||||||
@ -46,7 +50,7 @@ class FixtureBlueprint {
|
|||||||
public function __construct($name, $class = null, $defaults = array()) {
|
public function __construct($name, $class = null, $defaults = array()) {
|
||||||
if(!$class) $class = $name;
|
if(!$class) $class = $name;
|
||||||
|
|
||||||
if(!is_subclass_of($class, 'DataObject')) {
|
if(!is_subclass_of($class, 'SilverStripe\\ORM\\DataObject')) {
|
||||||
throw new InvalidArgumentException(sprintf(
|
throw new InvalidArgumentException(sprintf(
|
||||||
'Class "%s" is not a valid subclass of DataObject',
|
'Class "%s" is not a valid subclass of DataObject',
|
||||||
$class
|
$class
|
||||||
@ -73,7 +77,7 @@ class FixtureBlueprint {
|
|||||||
// which they are imported doesnt guarantee valid relations until after the import is complete.
|
// which they are imported doesnt guarantee valid relations until after the import is complete.
|
||||||
// Also disable filesystem manipulations
|
// Also disable filesystem manipulations
|
||||||
Config::nest();
|
Config::nest();
|
||||||
Config::inst()->update('DataObject', 'validation_enabled', false);
|
Config::inst()->update('SilverStripe\\ORM\\DataObject', 'validation_enabled', false);
|
||||||
Config::inst()->update('File', 'update_filesystem', false);
|
Config::inst()->update('File', 'update_filesystem', false);
|
||||||
|
|
||||||
$this->invokeCallbacks('beforeCreate', array($identifier, &$data, &$fixtures));
|
$this->invokeCallbacks('beforeCreate', array($identifier, &$data, &$fixtures));
|
||||||
@ -184,7 +188,7 @@ class FixtureBlueprint {
|
|||||||
if($className = $obj->hasOneComponent($hasOneField)) {
|
if($className = $obj->hasOneComponent($hasOneField)) {
|
||||||
$obj->{$hasOneField.'ID'} = $this->parseValue($fieldVal, $fixtures, $fieldClass);
|
$obj->{$hasOneField.'ID'} = $this->parseValue($fieldVal, $fixtures, $fieldClass);
|
||||||
// Inject class for polymorphic relation
|
// Inject class for polymorphic relation
|
||||||
if($className === 'DataObject') {
|
if($className === 'SilverStripe\\ORM\\DataObject') {
|
||||||
$obj->{$hasOneField.'Class'} = $fieldClass;
|
$obj->{$hasOneField.'Class'} = $fieldClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Queries\SQLInsert;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Queries\SQLDelete;
|
||||||
/**
|
/**
|
||||||
* Manages a set of database fixtures for {@link DataObject} records
|
* Manages a set of database fixtures for {@link DataObject} records
|
||||||
* as well as raw database table rows.
|
* as well as raw database table rows.
|
||||||
|
@ -1,7 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Hierarchy\Hierarchy;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test case class for the Sapphire framework.
|
* Test case class for the Sapphire framework.
|
||||||
@ -179,7 +187,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
Config::nest();
|
Config::nest();
|
||||||
Injector::nest();
|
Injector::nest();
|
||||||
|
|
||||||
$this->originalReadingMode = \Versioned::get_reading_mode();
|
$this->originalReadingMode = Versioned::get_reading_mode();
|
||||||
|
|
||||||
// We cannot run the tests on this abstract class.
|
// We cannot run the tests on this abstract class.
|
||||||
if(get_class($this) == "SapphireTest") {
|
if(get_class($this) == "SapphireTest") {
|
||||||
@ -232,7 +240,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
self::create_temp_db();
|
self::create_temp_db();
|
||||||
}
|
}
|
||||||
|
|
||||||
singleton('DataObject')->flushCache();
|
singleton('SilverStripe\\ORM\\DataObject')->flushCache();
|
||||||
|
|
||||||
self::empty_temp_db();
|
self::empty_temp_db();
|
||||||
|
|
||||||
@ -523,7 +531,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
$controller->response->removeHeader('Location');
|
$controller->response->removeHeader('Location');
|
||||||
}
|
}
|
||||||
|
|
||||||
\Versioned::set_reading_mode($this->originalReadingMode);
|
Versioned::set_reading_mode($this->originalReadingMode);
|
||||||
|
|
||||||
//unnest injector / config now that tests are over
|
//unnest injector / config now that tests are over
|
||||||
Injector::unnest();
|
Injector::unnest();
|
||||||
@ -866,7 +874,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
if($dbName && DB::get_conn()->databaseExists($dbName)) {
|
if($dbName && DB::get_conn()->databaseExists($dbName)) {
|
||||||
// Some DataExtensions keep a static cache of information that needs to
|
// Some DataExtensions keep a static cache of information that needs to
|
||||||
// be reset whenever the database is killed
|
// be reset whenever the database is killed
|
||||||
foreach(ClassInfo::subclassesFor('DataExtension') as $class) {
|
foreach(ClassInfo::subclassesFor('SilverStripe\\ORM\\DataExtension') as $class) {
|
||||||
$toCall = array($class, 'on_db_reset');
|
$toCall = array($class, 'on_db_reset');
|
||||||
if(is_callable($toCall)) call_user_func($toCall);
|
if(is_callable($toCall)) call_user_func($toCall);
|
||||||
}
|
}
|
||||||
@ -886,7 +894,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
// Some DataExtensions keep a static cache of information that needs to
|
// Some DataExtensions keep a static cache of information that needs to
|
||||||
// be reset whenever the database is cleaned out
|
// be reset whenever the database is cleaned out
|
||||||
$classes = array_merge(ClassInfo::subclassesFor('DataExtension'), ClassInfo::subclassesFor('DataObject'));
|
$classes = array_merge(ClassInfo::subclassesFor('SilverStripe\\ORM\\DataExtension'), ClassInfo::subclassesFor('SilverStripe\\ORM\\DataObject'));
|
||||||
foreach($classes as $class) {
|
foreach($classes as $class) {
|
||||||
$toCall = array($class, 'on_db_reset');
|
$toCall = array($class, 'on_db_reset');
|
||||||
if(is_callable($toCall)) call_user_func($toCall);
|
if(is_callable($toCall)) call_user_func($toCall);
|
||||||
@ -946,7 +954,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
// clear singletons, they're caching old extension info which is used in DatabaseAdmin->doBuild()
|
||||||
Injector::inst()->unregisterAllObjects();
|
Injector::inst()->unregisterAllObjects();
|
||||||
|
|
||||||
$dataClasses = ClassInfo::subclassesFor('DataObject');
|
$dataClasses = ClassInfo::subclassesFor('SilverStripe\\ORM\\DataObject');
|
||||||
array_shift($dataClasses);
|
array_shift($dataClasses);
|
||||||
|
|
||||||
DB::quiet();
|
DB::quiet();
|
||||||
@ -971,7 +979,7 @@ class SapphireTest extends PHPUnit_Framework_TestCase {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ClassInfo::reset_db_cache();
|
ClassInfo::reset_db_cache();
|
||||||
singleton('DataObject')->flushCache();
|
singleton('SilverStripe\\ORM\\DataObject')->flushCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class MySQLDatabaseConfigurationHelper implements DatabaseConfigurationHelper {
|
|||||||
$error = null;
|
$error = null;
|
||||||
try {
|
try {
|
||||||
switch($databaseConfig['type']) {
|
switch($databaseConfig['type']) {
|
||||||
case 'MySQLDatabase':
|
case 'SilverStripe\\ORM\\Connect\\MySQLDatabase':
|
||||||
$conn = @new MySQLi($databaseConfig['server'], $databaseConfig['username'],
|
$conn = @new MySQLi($databaseConfig['server'], $databaseConfig['username'],
|
||||||
$databaseConfig['password']);
|
$databaseConfig['password']);
|
||||||
if($conn && empty($conn->connect_errno)) {
|
if($conn && empty($conn->connect_errno)) {
|
||||||
|
@ -2,12 +2,16 @@
|
|||||||
|
|
||||||
namespace SilverStripe\Filesystem;
|
namespace SilverStripe\Filesystem;
|
||||||
|
|
||||||
use DataObject;
|
|
||||||
use Injector;
|
use Injector;
|
||||||
use Member;
|
use Member;
|
||||||
use Versioned;
|
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
use SilverStripe\Filesystem\Storage\DBFile;
|
use SilverStripe\Filesystem\Storage\DBFile;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides the necessary business logic to ensure that any assets attached
|
* This class provides the necessary business logic to ensure that any assets attached
|
||||||
@ -24,7 +28,7 @@ use SilverStripe\Filesystem\Storage\DBFile;
|
|||||||
*
|
*
|
||||||
* @property DataObject|Versioned $owner A {@see DataObject}, potentially decorated with {@see Versioned} extension.
|
* @property DataObject|Versioned $owner A {@see DataObject}, potentially decorated with {@see Versioned} extension.
|
||||||
*/
|
*/
|
||||||
class AssetControlExtension extends \DataExtension
|
class AssetControlExtension extends DataExtension
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -235,7 +239,7 @@ class AssetControlExtension extends \DataExtension
|
|||||||
*/
|
*/
|
||||||
protected function isVersioned()
|
protected function isVersioned()
|
||||||
{
|
{
|
||||||
return $this->owner->has_extension('Versioned') && class_exists('Versioned');
|
return $this->owner->has_extension('SilverStripe\\ORM\\Versioning\\Versioned') && class_exists('SilverStripe\\ORM\\Versioning\\Versioned');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -4,6 +4,12 @@ use SilverStripe\Filesystem\Storage\DBFile;
|
|||||||
use SilverStripe\Filesystem\Thumbnail;
|
use SilverStripe\Filesystem\Thumbnail;
|
||||||
use SilverStripe\Filesystem\ImageManipulation;
|
use SilverStripe\Filesystem\ImageManipulation;
|
||||||
use SilverStripe\Filesystem\Storage\AssetContainer;
|
use SilverStripe\Filesystem\Storage\AssetContainer;
|
||||||
|
use SilverStripe\ORM\Hierarchy\Hierarchy;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class handles the representation of a file on the filesystem within the framework.
|
* This class handles the representation of a file on the filesystem within the framework.
|
||||||
@ -102,8 +108,8 @@ class File extends DataObject implements ShortcodeHandler, AssetContainer, Thumb
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Hierarchy",
|
"SilverStripe\\ORM\\Hierarchy\\Hierarchy",
|
||||||
"Versioned"
|
"SilverStripe\\ORM\\Versioning\\Versioned"
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $casting = array (
|
private static $casting = array (
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Service to help migrate File dataobjects to the new APL.
|
* Service to help migrate File dataobjects to the new APL.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* A collection of static methods for manipulating the filesystem.
|
* A collection of static methods for manipulating the filesystem.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
/**
|
/**
|
||||||
* Represents a logical folder, which may be used to organise assets
|
* Represents a logical folder, which may be used to organise assets
|
||||||
* stored in the configured backend.
|
* stored in the configured backend.
|
||||||
|
@ -4,14 +4,16 @@ namespace SilverStripe\Filesystem;
|
|||||||
|
|
||||||
use Config;
|
use Config;
|
||||||
use Convert;
|
use Convert;
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Filesystem\Storage\DBFile;
|
use SilverStripe\Filesystem\Storage\DBFile;
|
||||||
use Image_Backend;
|
use Image_Backend;
|
||||||
use Injector;
|
use Injector;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use SilverStripe\Filesystem\Storage\AssetContainer;
|
use SilverStripe\Filesystem\Storage\AssetContainer;
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
use SilverStripe\Model\FieldType\DBHTMLText;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides image manipulation functionality.
|
* Provides image manipulation functionality.
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
use SilverStripe\Filesystem\Storage\AssetContainer;
|
use SilverStripe\Filesystem\Storage\AssetContainer;
|
||||||
use SilverStripe\Filesystem\Storage\AssetNameGenerator;
|
use SilverStripe\Filesystem\Storage\AssetNameGenerator;
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages uploads via HTML forms processed by PHP,
|
* Manages uploads via HTML forms processed by PHP,
|
||||||
|
@ -3,6 +3,8 @@
|
|||||||
namespace SilverStripe\Filesystem\Flysystem;
|
namespace SilverStripe\Filesystem\Flysystem;
|
||||||
|
|
||||||
use League\Flysystem\Adapter\Local;
|
use League\Flysystem\Adapter\Local;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adapter for local filesystem based on assets directory
|
* Adapter for local filesystem based on assets directory
|
||||||
@ -121,7 +123,7 @@ class AssetAdapter extends Local {
|
|||||||
*/
|
*/
|
||||||
protected function renderTemplate($template) {
|
protected function renderTemplate($template) {
|
||||||
// Build allowed extensions
|
// Build allowed extensions
|
||||||
$allowedExtensions = new \ArrayList();
|
$allowedExtensions = new ArrayList();
|
||||||
foreach(\File::config()->allowed_extensions as $extension) {
|
foreach(\File::config()->allowed_extensions as $extension) {
|
||||||
if($extension) {
|
if($extension) {
|
||||||
$allowedExtensions->push(new \ArrayData(array(
|
$allowedExtensions->push(new \ArrayData(array(
|
||||||
|
@ -4,15 +4,19 @@ namespace SilverStripe\Filesystem\Storage;
|
|||||||
|
|
||||||
use SilverStripe\Filesystem\Thumbnail;
|
use SilverStripe\Filesystem\Thumbnail;
|
||||||
use SilverStripe\Filesystem\ImageManipulation;
|
use SilverStripe\Filesystem\ImageManipulation;
|
||||||
use SilverStripe\Model\FieldType\DBComposite;
|
|
||||||
|
|
||||||
use Injector;
|
use Injector;
|
||||||
use AssetField;
|
use AssetField;
|
||||||
use File;
|
use File;
|
||||||
use Director;
|
use Director;
|
||||||
use Permission;
|
use Permission;
|
||||||
use ValidationResult;
|
|
||||||
use ValidationException;
|
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\ORM\FieldType\DBComposite;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a file reference stored in a database
|
* Represents a file reference stored in a database
|
||||||
|
@ -3,6 +3,10 @@
|
|||||||
use SilverStripe\Filesystem\Storage\AssetContainer;
|
use SilverStripe\Filesystem\Storage\AssetContainer;
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
use SilverStripe\Filesystem\Storage\DBFile;
|
use SilverStripe\Filesystem\Storage\DBFile;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field for uploading into a DBFile instance.
|
* Field for uploading into a DBFile instance.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Displays a set of checkboxes as a logical group.
|
* Displays a set of checkboxes as a logical group.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Two masked input fields, checks for matching passwords.
|
* Two masked input fields, checks for matching passwords.
|
||||||
*
|
*
|
||||||
|
@ -17,7 +17,7 @@ class CurrencyField extends TextField {
|
|||||||
*/
|
*/
|
||||||
public function setValue($val) {
|
public function setValue($val) {
|
||||||
if(!$val) $val = 0.00;
|
if(!$val) $val = 0.00;
|
||||||
$this->value = Config::inst()->get('SilverStripe\Model\FieldType\DBCurrency','currency_symbol') . number_format((double)preg_replace('/[^0-9.\-]/', '', $val), 2);
|
$this->value = Config::inst()->get('SilverStripe\\ORM\\FieldType\\DBCurrency','currency_symbol') . number_format((double)preg_replace('/[^0-9.\-]/', '', $val), 2);
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -44,7 +44,7 @@ class CurrencyField extends TextField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function validate($validator) {
|
public function validate($validator) {
|
||||||
$currencySymbol = preg_quote(Config::inst()->get('SilverStripe\Model\FieldType\DBCurrency', 'currency_symbol'));
|
$currencySymbol = preg_quote(Config::inst()->get('SilverStripe\\ORM\\FieldType\\DBCurrency', 'currency_symbol'));
|
||||||
$regex = '/^\s*(\-?'.$currencySymbol.'?|'.$currencySymbol.'\-?)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*$/';
|
$regex = '/^\s*(\-?'.$currencySymbol.'?|'.$currencySymbol.'\-?)?(\d{1,3}(\,\d{3})*|(\d+))(\.\d{2})?\s*$/';
|
||||||
if(!empty ($this->value)
|
if(!empty ($this->value)
|
||||||
&& !preg_match($regex, $this->value)) {
|
&& !preg_match($regex, $this->value)) {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBDate;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBDate;
|
||||||
|
|
||||||
|
|
||||||
require_once 'Zend/Date.php';
|
require_once 'Zend/Date.php';
|
||||||
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A composite field for date and time entry,
|
* A composite field for date and time entry,
|
||||||
* based on {@link DateField} and {@link TimeField}.
|
* based on {@link DateField} and {@link TimeField}.
|
||||||
* Usually saves into a single {@link SS_Datetime} database column.
|
* Usually saves into a single {@link DBDateTime} database column.
|
||||||
* If you want to save into {@link Date} or {@link Time} columns,
|
* If you want to save into {@link Date} or {@link Time} columns,
|
||||||
* please instanciate the fields separately.
|
* please instanciate the fields separately.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Dropdown field, created from a <select> tag.
|
* Dropdown field, created from a <select> tag.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* A list designed to hold form field instances.
|
* A list designed to hold form field instances.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
/**
|
/**
|
||||||
* Represents a file type which can be added to a form.
|
* Represents a file type which can be added to a form.
|
||||||
* Automatically tries to save has_one-relations on the saved
|
* Automatically tries to save has_one-relations on the saved
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
/**
|
/**
|
||||||
* Base class for all forms.
|
* Base class for all forms.
|
||||||
* The form class is an extensible base for all forms on a SilverStripe application. It can be used
|
* The form class is an extensible base for all forms on a SilverStripe application. It can be used
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a field in a form.
|
* Represents a field in a form.
|
||||||
*
|
*
|
||||||
|
@ -104,7 +104,7 @@ class FormScaffolder extends Object {
|
|||||||
if($this->obj->hasOne()) {
|
if($this->obj->hasOne()) {
|
||||||
foreach($this->obj->hasOne() as $relationship => $component) {
|
foreach($this->obj->hasOne() as $relationship => $component) {
|
||||||
if($this->restrictFields && !in_array($relationship, $this->restrictFields)) continue;
|
if($this->restrictFields && !in_array($relationship, $this->restrictFields)) continue;
|
||||||
$fieldName = $component === 'DataObject'
|
$fieldName = $component === 'SilverStripe\\ORM\\DataObject'
|
||||||
? $relationship // Polymorphic has_one field is composite, so don't refer to ID subfield
|
? $relationship // Polymorphic has_one field is composite, so don't refer to ID subfield
|
||||||
: "{$relationship}ID";
|
: "{$relationship}ID";
|
||||||
if($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
|
if($this->fieldClasses && isset($this->fieldClasses[$fieldName])) {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Grouped dropdown, using <optgroup> tags.
|
* Grouped dropdown, using <optgroup> tags.
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render a button that will submit the form its contained in through ajax.
|
* Render a button that will submit the form its contained in through ajax.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Multi-line listbox field, created from a <select> tag.
|
* Multi-line listbox field, created from a <select> tag.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read-only complement of {@link DropdownField}.
|
* Read-only complement of {@link DropdownField}.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage security
|
* @subpackage security
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBMoney;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\FieldType\DBMoney;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A form field that can save into a {@link Money} database field.
|
* A form field that can save into a {@link Money} database field.
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\Relation;
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
use SilverStripe\ORM\Relation;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a SelectField that may potentially have multiple selections, and may have
|
* Represents a SelectField that may potentially have multiple selections, and may have
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* NullableField is a field that wraps other fields when you want to allow the user to specify
|
* NullableField is a field that wraps other fields when you want to allow the user to specify
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Text input field with validation for numeric values. Supports validating
|
* Text input field with validation for numeric values. Supports validating
|
||||||
* the numeric value as to the {@link i18n::get_locale()} value, or an
|
* the numeric value as to the {@link i18n::get_locale()} value, or an
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Set of radio buttons designed to emulate a dropdown.
|
* Set of radio buttons designed to emulate a dropdown.
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package forms
|
* @package forms
|
||||||
* @subpackage fields-formattedinput
|
* @subpackage fields-formattedinput
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\SS_Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a field that allows users to select one or more items from a list
|
* Represents a field that allows users to select one or more items from a list
|
||||||
*/
|
*/
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Represents a number of fields which are selectable by a radio
|
* Represents a number of fields which are selectable by a radio
|
||||||
* button that appears at the beginning of each item. Using CSS, you can
|
* button that appears at the beginning of each item. Using CSS, you can
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Dropdown-like field that allows you to select an item from a hierarchical
|
* Dropdown-like field that allows you to select an item from a hierarchical
|
||||||
* AJAX-expandable tree.
|
* AJAX-expandable tree.
|
||||||
@ -336,7 +338,7 @@ class TreeDropdownField extends FormField {
|
|||||||
// Limit the amount of nodes shown for performance reasons.
|
// Limit the amount of nodes shown for performance reasons.
|
||||||
// Skip the check if we're filtering the tree, since its not clear how many children will
|
// Skip the check if we're filtering the tree, since its not clear how many children will
|
||||||
// match the filter criteria until they're queried (and matched up with previously marked nodes).
|
// match the filter criteria until they're queried (and matched up with previously marked nodes).
|
||||||
$nodeThresholdLeaf = Config::inst()->get('Hierarchy', 'node_threshold_leaf');
|
$nodeThresholdLeaf = Config::inst()->get('SilverStripe\\ORM\\Hierarchy\\Hierarchy', 'node_threshold_leaf');
|
||||||
if($nodeThresholdLeaf && !$this->filterCallback && !$this->search) {
|
if($nodeThresholdLeaf && !$this->filterCallback && !$this->search) {
|
||||||
$className = $this->sourceObject;
|
$className = $this->sourceObject;
|
||||||
$nodeCountCallback = function($parent, $numChildren) use($className, $nodeThresholdLeaf) {
|
$nodeCountCallback = function($parent, $numChildren) use($className, $nodeThresholdLeaf) {
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
/**
|
/**
|
||||||
* This formfield represents many-many joins using a tree selector shown in a dropdown styled element
|
* This formfield represents many-many joins using a tree selector shown in a dropdown styled element
|
||||||
* which can be added to any form usually in the CMS.
|
* which can be added to any form usually in the CMS.
|
||||||
|
@ -1,6 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Filesystem\Storage\AssetContainer;
|
use SilverStripe\Filesystem\Storage\AssetContainer;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
use SilverStripe\ORM\RelationList;
|
||||||
|
use SilverStripe\ORM\UnsavedRelationList;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Field for uploading single or multiple files of all types, including images.
|
* Field for uploading single or multiple files of all types, including images.
|
||||||
@ -1616,7 +1625,7 @@ class UploadField_SelectHandler extends RequestHandler {
|
|||||||
'Size' => singleton('File')->fieldLabel('Size')
|
'Size' => singleton('File')->fieldLabel('Size')
|
||||||
));
|
));
|
||||||
$colsComponent->setFieldCasting(array(
|
$colsComponent->setFieldCasting(array(
|
||||||
'Created' => 'SS_Datetime->Nice'
|
'Created' => 'DBDatetime->Nice'
|
||||||
));
|
));
|
||||||
|
|
||||||
// Set configurable pagination for file list field
|
// Set configurable pagination for file list field
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays a {@link SS_List} in a grid format.
|
* Displays a {@link SS_List} in a grid format.
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
/**
|
/**
|
||||||
* This class is is responsible for adding objects to another object's has_many
|
* This class is is responsible for adding objects to another object's has_many
|
||||||
* and many_many relation, as defined by the {@link RelationList} passed to the
|
* and many_many relation, as defined by the {@link RelationList} passed to the
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base interface for all components that can be added to GridField.
|
* Base interface for all components that can be added to GridField.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Encapsulates a collection of components following the
|
* Encapsulates a collection of components following the
|
||||||
* {@link GridFieldComponent} interface. While the {@link GridField} itself
|
* {@link GridFieldComponent} interface. While the {@link GridField} itself
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
/**
|
/**
|
||||||
* This class is a {@link GridField} component that adds a delete action for
|
* This class is a {@link GridField} component that adds a delete action for
|
||||||
* objects.
|
* objects.
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
use SilverStripe\Framework\Core\Extensible;
|
use SilverStripe\Framework\Core\Extensible;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\HasManyList;
|
||||||
|
use SilverStripe\ORM\ManyManyList;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides view and edit forms at GridField-specific URLs.
|
* Provides view and edit forms at GridField-specific URLs.
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_Filterable;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* GridFieldFilterHeader alters the {@link GridField} with some filtering
|
* GridFieldFilterHeader alters the {@link GridField} with some filtering
|
||||||
* fields in the header of each column.
|
* fields in the header of each column.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Adds a "level up" link to a GridField table, which is useful when viewing
|
* Adds a "level up" link to a GridField table, which is useful when viewing
|
||||||
* hierarchical data. Requires the managed record to have a "getParent()"
|
* hierarchical data. Requires the managed record to have a "getParent()"
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_Limitable;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\UnsavedRelationList;
|
||||||
/**
|
/**
|
||||||
* GridFieldPaginator paginates the {@link GridField} list and adds controls
|
* GridFieldPaginator paginates the {@link GridField} list and adds controls
|
||||||
* to the bottom of the {@link GridField}.
|
* to the bottom of the {@link GridField}.
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an "Print" button to the bottom or top of a GridField.
|
* Adds an "Print" button to the bottom or top of a GridField.
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_Sortable;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GridFieldSortableHeader adds column headers to a {@link GridField} that can
|
* GridFieldSortableHeader adds column headers to a {@link GridField} that can
|
||||||
* also sort the columns.
|
* also sort the columns.
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
use Embed\Adapters\AdapterInterface;
|
use Embed\Adapters\AdapterInterface;
|
||||||
use Embed\Embed;
|
use Embed\Embed;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A TinyMCE-powered WYSIWYG HTML editor field with image and link insertion and tracking capabilities. Editor fields
|
* A TinyMCE-powered WYSIWYG HTML editor field with image and link insertion and tracking capabilities. Editor fields
|
||||||
@ -322,7 +325,7 @@ class HTMLEditorField_Toolbar extends RequestHandler {
|
|||||||
'Created' => singleton('File')->fieldLabel('Created'),
|
'Created' => singleton('File')->fieldLabel('Created'),
|
||||||
));
|
));
|
||||||
$columns->setFieldCasting(array(
|
$columns->setFieldCasting(array(
|
||||||
'Created' => 'SS_Datetime->Nice'
|
'Created' => 'DBDatetime->Nice'
|
||||||
));
|
));
|
||||||
|
|
||||||
$fromCMS = new CompositeField(
|
$fromCMS = new CompositeField(
|
||||||
|
@ -239,6 +239,12 @@ class i18nTextCollector extends Object {
|
|||||||
return array_unique($allConflicts);
|
return array_unique($allConflicts);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Map of translation keys => module names
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $classModuleCache = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determine the best module to be given ownership over this key
|
* Determine the best module to be given ownership over this key
|
||||||
*
|
*
|
||||||
@ -249,8 +255,12 @@ class i18nTextCollector extends Object {
|
|||||||
protected function getBestModuleForKey($entitiesByModule, $key) {
|
protected function getBestModuleForKey($entitiesByModule, $key) {
|
||||||
// Check classes
|
// Check classes
|
||||||
$class = current(explode('.', $key));
|
$class = current(explode('.', $key));
|
||||||
$owner = i18n::get_owner_module($class);
|
if(array_key_exists($class, $this->classModuleCache)) {
|
||||||
|
return $this->classModuleCache[$class];
|
||||||
|
}
|
||||||
|
$owner = $this->findModuleForClass($class);
|
||||||
if($owner) {
|
if($owner) {
|
||||||
|
$this->classModuleCache[$class] = $owner;
|
||||||
return $owner;
|
return $owner;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -259,18 +269,56 @@ class i18nTextCollector extends Object {
|
|||||||
|
|
||||||
// Display notice if not found
|
// Display notice if not found
|
||||||
Debug::message(
|
Debug::message(
|
||||||
"Duplicate key {$key} detected in multiple modules with no obvious owner",
|
"Duplicate key {$key} detected in no / multiple modules with no obvious owner",
|
||||||
false
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
// Fall back to framework then cms modules
|
// Fall back to framework then cms modules
|
||||||
foreach(array('framework', 'cms') as $module) {
|
foreach(array('framework', 'cms') as $module) {
|
||||||
if(isset($entitiesByModule[$module][$key])) {
|
if(isset($entitiesByModule[$module][$key])) {
|
||||||
|
$this->classModuleCache[$class] = $module;
|
||||||
return $module;
|
return $module;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do nothing
|
// Do nothing
|
||||||
|
$this->classModuleCache[$class] = null;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Given a partial class name, attempt to determine the best module to assign strings to.
|
||||||
|
*
|
||||||
|
* @param string $class Either a FQN class name, or a non-qualified class name.
|
||||||
|
* @return string Name of module
|
||||||
|
*/
|
||||||
|
protected function findModuleForClass($class) {
|
||||||
|
if(ClassInfo::exists($class)) {
|
||||||
|
return i18n::get_owner_module($class);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// If we can't find a class, see if it needs to be fully qualified
|
||||||
|
if(strpos($class, '\\') !== false) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find FQN that ends with $class
|
||||||
|
$classes = preg_grep(
|
||||||
|
'/'.preg_quote("\\{$class}", '\/').'$/i',
|
||||||
|
SS_ClassLoader::instance()->getManifest()->getClassNames()
|
||||||
|
);
|
||||||
|
|
||||||
|
// Find all modules for candidate classes
|
||||||
|
$modules = array_unique(array_map(function($class) {
|
||||||
|
return i18n::get_owner_module($class);
|
||||||
|
}, $classes));
|
||||||
|
|
||||||
|
if(count($modules) === 1) {
|
||||||
|
return reset($modules);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Couldn't find it! Exists in none, or multiple modules.
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
5
main.php
5
main.php
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
************************************************************************************
|
************************************************************************************
|
||||||
** **
|
** **
|
||||||
@ -141,7 +144,7 @@ $chain
|
|||||||
require_once('core/Core.php');
|
require_once('core/Core.php');
|
||||||
|
|
||||||
// Connect to database
|
// Connect to database
|
||||||
require_once('model/DB.php');
|
require_once('ORM/DB.php');
|
||||||
global $databaseConfig;
|
global $databaseConfig;
|
||||||
if ($databaseConfig) DB::connect($databaseConfig);
|
if ($databaseConfig) DB::connect($databaseConfig);
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Backwards-compatibility class to preserve the functioning of references to SS_Datetime::now()
|
|
||||||
* @deprecated 4.0.0:5.0.0 Use SilverStripe\Model\FieldType\DBDatetime instead.
|
|
||||||
*/
|
|
||||||
class SS_Datetime extends SilverStripe\Model\FieldType\DBDatetime
|
|
||||||
{
|
|
||||||
|
|
||||||
public function __construct($name = null) {
|
|
||||||
self::deprecation_notice();
|
|
||||||
parent::__construct($name);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function now() {
|
|
||||||
self::deprecation_notice();
|
|
||||||
return parent::now();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Mock the system date temporarily, which is useful for time-based unit testing.
|
|
||||||
* Use {@link clear_mock_now()} to revert to the current system date.
|
|
||||||
* Caution: This sets a fixed date that doesn't increment with time.
|
|
||||||
*
|
|
||||||
* @param SS_Datetime|string $datetime Either in object format, or as a SS_Datetime compatible string.
|
|
||||||
*/
|
|
||||||
public static function set_mock_now($datetime) {
|
|
||||||
self::deprecation_notice();
|
|
||||||
return parent::set_mock_now($datetime);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear any mocked date, which causes
|
|
||||||
* {@link Now()} to return the current system date.
|
|
||||||
*/
|
|
||||||
public static function clear_mock_now() {
|
|
||||||
self::deprecation_notice();
|
|
||||||
return parent::clear_mock_now();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function get_template_global_variables() {
|
|
||||||
self::deprecation_notice();
|
|
||||||
return parent::get_template_global_variables();
|
|
||||||
}
|
|
||||||
|
|
||||||
protected static function deprecation_notice() {
|
|
||||||
Deprecation::notice('4.0', 'SS_Datetime is deprecated. Please use SilverStripe\Model\FieldType\DBDatetime instead.');
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
require_once('HTML/HTMLBBCodeParser.php');
|
require_once('HTML/HTMLBBCodeParser.php');
|
||||||
/*Seting up the PEAR bbcode parser*/
|
/*Seting up the PEAR bbcode parser*/
|
||||||
$config = parse_ini_file('BBCodeParser.ini', true);
|
$config = parse_ini_file('BBCodeParser.ini', true);
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Connect\MySQLSchemaManager;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
/**
|
/**
|
||||||
* Provides a simple search engine for your site based on the MySQL FULLTEXT index.
|
* Provides a simple search engine for your site based on the MySQL FULLTEXT index.
|
||||||
* Adds the {@link FulltextSearchable} extension to data classes,
|
* Adds the {@link FulltextSearchable} extension to data classes,
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
/**
|
/**
|
||||||
* Manages searching of properties on one or more {@link DataObject}
|
* Manages searching of properties on one or more {@link DataObject}
|
||||||
* types, based on a given set of input parameters.
|
* types, based on a given set of input parameters.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
/**
|
/**
|
||||||
* Base class for creating comparison filters, eg; greater than, less than, greater than or equal, etc
|
* Base class for creating comparison filters, eg; greater than, less than, greater than or equal, etc
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage search
|
* @subpackage search
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage search
|
* @subpackage search
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage search
|
* @subpackage search
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
/**
|
/**
|
||||||
* Base class for filtering implementations,
|
* Base class for filtering implementations,
|
||||||
* which work together with {@link SearchContext}
|
* which work together with {@link SearchContext}
|
||||||
@ -166,7 +169,7 @@ abstract class SearchFilter extends Object {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure that we're dealing with a DataObject.
|
// Ensure that we're dealing with a DataObject.
|
||||||
if (!is_subclass_of($this->model, 'DataObject')) {
|
if (!is_subclass_of($this->model, 'SilverStripe\\ORM\\DataObject')) {
|
||||||
throw new InvalidArgumentException(
|
throw new InvalidArgumentException(
|
||||||
"Model supplied to " . get_class($this) . " should be an instance of DataObject."
|
"Model supplied to " . get_class($this) . " should be an instance of DataObject."
|
||||||
);
|
);
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage search
|
* @subpackage search
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\UnsavedRelationList;
|
||||||
/**
|
/**
|
||||||
* A security group.
|
* A security group.
|
||||||
*
|
*
|
||||||
@ -45,7 +49,7 @@ class Group extends DataObject {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Hierarchy",
|
"SilverStripe\\ORM\\Hierarchy\\Hierarchy",
|
||||||
);
|
);
|
||||||
|
|
||||||
public function populateDefaults() {
|
public function populateDefaults() {
|
||||||
@ -459,7 +463,7 @@ class Group extends DataObject {
|
|||||||
* Filters to only those groups that the current user can edit
|
* Filters to only those groups that the current user can edit
|
||||||
*/
|
*/
|
||||||
public function AllChildrenIncludingDeleted() {
|
public function AllChildrenIncludingDeleted() {
|
||||||
$extInstance = $this->getExtensionInstance('Hierarchy');
|
$extInstance = $this->getExtensionInstance('SilverStripe\\ORM\\Hierarchy\\Hierarchy');
|
||||||
$extInstance->setOwner($this);
|
$extInstance->setOwner($this);
|
||||||
$children = $extInstance->AllChildrenIncludingDeleted();
|
$children = $extInstance->AllChildrenIncludingDeleted();
|
||||||
$extInstance->clearOwner();
|
$extInstance->clearOwner();
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @todo Migrate Permission->Arg and Permission->Type values
|
* @todo Migrate Permission->Arg and Permission->Type values
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Record all login attempts through the {@link LoginForm} object.
|
* Record all login attempts through the {@link LoginForm} object.
|
||||||
* This behaviour is disabled by default.
|
* This behaviour is disabled by default.
|
||||||
|
@ -1,6 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\ManyManyList;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The member class which represents the users of the system
|
* The member class which represents the users of the system
|
||||||
@ -32,10 +42,10 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
'Surname' => 'Varchar',
|
'Surname' => 'Varchar',
|
||||||
'Email' => 'Varchar(254)', // See RFC 5321, Section 4.5.3.1.3. (256 minus the < and > character)
|
'Email' => 'Varchar(254)', // See RFC 5321, Section 4.5.3.1.3. (256 minus the < and > character)
|
||||||
'TempIDHash' => 'Varchar(160)', // Temporary id used for cms re-authentication
|
'TempIDHash' => 'Varchar(160)', // Temporary id used for cms re-authentication
|
||||||
'TempIDExpired' => 'SS_Datetime', // Expiry of temp login
|
'TempIDExpired' => 'Datetime', // Expiry of temp login
|
||||||
'Password' => 'Varchar(160)',
|
'Password' => 'Varchar(160)',
|
||||||
'AutoLoginHash' => 'Varchar(160)', // Used to auto-login the user on password reset
|
'AutoLoginHash' => 'Varchar(160)', // Used to auto-login the user on password reset
|
||||||
'AutoLoginExpired' => 'SS_Datetime',
|
'AutoLoginExpired' => 'Datetime',
|
||||||
// This is an arbitrary code pointing to a PasswordEncryptor instance,
|
// This is an arbitrary code pointing to a PasswordEncryptor instance,
|
||||||
// not an actual encryption algorithm.
|
// not an actual encryption algorithm.
|
||||||
// Warning: Never change this field after its the first password hashing without
|
// Warning: Never change this field after its the first password hashing without
|
||||||
@ -43,7 +53,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
'PasswordEncryption' => "Varchar(50)",
|
'PasswordEncryption' => "Varchar(50)",
|
||||||
'Salt' => 'Varchar(50)',
|
'Salt' => 'Varchar(50)',
|
||||||
'PasswordExpiry' => 'Date',
|
'PasswordExpiry' => 'Date',
|
||||||
'LockedOutUntil' => 'SS_Datetime',
|
'LockedOutUntil' => 'Datetime',
|
||||||
'Locale' => 'Varchar(6)',
|
'Locale' => 'Varchar(6)',
|
||||||
// handled in registerFailedLogin(), only used if $lock_out_after_incorrect_logins is set
|
// handled in registerFailedLogin(), only used if $lock_out_after_incorrect_logins is set
|
||||||
'FailedLoginCount' => 'Int',
|
'FailedLoginCount' => 'Int',
|
||||||
@ -364,7 +374,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
* Returns true if this user is locked out
|
* Returns true if this user is locked out
|
||||||
*/
|
*/
|
||||||
public function isLockedOut() {
|
public function isLockedOut() {
|
||||||
return $this->LockedOutUntil && SS_Datetime::now()->Format('U') < strtotime($this->LockedOutUntil);
|
return $this->LockedOutUntil && DBDatetime::now()->Format('U') < strtotime($this->LockedOutUntil);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -553,11 +563,11 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
if(strpos(Cookie::get('alc_enc'), ':') && Cookie::get('alc_device') && !Session::get("loggedInAs")) {
|
if(strpos(Cookie::get('alc_enc'), ':') && Cookie::get('alc_device') && !Session::get("loggedInAs")) {
|
||||||
list($uid, $token) = explode(':', Cookie::get('alc_enc'), 2);
|
list($uid, $token) = explode(':', Cookie::get('alc_enc'), 2);
|
||||||
|
|
||||||
if (!$uid || !$token) {
|
if (!$uid || !$token) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$deviceID = Cookie::get('alc_device');
|
$deviceID = Cookie::get('alc_device');
|
||||||
|
|
||||||
$member = Member::get()->byId($uid);
|
$member = Member::get()->byId($uid);
|
||||||
@ -578,7 +588,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
} else {
|
} else {
|
||||||
// Check for expired token
|
// Check for expired token
|
||||||
$expiryDate = new DateTime($rememberLoginHash->ExpiryDate);
|
$expiryDate = new DateTime($rememberLoginHash->ExpiryDate);
|
||||||
$now = SS_Datetime::now();
|
$now = DBDatetime::now();
|
||||||
$now = new DateTime($now->Rfc2822());
|
$now = new DateTime($now->Rfc2822());
|
||||||
if ($now > $expiryDate) {
|
if ($now > $expiryDate) {
|
||||||
$member = null;
|
$member = null;
|
||||||
@ -1325,7 +1335,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
$groupIDList = array();
|
$groupIDList = array();
|
||||||
|
|
||||||
if(is_a($groups, 'SS_List')) {
|
if(is_a($groups, 'SilverStripe\\ORM\\SS_List')) {
|
||||||
foreach($groups as $group) {
|
foreach($groups as $group) {
|
||||||
$groupIDList[] = $group->ID;
|
$groupIDList[] = $group->ID;
|
||||||
}
|
}
|
||||||
@ -1654,7 +1664,7 @@ class Member extends DataObject implements TemplateGlobalProvider {
|
|||||||
|
|
||||||
if($this->FailedLoginCount >= self::config()->lock_out_after_incorrect_logins) {
|
if($this->FailedLoginCount >= self::config()->lock_out_after_incorrect_logins) {
|
||||||
$lockoutMins = self::config()->lock_out_delay_mins;
|
$lockoutMins = self::config()->lock_out_delay_mins;
|
||||||
$this->LockedOutUntil = date('Y-m-d H:i:s', SS_Datetime::now()->Format('U') + $lockoutMins*60);
|
$this->LockedOutUntil = date('Y-m-d H:i:s', DBDatetime::now()->Format('U') + $lockoutMins*60);
|
||||||
$this->FailedLoginCount = 0;
|
$this->FailedLoginCount = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
/**
|
/**
|
||||||
* Authenticator for the default "member" method
|
* Authenticator for the default "member" method
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Imports member records, and checks/updates duplicates based on their
|
* Imports member records, and checks/updates duplicates based on their
|
||||||
* 'Email' property.
|
* 'Email' property.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Keep track of users' previous passwords, so that we can check that new passwords aren't changed back to old ones.
|
* Keep track of users' previous passwords, so that we can check that new passwords aren't changed back to old ones.
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
/**
|
/**
|
||||||
* Allows pluggable password encryption.
|
* Allows pluggable password encryption.
|
||||||
* By default, this might be PHP's integrated sha1()
|
* By default, this might be PHP's integrated sha1()
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a validator for member passwords.
|
* This class represents a validator for member passwords.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* Represents a permission assigned to a group.
|
* Represents a permission assigned to a group.
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\DataObjectInterface;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shows a categorized list of available permissions (through {@link Permission::get_codes()}).
|
* Shows a categorized list of available permissions (through {@link Permission::get_codes()}).
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* A PermissionRole represents a collection of permission codes that can be applied to groups.
|
* A PermissionRole represents a collection of permission codes that can be applied to groups.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* A PermissionRoleCode represents a single permission code assigned to a {@link PermissionRole}.
|
* A PermissionRoleCode represents a single permission code assigned to a {@link PermissionRole}.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Persists a token associated with a device for users who opted for the "Remember Me"
|
* Persists a token associated with a device for users who opted for the "Remember Me"
|
||||||
* feature when logging in.
|
* feature when logging in.
|
||||||
@ -19,7 +22,7 @@ class RememberLoginHash extends DataObject {
|
|||||||
private static $db = array (
|
private static $db = array (
|
||||||
'DeviceID' => 'Varchar(40)',
|
'DeviceID' => 'Varchar(40)',
|
||||||
'Hash' => 'Varchar(160)',
|
'Hash' => 'Varchar(160)',
|
||||||
'ExpiryDate' => 'SS_Datetime'
|
'ExpiryDate' => 'Datetime'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array (
|
private static $has_one = array (
|
||||||
@ -122,7 +125,7 @@ class RememberLoginHash extends DataObject {
|
|||||||
$rememberLoginHash->DeviceID = $deviceID;
|
$rememberLoginHash->DeviceID = $deviceID;
|
||||||
$rememberLoginHash->Hash = $rememberLoginHash->getNewHash($member);
|
$rememberLoginHash->Hash = $rememberLoginHash->getNewHash($member);
|
||||||
$rememberLoginHash->MemberID = $member->ID;
|
$rememberLoginHash->MemberID = $member->ID;
|
||||||
$now = SS_Datetime::now();
|
$now = DBDatetime::now();
|
||||||
$expiryDate = new DateTime($now->Rfc2822());
|
$expiryDate = new DateTime($now->Rfc2822());
|
||||||
$tokenExpiryDays = Config::inst()->get('RememberLoginHash', 'token_expiry_days');
|
$tokenExpiryDays = Config::inst()->get('RememberLoginHash', 'token_expiry_days');
|
||||||
$expiryDate->add(new DateInterval('P'.$tokenExpiryDays.'D'));
|
$expiryDate->add(new DateInterval('P'.$tokenExpiryDays.'D'));
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
/**
|
/**
|
||||||
* Implements a basic security model
|
* Implements a basic security model
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Encrypt all passwords
|
* Encrypt all passwords
|
||||||
*
|
*
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Migrates all 3.x file dataobjects to use the new DBFile field.
|
* Migrates all 3.x file dataobjects to use the new DBFile field.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Regenerate all cached images that have been created as the result of a manipulation method being called on a
|
* Regenerate all cached images that have been created as the result of a manipulation method being called on a
|
||||||
* {@link Image} object
|
* {@link Image} object
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
class XMLDataFormatterTest extends SapphireTest {
|
class XMLDataFormatterTest extends SapphireTest {
|
||||||
protected $arguments, $contents, $tagName;
|
protected $arguments, $contents, $tagName;
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This bootstraps the SilverStripe system so that phpunit can be run directly on SilverStripe tests.
|
* This bootstraps the SilverStripe system so that phpunit can be run directly on SilverStripe tests.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
|
||||||
class ControllerTest extends FunctionalTest {
|
class ControllerTest extends FunctionalTest {
|
||||||
|
|
||||||
protected static $fixture_file = 'ControllerTest.yml';
|
protected static $fixture_file = 'ControllerTest.yml';
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -566,7 +568,7 @@ class TestRequestFilter implements RequestFilter, TestOnly {
|
|||||||
public $failPre = false;
|
public $failPre = false;
|
||||||
public $failPost = false;
|
public $failPost = false;
|
||||||
|
|
||||||
public function preRequest(\SS_HTTPRequest $request, \Session $session, \DataModel $model) {
|
public function preRequest(\SS_HTTPRequest $request, \Session $session, DataModel $model) {
|
||||||
++$this->preCalls;
|
++$this->preCalls;
|
||||||
|
|
||||||
if ($this->failPre) {
|
if ($this->failPre) {
|
||||||
@ -574,7 +576,7 @@ class TestRequestFilter implements RequestFilter, TestOnly {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function postRequest(\SS_HTTPRequest $request, \SS_HTTPResponse $response, \DataModel $model) {
|
public function postRequest(\SS_HTTPRequest $request, \SS_HTTPResponse $response, DataModel $model) {
|
||||||
++$this->postCalls;
|
++$this->postCalls;
|
||||||
|
|
||||||
if ($this->failPost) {
|
if ($this->failPost) {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBVarchar;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||||
|
|
||||||
|
|
||||||
class ArrayDataTest extends SapphireTest {
|
class ArrayDataTest extends SapphireTest {
|
||||||
|
|
||||||
@ -10,7 +12,7 @@ class ArrayDataTest extends SapphireTest {
|
|||||||
"A" => new DBVarchar("A"),
|
"A" => new DBVarchar("A"),
|
||||||
"B" => new stdClass(),
|
"B" => new stdClass(),
|
||||||
));
|
));
|
||||||
$this->assertEquals('SilverStripe\Model\FieldType\DBVarchar', get_class($arrayData->A));
|
$this->assertEquals('SilverStripe\\ORM\\FieldType\\DBVarchar', get_class($arrayData->A));
|
||||||
$this->assertEquals("ArrayData", get_class($arrayData->B));
|
$this->assertEquals("ArrayData", get_class($arrayData->B));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -91,7 +93,7 @@ class ClassInfoTest extends SapphireTest {
|
|||||||
$expect = ArrayLib::valuekey(array(
|
$expect = ArrayLib::valuekey(array(
|
||||||
'Object',
|
'Object',
|
||||||
'ViewableData',
|
'ViewableData',
|
||||||
'DataObject',
|
'SilverStripe\\ORM\\DataObject',
|
||||||
'ClassInfoTest_BaseClass',
|
'ClassInfoTest_BaseClass',
|
||||||
'ClassInfoTest_ChildClass',
|
'ClassInfoTest_ChildClass',
|
||||||
));
|
));
|
||||||
|
@ -383,18 +383,18 @@ class ObjectTest extends SapphireTest {
|
|||||||
public function testParseClassSpec() {
|
public function testParseClassSpec() {
|
||||||
// Simple case
|
// Simple case
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('Versioned',array('Stage', 'Live')),
|
array('SilverStripe\\ORM\\Versioning\\Versioned',array('Stage', 'Live')),
|
||||||
Object::parse_class_spec("Versioned('Stage','Live')")
|
Object::parse_class_spec("SilverStripe\\ORM\\Versioning\\Versioned('Stage','Live')")
|
||||||
);
|
);
|
||||||
// String with commas
|
// String with commas
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('Versioned',array('Stage,Live', 'Stage')),
|
array('SilverStripe\\ORM\\Versioning\\Versioned',array('Stage,Live', 'Stage')),
|
||||||
Object::parse_class_spec("Versioned('Stage,Live','Stage')")
|
Object::parse_class_spec("SilverStripe\\ORM\\Versioning\\Versioned('Stage,Live','Stage')")
|
||||||
);
|
);
|
||||||
// String with quotes
|
// String with quotes
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('Versioned',array('Stage\'Stage,Live\'Live', 'Live')),
|
array('SilverStripe\\ORM\\Versioning\\Versioned',array('Stage\'Stage,Live\'Live', 'Live')),
|
||||||
Object::parse_class_spec("Versioned('Stage\'Stage,Live\'Live','Live')")
|
Object::parse_class_spec("SilverStripe\\ORM\\Versioning\\Versioned('Stage\'Stage,Live\'Live','Live')")
|
||||||
);
|
);
|
||||||
|
|
||||||
// True, false and null values
|
// True, false and null values
|
||||||
|
@ -37,7 +37,7 @@ class NamespacedClassManifestTest extends SapphireTest {
|
|||||||
'PermissionProvider', ' ', 'AS', ' ', 'P',
|
'PermissionProvider', ' ', 'AS', ' ', 'P',
|
||||||
),
|
),
|
||||||
array('silverstripe', '\\', 'test', '\\', 'ClassA'),
|
array('silverstripe', '\\', 'test', '\\', 'ClassA'),
|
||||||
array('\\', 'DataObject'),
|
array('\\', 'Object'),
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertEquals(count($expectedItems), count($parsedTokens));
|
$this->assertEquals(count($expectedItems), count($parsedTokens));
|
||||||
@ -61,7 +61,7 @@ class NamespacedClassManifestTest extends SapphireTest {
|
|||||||
'Response' => 'SS_HTTPResponse',
|
'Response' => 'SS_HTTPResponse',
|
||||||
'P' => 'PermissionProvider',
|
'P' => 'PermissionProvider',
|
||||||
'silverstripe\test\ClassA',
|
'silverstripe\test\ClassA',
|
||||||
'\DataObject',
|
'\Object',
|
||||||
);
|
);
|
||||||
|
|
||||||
$imports = $method->invoke($this->manifest, $tokens);
|
$imports = $method->invoke($this->manifest, $tokens);
|
||||||
|
@ -2,11 +2,11 @@
|
|||||||
namespace SilverStripe\Framework\Tests;
|
namespace SilverStripe\Framework\Tests;
|
||||||
|
|
||||||
//whitespace here is important for tests, please don't change it
|
//whitespace here is important for tests, please don't change it
|
||||||
use ModelAdmin;
|
use ModelAdmin;
|
||||||
use Controller as Cont ;
|
use Controller as Cont ;
|
||||||
use SS_HTTPRequest as Request,SS_HTTPResponse AS Response, PermissionProvider AS P;
|
use SS_HTTPRequest as Request,SS_HTTPResponse AS Response, PermissionProvider AS P;
|
||||||
use silverstripe\test\ClassA;
|
use silverstripe\test\ClassA;
|
||||||
use \DataObject;
|
use \Object;
|
||||||
|
|
||||||
class ClassI extends ModelAdmin implements P {
|
class ClassI extends ModelAdmin implements P {
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests {@see AssetControlExtension}
|
* Tests {@see AssetControlExtension}
|
||||||
@ -15,7 +18,7 @@ class AssetControlExtensionTest extends SapphireTest {
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
// Set backend and base url
|
// Set backend and base url
|
||||||
\Versioned::set_stage(Versioned::DRAFT);
|
Versioned::set_stage(Versioned::DRAFT);
|
||||||
AssetStoreTest_SpyStore::activate('AssetControlExtensionTest');
|
AssetStoreTest_SpyStore::activate('AssetControlExtensionTest');
|
||||||
$this->logInWithPermission('ADMIN');
|
$this->logInWithPermission('ADMIN');
|
||||||
|
|
||||||
@ -46,7 +49,7 @@ class AssetControlExtensionTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testFileDelete() {
|
public function testFileDelete() {
|
||||||
\Versioned::set_stage(Versioned::DRAFT);
|
Versioned::set_stage(Versioned::DRAFT);
|
||||||
|
|
||||||
/** @var AssetControlExtensionTest_VersionedObject $object1 */
|
/** @var AssetControlExtensionTest_VersionedObject $object1 */
|
||||||
$object1 = AssetControlExtensionTest_VersionedObject::get()
|
$object1 = AssetControlExtensionTest_VersionedObject::get()
|
||||||
@ -120,7 +123,7 @@ class AssetControlExtensionTest extends SapphireTest {
|
|||||||
* Test files being replaced
|
* Test files being replaced
|
||||||
*/
|
*/
|
||||||
public function testReplaceFile() {
|
public function testReplaceFile() {
|
||||||
\Versioned::set_stage(Versioned::DRAFT);
|
Versioned::set_stage(Versioned::DRAFT);
|
||||||
|
|
||||||
/** @var AssetControlExtensionTest_VersionedObject $object1 */
|
/** @var AssetControlExtensionTest_VersionedObject $object1 */
|
||||||
$object1 = AssetControlExtensionTest_VersionedObject::get()
|
$object1 = AssetControlExtensionTest_VersionedObject::get()
|
||||||
@ -208,7 +211,7 @@ class AssetControlExtensionTest extends SapphireTest {
|
|||||||
*/
|
*/
|
||||||
class AssetControlExtensionTest_VersionedObject extends DataObject implements TestOnly {
|
class AssetControlExtensionTest_VersionedObject extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned'
|
'SilverStripe\\ORM\\Versioning\\Versioned'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Filesystem as SS_Filesystem;
|
use Filesystem as SS_Filesystem;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ensures that File dataobjects can be safely migrated from 3.x
|
* Ensures that File dataobjects can be safely migrated from 3.x
|
||||||
|
@ -2,6 +2,10 @@
|
|||||||
|
|
||||||
use Filesystem as SS_Filesystem;
|
use Filesystem as SS_Filesystem;
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for the File class
|
* Tests for the File class
|
||||||
@ -327,7 +331,7 @@ class FileTest extends SapphireTest {
|
|||||||
/**
|
/**
|
||||||
* @see http://open.silverstripe.org/ticket/5693
|
* @see http://open.silverstripe.org/ticket/5693
|
||||||
*
|
*
|
||||||
* @expectedException ValidationException
|
* @expectedException SilverStripe\ORM\ValidationException
|
||||||
*/
|
*/
|
||||||
public function testSetNameWithInvalidExtensionDoesntChangeFilesystem() {
|
public function testSetNameWithInvalidExtensionDoesntChangeFilesystem() {
|
||||||
$orig = Config::inst()->get('File', 'allowed_extensions');
|
$orig = Config::inst()->get('File', 'allowed_extensions');
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Filesystem as SS_Filesystem;
|
use Filesystem as SS_Filesystem;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Ingo Schommer (ingo at silverstripe dot com)
|
* @author Ingo Schommer (ingo at silverstripe dot com)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -60,7 +60,7 @@ class CurrencyFieldTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//tests with updated currency symbol setting
|
//tests with updated currency symbol setting
|
||||||
Config::inst()->update('SilverStripe\Model\FieldType\DBCurrency', 'currency_symbol', '€');
|
Config::inst()->update('SilverStripe\\ORM\\FieldType\\DBCurrency', 'currency_symbol', '€');
|
||||||
|
|
||||||
$f->setValue('123.45');
|
$f->setValue('123.45');
|
||||||
$this->assertTrue(
|
$this->assertTrue(
|
||||||
@ -164,7 +164,7 @@ class CurrencyFieldTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//update currency symbol via config
|
//update currency symbol via config
|
||||||
Config::inst()->update('SilverStripe\Model\FieldType\DBCurrency', 'currency_symbol', '€');
|
Config::inst()->update('SilverStripe\\ORM\\FieldType\\DBCurrency', 'currency_symbol', '€');
|
||||||
|
|
||||||
$f->setValue('123.45');
|
$f->setValue('123.45');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -235,7 +235,7 @@ class CurrencyFieldTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
//tests with updated currency symbol setting
|
//tests with updated currency symbol setting
|
||||||
Config::inst()->update('SilverStripe\Model\FieldType\DBCurrency', 'currency_symbol', '€');
|
Config::inst()->update('SilverStripe\\ORM\\FieldType\\DBCurrency', 'currency_symbol', '€');
|
||||||
|
|
||||||
$f->setValue('€123.45');
|
$f->setValue('€123.45');
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
use SilverStripe\Filesystem\Storage\AssetStore;
|
use SilverStripe\Filesystem\Storage\AssetStore;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Description of DBFileTest
|
* Description of DBFileTest
|
||||||
@ -60,7 +62,7 @@ class DBFileTest extends SapphireTest {
|
|||||||
$obj->MyFile->setFromLocalFile($fish, 'awesome-fish.jpg');
|
$obj->MyFile->setFromLocalFile($fish, 'awesome-fish.jpg');
|
||||||
|
|
||||||
// This should fail
|
// This should fail
|
||||||
$this->setExpectedException('ValidationException');
|
$this->setExpectedException('SilverStripe\\ORM\\ValidationException');
|
||||||
$obj->MyFile->setFromString('puppies', 'subdir/puppy-document.txt');
|
$obj->MyFile->setFromString('puppies', 'subdir/puppy-document.txt');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -251,7 +253,7 @@ class DatetimeFieldTest extends SapphireTest {
|
|||||||
class DatetimeFieldTest_Model extends DataObject implements TestOnly {
|
class DatetimeFieldTest_Model extends DataObject implements TestOnly {
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'MyDatetime' => 'SS_Datetime'
|
'MyDatetime' => 'Datetime'
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -263,7 +265,7 @@ class DropdownFieldTest extends SapphireTest {
|
|||||||
public function testDropdownWithArrayValues($value) {
|
public function testDropdownWithArrayValues($value) {
|
||||||
$field = $this->createDropdownField();
|
$field = $this->createDropdownField();
|
||||||
$field->setValue($value);
|
$field->setValue($value);
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBHTMLText', $field->Field());
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBHTMLText', $field->Field());
|
||||||
$this->assertSame($value, $field->Value());
|
$this->assertSame($value, $field->Value());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBEnum;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBEnum;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for DataObject FormField scaffolding
|
* Tests for DataObject FormField scaffolding
|
||||||
*
|
*
|
||||||
@ -120,7 +123,7 @@ class FormScaffolderTest_Article extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Author' => 'FormScaffolderTest_Author',
|
'Author' => 'FormScaffolderTest_Author',
|
||||||
'Subject' => 'DataObject'
|
'Subject' => 'SilverStripe\\ORM\\DataObject'
|
||||||
);
|
);
|
||||||
private static $many_many = array(
|
private static $many_many = array(
|
||||||
'Tags' => 'FormScaffolderTest_Tag',
|
'Tags' => 'FormScaffolderTest_Tag',
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\SS_List;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
class GridFieldTest extends SapphireTest {
|
class GridFieldTest extends SapphireTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,8 +76,8 @@ class GridFieldTest extends SapphireTest {
|
|||||||
public function testGridFieldModelClass() {
|
public function testGridFieldModelClass() {
|
||||||
$obj = new GridField('testfield', 'testfield', Member::get());
|
$obj = new GridField('testfield', 'testfield', Member::get());
|
||||||
$this->assertEquals('Member', $obj->getModelClass(), 'Should return Member');
|
$this->assertEquals('Member', $obj->getModelClass(), 'Should return Member');
|
||||||
$obj->setModelClass('DataModel');
|
$obj->setModelClass('SilverStripe\\ORM\\DataModel');
|
||||||
$this->assertEquals('DataModel', $obj->getModelClass(), 'Should return Member');
|
$this->assertEquals('SilverStripe\\ORM\\DataModel', $obj->getModelClass(), 'Should return Member');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Filesystem as SS_Filesystem;
|
use Filesystem as SS_Filesystem;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBMoney;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBMoney;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
class GridFieldAddExistingAutocompleterTest extends FunctionalTest {
|
class GridFieldAddExistingAutocompleterTest extends FunctionalTest {
|
||||||
|
|
||||||
protected static $fixture_file = 'GridFieldTest.yml';
|
protected static $fixture_file = 'GridFieldTest.yml';
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -8,7 +10,7 @@ class GridFieldConfigTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testGetComponents() {
|
public function testGetComponents() {
|
||||||
$config = GridFieldConfig::create();
|
$config = GridFieldConfig::create();
|
||||||
$this->assertInstanceOf('ArrayList', $config->getComponents());
|
$this->assertInstanceOf('SilverStripe\\ORM\\ArrayList', $config->getComponents());
|
||||||
$this->assertEquals($config->getComponents()->Count(), 0);
|
$this->assertEquals($config->getComponents()->Count(), 0);
|
||||||
|
|
||||||
$config
|
$config
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class GridFieldDeleteActionTest extends SapphireTest {
|
class GridFieldDeleteActionTest extends SapphireTest {
|
||||||
|
|
||||||
/** @var ArrayList */
|
/** @var ArrayList */
|
||||||
@ -67,7 +70,7 @@ class GridFieldDeleteActionTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testDeleteActionWithoutCorrectPermission() {
|
public function testDeleteActionWithoutCorrectPermission() {
|
||||||
if(Member::currentUser()) { Member::currentUser()->logOut(); }
|
if(Member::currentUser()) { Member::currentUser()->logOut(); }
|
||||||
$this->setExpectedException('ValidationException');
|
$this->setExpectedException('SilverStripe\\ORM\\ValidationException');
|
||||||
|
|
||||||
$stateID = 'testGridStateActionField';
|
$stateID = 'testGridStateActionField';
|
||||||
Session::set(
|
Session::set(
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class GridFieldEditButtonTest extends SapphireTest {
|
class GridFieldEditButtonTest extends SapphireTest {
|
||||||
|
|
||||||
/** @var ArrayList */
|
/** @var ArrayList */
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
class GridFieldPaginatorTest extends FunctionalTest {
|
class GridFieldPaginatorTest extends FunctionalTest {
|
||||||
/** @var ArrayList */
|
/** @var ArrayList */
|
||||||
protected $list;
|
protected $list;
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
class GridFieldPrintButtonTest extends SapphireTest {
|
class GridFieldPrintButtonTest extends SapphireTest {
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the API for creating GridField_URLHandler compeonnts
|
* Test the API for creating GridField_URLHandler compeonnts
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
class i18nTestModuleExtension extends DataExtension {
|
class i18nTestModuleExtension extends DataExtension {
|
||||||
|
|
||||||
public static $db = array(
|
public static $db = array(
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
class i18nTestModule extends DataObject implements TestOnly {
|
class i18nTestModule extends DataObject implements TestOnly {
|
||||||
|
|
||||||
static $db = array(
|
static $db = array(
|
||||||
|
@ -0,0 +1,14 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace i18nTest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: dmooyman
|
||||||
|
* Date: 17/06/16
|
||||||
|
* Time: 12:49 PM
|
||||||
|
*/
|
||||||
|
class i18nTestNamespacedClass
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
require_once 'Zend/Translate.php';
|
require_once 'Zend/Translate.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -24,6 +24,7 @@ class i18nTextCollectorTest extends SapphireTest {
|
|||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
$this->alternateBasePath = $this->getCurrentAbsolutePath() . "/_fakewebroot";
|
$this->alternateBasePath = $this->getCurrentAbsolutePath() . "/_fakewebroot";
|
||||||
|
Config::inst()->update('Director', 'alternate_base_folder', $this->alternateBasePath);
|
||||||
$this->alternateBaseSavePath = TEMP_FOLDER . '/i18nTextCollectorTest_webroot';
|
$this->alternateBaseSavePath = TEMP_FOLDER . '/i18nTextCollectorTest_webroot';
|
||||||
Filesystem::makeFolder($this->alternateBaseSavePath);
|
Filesystem::makeFolder($this->alternateBaseSavePath);
|
||||||
|
|
||||||
@ -40,6 +41,10 @@ class i18nTextCollectorTest extends SapphireTest {
|
|||||||
|
|
||||||
public function tearDown() {
|
public function tearDown() {
|
||||||
SS_TemplateLoader::instance()->popManifest();
|
SS_TemplateLoader::instance()->popManifest();
|
||||||
|
// Pop if added during testing
|
||||||
|
if(SS_ClassLoader::instance()->getManifest() === $this->manifest) {
|
||||||
|
SS_ClassLoader::instance()->popManifest();
|
||||||
|
}
|
||||||
parent::tearDown();
|
parent::tearDown();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -520,6 +525,8 @@ YAML;
|
|||||||
$local = i18n::get_locale();
|
$local = i18n::get_locale();
|
||||||
i18n::set_locale('en_US');
|
i18n::set_locale('en_US');
|
||||||
i18n::set_default_locale('en_US');
|
i18n::set_default_locale('en_US');
|
||||||
|
i18n::include_by_locale('en');
|
||||||
|
i18n::include_by_locale('en_US');
|
||||||
|
|
||||||
$c = new i18nTextCollector();
|
$c = new i18nTextCollector();
|
||||||
$c->setWriter(new i18nTextCollector_Writer_Php());
|
$c->setWriter(new i18nTextCollector_Writer_Php());
|
||||||
@ -688,28 +695,28 @@ YAML;
|
|||||||
* Test that duplicate keys are resolved to the appropriate modules
|
* Test that duplicate keys are resolved to the appropriate modules
|
||||||
*/
|
*/
|
||||||
public function testResolveDuplicates() {
|
public function testResolveDuplicates() {
|
||||||
|
SS_ClassLoader::instance()->pushManifest($this->manifest);
|
||||||
$collector = new i18nTextCollectorTest_Collector();
|
$collector = new i18nTextCollectorTest_Collector();
|
||||||
|
|
||||||
// Dummy data as collected
|
// Dummy data as collected
|
||||||
$data1 = array(
|
$data1 = array(
|
||||||
'framework' => array(
|
'i18ntestmodule' => array(
|
||||||
'DataObject.PLURALNAME' => array('Data Objects'),
|
'i18nTestModule.PLURALNAME' => array('Data Objects'),
|
||||||
'DataObject.SINGULARNAME' => array('Data Object')
|
'i18nTestModule.SINGULARNAME' => array('Data Object')
|
||||||
),
|
),
|
||||||
'mymodule' => array(
|
'mymodule' => array(
|
||||||
'DataObject.PLURALNAME' => array('Ignored String'),
|
'i18nTestModule.PLURALNAME' => array('Ignored String'),
|
||||||
'DataObject.STREETNAME' => array('Shortland Street')
|
'i18nTestModule.STREETNAME' => array('Shortland Street')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'framework' => array(
|
'i18ntestmodule' => array(
|
||||||
'DataObject.PLURALNAME' => array('Data Objects'),
|
'i18nTestModule.PLURALNAME' => array('Data Objects'),
|
||||||
// Because DataObject is in framework module
|
'i18nTestModule.SINGULARNAME' => array('Data Object')
|
||||||
'DataObject.SINGULARNAME' => array('Data Object')
|
|
||||||
),
|
),
|
||||||
'mymodule' => array(
|
'mymodule' => array(
|
||||||
// Because this key doesn't exist in framework strings
|
// Because this key doesn't exist in i18ntestmodule strings
|
||||||
'DataObject.STREETNAME' => array('Shortland Street')
|
'i18nTestModule.STREETNAME' => array('Shortland Street')
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -719,22 +726,22 @@ YAML;
|
|||||||
// Test getConflicts
|
// Test getConflicts
|
||||||
$data2 = array(
|
$data2 = array(
|
||||||
'module1' => array(
|
'module1' => array(
|
||||||
'DataObject.ONE' => array('One'),
|
'i18ntestmodule.ONE' => array('One'),
|
||||||
'DataObject.TWO' => array('Two'),
|
'i18ntestmodule.TWO' => array('Two'),
|
||||||
'DataObject.THREE' => array('Three'),
|
'i18ntestmodule.THREE' => array('Three'),
|
||||||
),
|
),
|
||||||
'module2' => array(
|
'module2' => array(
|
||||||
'DataObject.THREE' => array('Three'),
|
'i18ntestmodule.THREE' => array('Three'),
|
||||||
),
|
),
|
||||||
'module3' => array(
|
'module3' => array(
|
||||||
'DataObject.TWO' => array('Two'),
|
'i18ntestmodule.TWO' => array('Two'),
|
||||||
'DataObject.THREE' => array('Three'),
|
'i18ntestmodule.THREE' => array('Three'),
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$conflictsA = $collector->getConflicts_Test($data2);
|
$conflictsA = $collector->getConflicts_Test($data2);
|
||||||
sort($conflictsA);
|
sort($conflictsA);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('DataObject.THREE', 'DataObject.TWO'),
|
array('i18ntestmodule.THREE', 'i18ntestmodule.TWO'),
|
||||||
$conflictsA
|
$conflictsA
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -742,7 +749,7 @@ YAML;
|
|||||||
unset($data2['module3']);
|
unset($data2['module3']);
|
||||||
$conflictsB = $collector->getConflicts_Test($data2);
|
$conflictsB = $collector->getConflicts_Test($data2);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array('DataObject.THREE'),
|
array('i18ntestmodule.THREE'),
|
||||||
$conflictsB
|
$conflictsB
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -751,6 +758,7 @@ YAML;
|
|||||||
* Test ability for textcollector to detect modules
|
* Test ability for textcollector to detect modules
|
||||||
*/
|
*/
|
||||||
public function testModuleDetection() {
|
public function testModuleDetection() {
|
||||||
|
SS_ClassLoader::instance()->pushManifest($this->manifest);
|
||||||
$collector = new i18nTextCollectorTest_Collector();
|
$collector = new i18nTextCollectorTest_Collector();
|
||||||
$modules = $collector->getModules_Test($this->alternateBasePath);
|
$modules = $collector->getModules_Test($this->alternateBasePath);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -763,6 +771,13 @@ YAML;
|
|||||||
),
|
),
|
||||||
$modules
|
$modules
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->assertEquals('i18ntestmodule', $collector->findModuleForClass_Test('i18nTestNamespacedClass'));
|
||||||
|
$this->assertEquals(
|
||||||
|
'i18ntestmodule',
|
||||||
|
$collector->findModuleForClass_Test('i18nTest\\i18nTestNamespacedClass')
|
||||||
|
);
|
||||||
|
$this->assertEquals('i18ntestmodule', $collector->findModuleForClass_Test('i18nTestSubModule'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -784,11 +799,12 @@ YAML;
|
|||||||
// Normal module should have predictable dir structure
|
// Normal module should have predictable dir structure
|
||||||
$testFiles = $collector->getFileListForModule_Test('i18ntestmodule');
|
$testFiles = $collector->getFileListForModule_Test('i18ntestmodule');
|
||||||
$testRoot = $this->alternateBasePath . '/i18ntestmodule';
|
$testRoot = $this->alternateBasePath . '/i18ntestmodule';
|
||||||
$this->assertEquals(6, count($testFiles));
|
$this->assertEquals(7, count($testFiles));
|
||||||
// Code in code folder is detected
|
// Code in code folder is detected
|
||||||
$this->assertArrayHasKey("{$testRoot}/code/i18nTestModule.php", $testFiles);
|
$this->assertArrayHasKey("{$testRoot}/code/i18nTestModule.php", $testFiles);
|
||||||
$this->assertArrayHasKey("{$testRoot}/code/subfolder/_config.php", $testFiles);
|
$this->assertArrayHasKey("{$testRoot}/code/subfolder/_config.php", $testFiles);
|
||||||
$this->assertArrayHasKey("{$testRoot}/code/subfolder/i18nTestSubModule.php", $testFiles);
|
$this->assertArrayHasKey("{$testRoot}/code/subfolder/i18nTestSubModule.php", $testFiles);
|
||||||
|
$this->assertArrayHasKey("{$testRoot}/code/subfolder/i18nTestNamespacedClass.php", $testFiles);
|
||||||
// Templates in templates folder is detected
|
// Templates in templates folder is detected
|
||||||
$this->assertArrayHasKey("{$testRoot}/templates/Includes/i18nTestModuleInclude.ss", $testFiles);
|
$this->assertArrayHasKey("{$testRoot}/templates/Includes/i18nTestModuleInclude.ss", $testFiles);
|
||||||
$this->assertArrayHasKey("{$testRoot}/templates/Layout/i18nTestModule.ss", $testFiles);
|
$this->assertArrayHasKey("{$testRoot}/templates/Layout/i18nTestModule.ss", $testFiles);
|
||||||
@ -836,11 +852,15 @@ class i18nTextCollectorTest_Collector extends i18nTextCollector implements TestO
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getFileListForModule_Test($module) {
|
public function getFileListForModule_Test($module) {
|
||||||
return parent::getFileListForModule($module);
|
return $this->getFileListForModule($module);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConflicts_Test($entitiesByModule) {
|
public function getConflicts_Test($entitiesByModule) {
|
||||||
return parent::getConflicts($entitiesByModule);
|
return $this->getConflicts($entitiesByModule);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findModuleForClass_Test($class) {
|
||||||
|
return $this->findModuleForClass($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\SS_Filterable;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -217,7 +221,7 @@ class ArrayListTest extends SapphireTest {
|
|||||||
$map = $list->map('ID', 'Name');
|
$map = $list->map('ID', 'Name');
|
||||||
// Items added after calling map should not be included retroactively
|
// Items added after calling map should not be included retroactively
|
||||||
$list->add(array('ID' => 7, 'Name' => 'Andrew'));
|
$list->add(array('ID' => 7, 'Name' => 'Andrew'));
|
||||||
$this->assertInstanceOf('SS_Map', $map);
|
$this->assertInstanceOf('SilverStripe\\ORM\\SS_Map', $map);
|
||||||
$this->assertEquals(array(
|
$this->assertEquals(array(
|
||||||
1 => 'Steve',
|
1 => 'Steve',
|
||||||
3 => 'Bob',
|
3 => 'Bob',
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Versioning\ChangeSetItem;
|
||||||
|
|
||||||
class ChangeSetItemTest_Versioned extends DataObject {
|
class ChangeSetItemTest_Versioned extends DataObject {
|
||||||
private static $db = [
|
private static $db = [
|
||||||
'Foo' => 'Int'
|
'Foo' => 'Int'
|
||||||
];
|
];
|
||||||
|
|
||||||
private static $extensions = [
|
private static $extensions = [
|
||||||
"Versioned"
|
"SilverStripe\\ORM\\Versioning\\Versioned"
|
||||||
];
|
];
|
||||||
|
|
||||||
function canEdit($member = null) { return true; }
|
function canEdit($member = null) { return true; }
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Versioning\ChangeSet;
|
||||||
|
use SilverStripe\ORM\Versioning\ChangeSetItem;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides a set of targettable permissions for tested models
|
* Provides a set of targettable permissions for tested models
|
||||||
*
|
*
|
||||||
@ -55,7 +60,7 @@ class ChangeSetTest_Base extends DataObject implements TestOnly {
|
|||||||
];
|
];
|
||||||
|
|
||||||
private static $extensions = [
|
private static $extensions = [
|
||||||
"Versioned",
|
"SilverStripe\\ORM\\Versioning\\Versioned",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +84,7 @@ class ChangeSetTest_Mid extends DataObject implements TestOnly {
|
|||||||
];
|
];
|
||||||
|
|
||||||
private static $extensions = [
|
private static $extensions = [
|
||||||
"Versioned",
|
"SilverStripe\\ORM\\Versioning\\Versioned",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +99,7 @@ class ChangeSetTest_End extends DataObject implements TestOnly {
|
|||||||
];
|
];
|
||||||
|
|
||||||
private static $extensions = [
|
private static $extensions = [
|
||||||
"Versioned",
|
"SilverStripe\\ORM\\Versioning\\Versioned",
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBClassName;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBClassName;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
class DBClassNameTest extends SapphireTest {
|
class DBClassNameTest extends SapphireTest {
|
||||||
|
|
||||||
@ -63,9 +66,9 @@ class DBClassNameTest extends SapphireTest {
|
|||||||
*/
|
*/
|
||||||
public function testBaseClassDetection() {
|
public function testBaseClassDetection() {
|
||||||
// Explicit DataObject
|
// Explicit DataObject
|
||||||
$field1 = new DBClassName('MyClass', 'DataObject');
|
$field1 = new DBClassName('MyClass', 'SilverStripe\\ORM\\DataObject');
|
||||||
$this->assertEquals('DataObject', $field1->getBaseClass());
|
$this->assertEquals('SilverStripe\\ORM\\DataObject', $field1->getBaseClass());
|
||||||
$this->assertNotEquals('DataObject', $field1->getDefault());
|
$this->assertNotEquals('SilverStripe\\ORM\\DataObject', $field1->getDefault());
|
||||||
|
|
||||||
// Explicit base class
|
// Explicit base class
|
||||||
$field2 = new DBClassName('MyClass', 'DBClassNameTest_Object');
|
$field2 = new DBClassName('MyClass', 'DBClassNameTest_Object');
|
||||||
@ -86,14 +89,14 @@ class DBClassNameTest extends SapphireTest {
|
|||||||
|
|
||||||
// Missing
|
// Missing
|
||||||
$field5 = new DBClassName('MyClass');
|
$field5 = new DBClassName('MyClass');
|
||||||
$this->assertEquals('DataObject', $field5->getBaseClass());
|
$this->assertEquals('SilverStripe\\ORM\\DataObject', $field5->getBaseClass());
|
||||||
$this->assertNotEquals('DataObject', $field5->getDefault());
|
$this->assertNotEquals('SilverStripe\\ORM\\DataObject', $field5->getDefault());
|
||||||
|
|
||||||
// Invalid class
|
// Invalid class
|
||||||
$field6 = new DBClassName('MyClass');
|
$field6 = new DBClassName('MyClass');
|
||||||
$field6->setTable('InvalidTable');
|
$field6->setTable('InvalidTable');
|
||||||
$this->assertEquals('DataObject', $field6->getBaseClass());
|
$this->assertEquals('SilverStripe\\ORM\\DataObject', $field6->getBaseClass());
|
||||||
$this->assertNotEquals('DataObject', $field6->getDefault());
|
$this->assertNotEquals('SilverStripe\\ORM\\DataObject', $field6->getDefault());
|
||||||
|
|
||||||
// Custom default_classname
|
// Custom default_classname
|
||||||
$field7 = new DBClassName('MyClass');
|
$field7 = new DBClassName('MyClass');
|
||||||
@ -106,12 +109,12 @@ class DBClassNameTest extends SapphireTest {
|
|||||||
class DBClassNameTest_Object extends DataObject implements TestOnly {
|
class DBClassNameTest_Object extends DataObject implements TestOnly {
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned'
|
'SilverStripe\\ORM\\Versioning\\Versioned'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'DefaultClass' => 'DBClassName',
|
'DefaultClass' => 'DBClassName',
|
||||||
'AnyClass' => 'DBClassName("DataObject")',
|
'AnyClass' => "DBClassName('SilverStripe\\ORM\\DataObject')",
|
||||||
'ChildClass' => 'DBClassName("DBClassNameTest_ObjectSubClass")',
|
'ChildClass' => 'DBClassName("DBClassNameTest_ObjectSubClass")',
|
||||||
'LeafClass' => 'DBClassName("DBClassNameTest_ObjectSubSubClass")'
|
'LeafClass' => 'DBClassName("DBClassNameTest_ObjectSubSubClass")'
|
||||||
);
|
);
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBMoney;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBMoney;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBCurrency;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBCurrency;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
@ -65,7 +69,7 @@ class DBDateTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
$date = DBField::create_field('Date', '2003-03-04');
|
$date = DBField::create_field('Date', '2003-03-04');
|
||||||
Config::inst()->update('SilverStripe\Model\FieldType\DBDate', 'nice_format', 'd F Y');
|
Config::inst()->update('SilverStripe\\ORM\\FieldType\\DBDate', 'nice_format', 'd F Y');
|
||||||
$this->assertEquals('04 March 2003', $date->Nice());
|
$this->assertEquals('04 March 2003', $date->Nice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBVarchar;
|
|
||||||
use SilverStripe\Model\FieldType\DBText;
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||||
|
use SilverStripe\ORM\FieldType\DBText;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBHTMLText;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBMoney;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBMoney;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Partially based on Zend_CurrencyTest.
|
* Partially based on Zend_CurrencyTest.
|
||||||
@ -25,14 +29,14 @@ class DBMoneyTest extends SapphireTest {
|
|||||||
|
|
||||||
public function testMoneyFieldsReturnedAsObjects() {
|
public function testMoneyFieldsReturnedAsObjects() {
|
||||||
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
|
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBMoney', $obj->MyMoney);
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBMoney', $obj->MyMoney);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testLoadFromFixture() {
|
public function testLoadFromFixture() {
|
||||||
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
|
$obj = $this->objFromFixture('MoneyTest_DataObject', 'test1');
|
||||||
|
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBMoney', $obj->MyMoney);
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBMoney', $obj->MyMoney);
|
||||||
$this->assertEquals($obj->MyMoney->getCurrency(), 'EUR');
|
$this->assertEquals($obj->MyMoney->getCurrency(), 'EUR');
|
||||||
$this->assertEquals($obj->MyMoney->getAmount(), 1.23);
|
$this->assertEquals($obj->MyMoney->getAmount(), 1.23);
|
||||||
}
|
}
|
||||||
@ -46,7 +50,7 @@ class DBMoneyTest extends SapphireTest {
|
|||||||
$this->assertNotContains('MyMoney', array_keys($changed));
|
$this->assertNotContains('MyMoney', array_keys($changed));
|
||||||
|
|
||||||
// With changes
|
// With changes
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBMoney', $obj->MyMoney);
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBMoney', $obj->MyMoney);
|
||||||
$obj->MyMoney->setAmount(99);
|
$obj->MyMoney->setAmount(99);
|
||||||
$changed = $obj->getChangedFields();
|
$changed = $obj->getChangedFields();
|
||||||
$this->assertContains('MyMoney', array_keys($changed), 'Field is detected as changed');
|
$this->assertContains('MyMoney', array_keys($changed), 'Field is detected as changed');
|
||||||
@ -263,7 +267,7 @@ class DBMoneyTest extends SapphireTest {
|
|||||||
public function testLoadIntoDataObject() {
|
public function testLoadIntoDataObject() {
|
||||||
$obj = new MoneyTest_DataObject();
|
$obj = new MoneyTest_DataObject();
|
||||||
|
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBMoney', $obj->obj('MyMoney'));
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBMoney', $obj->obj('MyMoney'));
|
||||||
|
|
||||||
$m = new DBMoney();
|
$m = new DBMoney();
|
||||||
$m->setValue(array(
|
$m->setValue(array(
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBPercentage;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBPercentage;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBString;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\FieldType\DBString;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBText;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBText;
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBYear;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBYear;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
|
@ -1,6 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Filesystem as SS_Filesystem;
|
use Filesystem as SS_Filesystem;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\Versioning\DataDifferencer;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
@ -94,7 +98,7 @@ class DataDifferencerTest extends SapphireTest {
|
|||||||
class DataDifferencerTest_Object extends DataObject implements TestOnly {
|
class DataDifferencerTest_Object extends DataObject implements TestOnly {
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned'
|
'SilverStripe\\ORM\\Versioning\\Versioned'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
class DataExtensionTest extends SapphireTest {
|
class DataExtensionTest extends SapphireTest {
|
||||||
protected static $fixture_file = 'DataExtensionTest.yml';
|
protected static $fixture_file = 'DataExtensionTest.yml';
|
||||||
|
|
||||||
@ -14,7 +17,7 @@ class DataExtensionTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
protected $requiredExtensions = array(
|
protected $requiredExtensions = array(
|
||||||
'DataObject' => array( 'DataExtensionTest_AppliedToDO' ),
|
'\SilverStripe\ORM\DataObject' => array( 'DataExtensionTest_AppliedToDO' ),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testOneToManyAssociationWithExtension() {
|
public function testOneToManyAssociationWithExtension() {
|
||||||
@ -152,7 +155,7 @@ class DataExtensionTest extends SapphireTest {
|
|||||||
public function testDbObjectOnExtendedFields() {
|
public function testDbObjectOnExtendedFields() {
|
||||||
$member = $this->objFromFixture('DataExtensionTest_Member', 'member1');
|
$member = $this->objFromFixture('DataExtensionTest_Member', 'member1');
|
||||||
$this->assertNotNull($member->dbObject('Website'));
|
$this->assertNotNull($member->dbObject('Website'));
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBVarchar', $member->dbObject('Website'));
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBVarchar', $member->dbObject('Website'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testExtensionCanBeAppliedToDataObject() {
|
public function testExtensionCanBeAppliedToDataObject() {
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\SS_Filterable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class DataObjectDuplicationTest extends SapphireTest {
|
class DataObjectDuplicationTest extends SapphireTest {
|
||||||
|
|
||||||
protected $usesDatabase = true;
|
protected $usesDatabase = true;
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -434,7 +439,7 @@ class VersionedLazy_DataObject extends DataObject implements TestOnly {
|
|||||||
"PageName" => "Varchar"
|
"PageName" => "Varchar"
|
||||||
);
|
);
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned('Stage', 'Live')"
|
"SilverStripe\\ORM\\Versioning\\Versioned('Stage', 'Live')"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +448,6 @@ class VersionedLazySub_DataObject extends VersionedLazy_DataObject {
|
|||||||
"ExtraField" => "Varchar",
|
"ExtraField" => "Varchar",
|
||||||
);
|
);
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned('Stage', 'Live')"
|
"SilverStripe\\ORM\\Versioning\\Versioned('Stage', 'Live')"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBClassName;
|
|
||||||
|
use SilverStripe\ORM\Connect\MySQLSchemaManager;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\FieldType\DBClassName;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
class DataObjectSchemaGenerationTest extends SapphireTest {
|
class DataObjectSchemaGenerationTest extends SapphireTest {
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
@ -134,6 +139,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
DBClassName::clear_classname_cache();
|
DBClassName::clear_classname_cache();
|
||||||
$do1 = new DataObjectSchemaGenerationTest_DO();
|
$do1 = new DataObjectSchemaGenerationTest_DO();
|
||||||
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
||||||
|
/** @skipUpgrade */
|
||||||
$this->assertEquals("DBClassName", $fields['ClassName']);
|
$this->assertEquals("DBClassName", $fields['ClassName']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
@ -149,6 +155,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
$item1->write();
|
$item1->write();
|
||||||
DBClassName::clear_classname_cache();
|
DBClassName::clear_classname_cache();
|
||||||
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
||||||
|
/** @skipUpgrade */
|
||||||
$this->assertEquals("DBClassName", $fields['ClassName']);
|
$this->assertEquals("DBClassName", $fields['ClassName']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
@ -164,6 +171,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
$item2->write();
|
$item2->write();
|
||||||
DBClassName::clear_classname_cache();
|
DBClassName::clear_classname_cache();
|
||||||
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
||||||
|
/** @skipUpgrade */
|
||||||
$this->assertEquals("DBClassName", $fields['ClassName']);
|
$this->assertEquals("DBClassName", $fields['ClassName']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
@ -181,6 +189,7 @@ class DataObjectSchemaGenerationTest extends SapphireTest {
|
|||||||
$item2->write();
|
$item2->write();
|
||||||
DBClassName::clear_classname_cache();
|
DBClassName::clear_classname_cache();
|
||||||
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
$fields = DataObject::database_fields('DataObjectSchemaGenerationTest_DO');
|
||||||
|
/** @skipUpgrade */
|
||||||
$this->assertEquals("DBClassName", $fields['ClassName']);
|
$this->assertEquals("DBClassName", $fields['ClassName']);
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
array(
|
array(
|
||||||
@ -201,7 +210,7 @@ class DataObjectSchemaGenerationTest_DO extends DataObject implements TestOnly {
|
|||||||
'NumberField' => 'Decimal',
|
'NumberField' => 'Decimal',
|
||||||
'FloatingField' => 'Decimal(10,3,1.1)',
|
'FloatingField' => 'Decimal(10,3,1.1)',
|
||||||
'TextValue' => 'Varchar',
|
'TextValue' => 'Varchar',
|
||||||
'Date' => 'SS_Datetime',
|
'Date' => 'Datetime',
|
||||||
'MyNumber' => 'Int'
|
'MyNumber' => 'Int'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests schema inspection of DataObjects
|
* Tests schema inspection of DataObjects
|
||||||
*/
|
*/
|
||||||
@ -304,7 +306,7 @@ class DataObjectSchemaTest extends SapphireTest
|
|||||||
$this->assertEquals('DataObjectSchemaTest_BaseClass', $schema->baseDataClass('DataObjectSchemaTest_GRANDChildClass'));
|
$this->assertEquals('DataObjectSchemaTest_BaseClass', $schema->baseDataClass('DataObjectSchemaTest_GRANDChildClass'));
|
||||||
|
|
||||||
$this->setExpectedException('InvalidArgumentException');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
$schema->baseDataClass('DataObject');
|
$schema->baseDataClass('SilverStripe\\ORM\\DataObject');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,11 +4,13 @@
|
|||||||
* Namespaced dataobjcets used by DataObjectSchemaTest
|
* Namespaced dataobjcets used by DataObjectSchemaTest
|
||||||
*/
|
*/
|
||||||
namespace Namespaced\DOST;
|
namespace Namespaced\DOST;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Basic namespaced object
|
* Basic namespaced object
|
||||||
*/
|
*/
|
||||||
class MyObject extends \DataObject implements \TestOnly {
|
class MyObject extends DataObject implements \TestOnly {
|
||||||
private static $db = [
|
private static $db = [
|
||||||
'Title' => 'Varchar',
|
'Title' => 'Varchar',
|
||||||
'Description' => 'Text',
|
'Description' => 'Text',
|
||||||
@ -18,7 +20,7 @@ class MyObject extends \DataObject implements \TestOnly {
|
|||||||
/**
|
/**
|
||||||
* Namespaced object with custom table
|
* Namespaced object with custom table
|
||||||
*/
|
*/
|
||||||
class MyObject_CustomTable extends \DataObject implements \TestOnly {
|
class MyObject_CustomTable extends DataObject implements \TestOnly {
|
||||||
private static $table_name = 'CustomNamespacedTable';
|
private static $table_name = 'CustomNamespacedTable';
|
||||||
private static $db = [
|
private static $db = [
|
||||||
'Title' => 'Varchar',
|
'Title' => 'Varchar',
|
||||||
@ -42,7 +44,7 @@ class MyObject_NestedObject extends MyObject implements \TestOnly {
|
|||||||
/**
|
/**
|
||||||
* Namespaced object with custom table that itself is namespaced
|
* Namespaced object with custom table that itself is namespaced
|
||||||
*/
|
*/
|
||||||
class MyObject_NamespacedTable extends \DataObject implements \TestOnly {
|
class MyObject_NamespacedTable extends DataObject implements \TestOnly {
|
||||||
private static $table_name = 'Custom\NamespacedTable';
|
private static $table_name = 'Custom\NamespacedTable';
|
||||||
private static $db = [
|
private static $db = [
|
||||||
'Title' => 'Varchar',
|
'Title' => 'Varchar',
|
||||||
@ -71,7 +73,7 @@ class MyObject_Namespaced_Subclass extends MyObject_NamespacedTable implements \
|
|||||||
* Namespaced class without any fields
|
* Namespaced class without any fields
|
||||||
* has a has_many to another namespaced table
|
* has a has_many to another namespaced table
|
||||||
*/
|
*/
|
||||||
class MyObject_NoFields extends \DataObject implements \TestOnly {
|
class MyObject_NoFields extends DataObject implements \TestOnly {
|
||||||
private static $has_many = [
|
private static $has_many = [
|
||||||
'Owns' => 'Namespaced\DOST\MyObject_NamespacedTable',
|
'Owns' => 'Namespaced\DOST\MyObject_NamespacedTable',
|
||||||
];
|
];
|
||||||
|
@ -1,6 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLDatabase;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
@ -314,7 +321,7 @@ class DataObjectTest extends SapphireTest {
|
|||||||
'belongs_many_many is properly inspected');
|
'belongs_many_many is properly inspected');
|
||||||
$this->assertEquals(singleton('DataObjectTest_CEO')->getRelationClass('Company'), 'DataObjectTest_Company',
|
$this->assertEquals(singleton('DataObjectTest_CEO')->getRelationClass('Company'), 'DataObjectTest_Company',
|
||||||
'belongs_to is properly inspected');
|
'belongs_to is properly inspected');
|
||||||
$this->assertEquals(singleton('DataObjectTest_Fan')->getRelationClass('Favourite'), 'DataObject',
|
$this->assertEquals(singleton('DataObjectTest_Fan')->getRelationClass('Favourite'), 'SilverStripe\\ORM\\DataObject',
|
||||||
'polymorphic has_one is properly inspected');
|
'polymorphic has_one is properly inspected');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,7 +362,7 @@ class DataObjectTest extends SapphireTest {
|
|||||||
// check behaviour of dbObject with polymorphic relations
|
// check behaviour of dbObject with polymorphic relations
|
||||||
$favouriteDBObject = $fan1->dbObject('Favourite');
|
$favouriteDBObject = $fan1->dbObject('Favourite');
|
||||||
$favouriteValue = $favouriteDBObject->getValue();
|
$favouriteValue = $favouriteDBObject->getValue();
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBPolymorphicForeignKey', $favouriteDBObject);
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBPolymorphicForeignKey', $favouriteDBObject);
|
||||||
$this->assertEquals($favourite->ID, $favouriteValue->ID);
|
$this->assertEquals($favourite->ID, $favouriteValue->ID);
|
||||||
$this->assertEquals($favourite->ClassName, $favouriteValue->ClassName);
|
$this->assertEquals($favourite->ClassName, $favouriteValue->ClassName);
|
||||||
}
|
}
|
||||||
@ -1048,7 +1055,7 @@ class DataObjectTest extends SapphireTest {
|
|||||||
public function testWritingInvalidDataObjectThrowsException() {
|
public function testWritingInvalidDataObjectThrowsException() {
|
||||||
$validatedObject = new DataObjectTest_ValidatedObject();
|
$validatedObject = new DataObjectTest_ValidatedObject();
|
||||||
|
|
||||||
$this->setExpectedException('ValidationException');
|
$this->setExpectedException('SilverStripe\\ORM\\ValidationException');
|
||||||
$validatedObject->write();
|
$validatedObject->write();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1102,7 +1109,7 @@ class DataObjectTest extends SapphireTest {
|
|||||||
$this->assertFalse(DataObject::has_own_table("DataObjectTest_FieldlessSubTable"));
|
$this->assertFalse(DataObject::has_own_table("DataObjectTest_FieldlessSubTable"));
|
||||||
|
|
||||||
/* Return false if you don't pass it a subclass of DataObject */
|
/* Return false if you don't pass it a subclass of DataObject */
|
||||||
$this->assertFalse(DataObject::has_own_table("DataObject"));
|
$this->assertFalse(DataObject::has_own_table("SilverStripe\\ORM\\DataObject"));
|
||||||
$this->assertFalse(DataObject::has_own_table("ViewableData"));
|
$this->assertFalse(DataObject::has_own_table("ViewableData"));
|
||||||
$this->assertFalse(DataObject::has_own_table("ThisIsntADataObject"));
|
$this->assertFalse(DataObject::has_own_table("ThisIsntADataObject"));
|
||||||
}
|
}
|
||||||
@ -1286,7 +1293,7 @@ class DataObjectTest extends SapphireTest {
|
|||||||
|
|
||||||
// Check everything works when no relation is present
|
// Check everything works when no relation is present
|
||||||
$teamWithoutSponsor = $this->objFromFixture('DataObjectTest_Team', 'team3');
|
$teamWithoutSponsor = $this->objFromFixture('DataObjectTest_Team', 'team3');
|
||||||
$this->assertInstanceOf('ManyManyList', $teamWithoutSponsor->Sponsors());
|
$this->assertInstanceOf('SilverStripe\\ORM\\ManyManyList', $teamWithoutSponsor->Sponsors());
|
||||||
$this->assertEquals(0, $teamWithoutSponsor->Sponsors()->count());
|
$this->assertEquals(0, $teamWithoutSponsor->Sponsors()->count());
|
||||||
|
|
||||||
// Test that belongs_many_many can be infered from with getNonReciprocalComponent
|
// Test that belongs_many_many can be infered from with getNonReciprocalComponent
|
||||||
@ -1414,7 +1421,8 @@ class DataObjectTest extends SapphireTest {
|
|||||||
$assertions = array(
|
$assertions = array(
|
||||||
'DataObjectTest_Player' => 'Data Object Test Player',
|
'DataObjectTest_Player' => 'Data Object Test Player',
|
||||||
'DataObjectTest_Team' => 'Data Object Test Team',
|
'DataObjectTest_Team' => 'Data Object Test Team',
|
||||||
'DataObjectTest_Fixture' => 'Data Object Test Fixture'
|
'DataObjectTest_Fixture' => 'Data Object Test Fixture',
|
||||||
|
'DataObjectTest\NamespacedClass' => 'Namespaced Class',
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach($assertions as $class => $expectedSingularName) {
|
foreach($assertions as $class => $expectedSingularName) {
|
||||||
@ -1752,16 +1760,16 @@ class DataObjectTest extends SapphireTest {
|
|||||||
$captain = $this->objFromFixture('DataObjectTest_Player', 'captain1');
|
$captain = $this->objFromFixture('DataObjectTest_Player', 'captain1');
|
||||||
|
|
||||||
// Test traversal of a single has_one
|
// Test traversal of a single has_one
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBVarchar', $captain->relObject('FavouriteTeam.Title'));
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBVarchar', $captain->relObject('FavouriteTeam.Title'));
|
||||||
$this->assertEquals("Team 1", $captain->relObject('FavouriteTeam.Title')->getValue());
|
$this->assertEquals("Team 1", $captain->relObject('FavouriteTeam.Title')->getValue());
|
||||||
|
|
||||||
// Test direct field access
|
// Test direct field access
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBBoolean', $captain->relObject('IsRetired'));
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBBoolean', $captain->relObject('IsRetired'));
|
||||||
$this->assertEquals(1, $captain->relObject('IsRetired')->getValue());
|
$this->assertEquals(1, $captain->relObject('IsRetired')->getValue());
|
||||||
|
|
||||||
$player = $this->objFromFixture('DataObjectTest_Player', 'player2');
|
$player = $this->objFromFixture('DataObjectTest_Player', 'player2');
|
||||||
// Test that we can traverse more than once, and that arbitrary methods are okay
|
// Test that we can traverse more than once, and that arbitrary methods are okay
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBVarchar', $player->relObject('Teams.First.Title'));
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBVarchar', $player->relObject('Teams.First.Title'));
|
||||||
$this->assertEquals("Team 1", $player->relObject('Teams.First.Title')->getValue());
|
$this->assertEquals("Team 1", $player->relObject('Teams.First.Title')->getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1878,7 +1886,7 @@ class DataObjectTest_Fixture extends DataObject implements TestOnly {
|
|||||||
|
|
||||||
// Field types
|
// Field types
|
||||||
'DateField' => 'Date',
|
'DateField' => 'Date',
|
||||||
'DatetimeField' => 'SS_Datetime',
|
'DatetimeField' => 'Datetime',
|
||||||
|
|
||||||
'MyFieldWithDefault' => 'Varchar',
|
'MyFieldWithDefault' => 'Varchar',
|
||||||
'MyFieldWithAltDefault' => 'Varchar'
|
'MyFieldWithAltDefault' => 'Varchar'
|
||||||
@ -1976,7 +1984,7 @@ class DataObjectTest_Company extends DataObject implements TestOnly {
|
|||||||
private static $has_one = array (
|
private static $has_one = array (
|
||||||
'CEO' => 'DataObjectTest_CEO',
|
'CEO' => 'DataObjectTest_CEO',
|
||||||
'PreviousCEO' => 'DataObjectTest_CEO',
|
'PreviousCEO' => 'DataObjectTest_CEO',
|
||||||
'Owner' => 'DataObject' // polymorphic
|
'Owner' => 'SilverStripe\\ORM\\DataObject' // polymorphic
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array (
|
private static $has_many = array (
|
||||||
@ -2040,8 +2048,8 @@ class DataObjectTest_Fan extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Favourite' => 'DataObject', // Polymorphic relation
|
'Favourite' => 'SilverStripe\\ORM\\DataObject', // Polymorphic relation
|
||||||
'SecondFavourite' => 'DataObject'
|
'SecondFavourite' => 'SilverStripe\\ORM\\DataObject'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace DataObjectTest;
|
namespace DataObjectTest;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Right now this is only used in DataListTest, but extending it to DataObjectTest in the future would make sense.
|
* Right now this is only used in DataListTest, but extending it to DataObjectTest in the future would make sense.
|
||||||
* Note that it was deliberated named to include "\N" to try and trip bad code up.
|
* Note that it was deliberated named to include "\N" to try and trip bad code up.
|
||||||
*/
|
*/
|
||||||
class NamespacedClass extends \DataObject implements \TestOnly {
|
class NamespacedClass extends DataObject implements \TestOnly {
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Name' => 'Varchar',
|
'Name' => 'Varchar',
|
||||||
);
|
);
|
||||||
@ -16,13 +18,13 @@ class NamespacedClass extends \DataObject implements \TestOnly {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
class RelationClass extends \DataObject implements \TestOnly {
|
class RelationClass extends DataObject implements \TestOnly {
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'Title' => 'Varchar'
|
'Title' => 'Varchar'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Parent' => 'DataObject'
|
'Parent' => 'SilverStripe\\ORM\\DataObject'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataQuery;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
class DataQueryTest extends SapphireTest {
|
class DataQueryTest extends SapphireTest {
|
||||||
|
|
||||||
protected static $fixture_file = 'DataQueryTest.yml';
|
protected static $fixture_file = 'DataQueryTest.yml';
|
||||||
@ -389,7 +393,7 @@ class DataQueryTest_F extends DataObject implements TestOnly {
|
|||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
'SortOrder' => 'Int',
|
'SortOrder' => 'Int',
|
||||||
'MyDate' => 'SS_Datetime',
|
'MyDate' => 'Datetime',
|
||||||
'MyString' => 'Text'
|
'MyString' => 'Text'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLDatabase;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLSchemaManager;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage Testing
|
* @subpackage Testing
|
||||||
|
@ -1,7 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@link Datetime} class.
|
* Tests for {@link Datetime} class.
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\GroupedList;
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link GroupedList} list decorator.
|
* Tests for the {@link GroupedList} list decorator.
|
||||||
*
|
*
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class HierarchyTest extends SapphireTest {
|
class HierarchyTest extends SapphireTest {
|
||||||
|
|
||||||
protected static $fixture_file = 'HierarchyTest.yml';
|
protected static $fixture_file = 'HierarchyTest.yml';
|
||||||
|
|
||||||
protected $requiredExtensions = array(
|
protected $requiredExtensions = array(
|
||||||
'HierarchyTest_Object' => array('Hierarchy', 'Versioned'),
|
'HierarchyTest_Object' => array('SilverStripe\\ORM\\Hierarchy\\Hierarchy', 'SilverStripe\\ORM\\Versioning\\Versioned'),
|
||||||
'HierarchyHideTest_Object' => array('Hierarchy', 'Versioned'),
|
'HierarchyHideTest_Object' => array('SilverStripe\\ORM\\Hierarchy\\Hierarchy', 'SilverStripe\\ORM\\Versioning\\Versioned'),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
@ -566,8 +570,8 @@ class HierarchyTest_Object extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Hierarchy',
|
'SilverStripe\\ORM\\Hierarchy\\Hierarchy',
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
public function cmstreeclasses() {
|
public function cmstreeclasses() {
|
||||||
@ -581,8 +585,8 @@ class HierarchyHideTest_Object extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Hierarchy',
|
'SilverStripe\\ORM\\Hierarchy\\Hierarchy',
|
||||||
"Versioned('Stage', 'Live')",
|
"SilverStripe\\ORM\\Versioning\\Versioned('Stage', 'Live')",
|
||||||
);
|
);
|
||||||
|
|
||||||
public function cmstreeclasses() {
|
public function cmstreeclasses() {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBMoney;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBMoney;
|
||||||
|
use SilverStripe\ORM\ManyManyList;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
@ -32,7 +37,7 @@ class ManyManyListTest extends SapphireTest {
|
|||||||
$check = $obj->Clients()->First();
|
$check = $obj->Clients()->First();
|
||||||
|
|
||||||
$this->assertEquals('Foo', $check->Reference, 'Basic scalar fields should exist');
|
$this->assertEquals('Foo', $check->Reference, 'Basic scalar fields should exist');
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBMoney', $check->Worth, 'Composite fields should exist on the record');
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBMoney', $check->Worth, 'Composite fields should exist on the record');
|
||||||
$this->assertEquals(100, $check->Worth->getAmount());
|
$this->assertEquals(100, $check->Worth->getAmount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\SS_Map;
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLiConnector;
|
||||||
|
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage testing
|
* @subpackage testing
|
||||||
@ -27,12 +32,12 @@ class MySQLDatabaseTest extends SapphireTest {
|
|||||||
'SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" WHERE "Sort" > ? ORDER BY "Sort"',
|
'SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" WHERE "Sort" > ? ORDER BY "Sort"',
|
||||||
array(2)
|
array(2)
|
||||||
);
|
);
|
||||||
$this->assertInstanceOf('MySQLStatement', $result1);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\MySQLStatement', $result1);
|
||||||
$this->assertInstanceOf('MySQLStatement', $result2);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\MySQLStatement', $result2);
|
||||||
|
|
||||||
// Also select non-prepared statement
|
// Also select non-prepared statement
|
||||||
$result3 = DB::get_connector()->query('SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" ORDER BY "Sort"');
|
$result3 = DB::get_connector()->query('SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" ORDER BY "Sort"');
|
||||||
$this->assertInstanceOf('MySQLQuery', $result3);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\MySQLQuery', $result3);
|
||||||
|
|
||||||
// Iterating one level should not buffer, but return the right result
|
// Iterating one level should not buffer, but return the right result
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -101,13 +106,13 @@ class MySQLDatabaseTest extends SapphireTest {
|
|||||||
// Test update which affects no rows
|
// Test update which affects no rows
|
||||||
$query->setWhere(array('Title' => 'Bob'));
|
$query->setWhere(array('Title' => 'Bob'));
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
$this->assertInstanceOf('MySQLQuery', $result);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\MySQLQuery', $result);
|
||||||
$this->assertEquals(0, DB::affected_rows());
|
$this->assertEquals(0, DB::affected_rows());
|
||||||
|
|
||||||
// Test update which affects some rows
|
// Test update which affects some rows
|
||||||
$query->setWhere(array('Title' => 'First Item'));
|
$query->setWhere(array('Title' => 'First Item'));
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
$this->assertInstanceOf('MySQLQuery', $result);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\MySQLQuery', $result);
|
||||||
$this->assertEquals(1, DB::affected_rows());
|
$this->assertEquals(1, DB::affected_rows());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Connect\PDOConnector;
|
||||||
|
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage testing
|
* @subpackage testing
|
||||||
@ -27,12 +31,12 @@ class PDODatabaseTest extends SapphireTest {
|
|||||||
'SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" WHERE "Sort" > ? ORDER BY "Sort"',
|
'SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" WHERE "Sort" > ? ORDER BY "Sort"',
|
||||||
array(2)
|
array(2)
|
||||||
);
|
);
|
||||||
$this->assertInstanceOf('PDOQuery', $result1);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\PDOQuery', $result1);
|
||||||
$this->assertInstanceOf('PDOQuery', $result2);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\PDOQuery', $result2);
|
||||||
|
|
||||||
// Also select non-prepared statement
|
// Also select non-prepared statement
|
||||||
$result3 = DB::get_connector()->query('SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" ORDER BY "Sort"');
|
$result3 = DB::get_connector()->query('SELECT "Sort", "Title" FROM "MySQLDatabaseTest_Data" ORDER BY "Sort"');
|
||||||
$this->assertInstanceOf('PDOQuery', $result3);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\PDOQuery', $result3);
|
||||||
|
|
||||||
// Iterating one level should not buffer, but return the right result
|
// Iterating one level should not buffer, but return the right result
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
@ -101,13 +105,13 @@ class PDODatabaseTest extends SapphireTest {
|
|||||||
// Test update which affects no rows
|
// Test update which affects no rows
|
||||||
$query->setWhere(array('Title' => 'Bob'));
|
$query->setWhere(array('Title' => 'Bob'));
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
$this->assertInstanceOf('PDOQuery', $result);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\PDOQuery', $result);
|
||||||
$this->assertEquals(0, DB::affected_rows());
|
$this->assertEquals(0, DB::affected_rows());
|
||||||
|
|
||||||
// Test update which affects some rows
|
// Test update which affects some rows
|
||||||
$query->setWhere(array('Title' => 'First Item'));
|
$query->setWhere(array('Title' => 'First Item'));
|
||||||
$result = $query->execute();
|
$result = $query->execute();
|
||||||
$this->assertInstanceOf('PDOQuery', $result);
|
$this->assertInstanceOf('SilverStripe\\ORM\\Connect\\PDOQuery', $result);
|
||||||
$this->assertEquals(1, DB::affected_rows());
|
$this->assertEquals(1, DB::affected_rows());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* Tests for the {@link PaginatedList} class.
|
* Tests for the {@link PaginatedList} class.
|
||||||
*
|
*
|
||||||
@ -62,7 +65,7 @@ class PaginatedListTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function testSetPaginationFromQuery() {
|
public function testSetPaginationFromQuery() {
|
||||||
$query = $this->getMock('SQLSelect');
|
$query = $this->getMock('SilverStripe\\ORM\\Queries\\SQLSelect');
|
||||||
$query->expects($this->once())
|
$query->expects($this->once())
|
||||||
->method('getLimit')
|
->method('getLimit')
|
||||||
->will($this->returnValue(array('limit' => 15, 'start' => 30)));
|
->will($this->returnValue(array('limit' => 15, 'start' => 30)));
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Queries\SQLInsert;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@see SQLInsert}
|
* Tests for {@see SQLInsert}
|
||||||
@ -27,7 +31,7 @@ class SQLInsertTest extends SapphireTest {
|
|||||||
->assign('"Description"', 'No description');
|
->assign('"Description"', 'No description');
|
||||||
$sql = $query->sql($parameters);
|
$sql = $query->sql($parameters);
|
||||||
// Only test this case if using the default query builder
|
// Only test this case if using the default query builder
|
||||||
if(get_class(DB::get_conn()->getQueryBuilder()) === 'DBQueryBuilder') {
|
if(get_class(DB::get_conn()->getQueryBuilder()) === 'SilverStripe\\ORM\\Connect\\DBQueryBuilder') {
|
||||||
$this->assertSQLEquals(
|
$this->assertSQLEquals(
|
||||||
'INSERT INTO "SQLInsertTestBase" ("Title", "HasFun", "Age", "Description") VALUES (?, ?, ?, ?)',
|
'INSERT INTO "SQLInsertTestBase" ("Title", "HasFun", "Age", "Description") VALUES (?, ?, ?, ?)',
|
||||||
$sql
|
$sql
|
||||||
@ -59,7 +63,7 @@ class SQLInsertTest extends SapphireTest {
|
|||||||
));
|
));
|
||||||
$sql = $query->sql($parameters);
|
$sql = $query->sql($parameters);
|
||||||
// Only test this case if using the default query builder
|
// Only test this case if using the default query builder
|
||||||
if(get_class(DB::get_conn()->getQueryBuilder()) === 'DBQueryBuilder') {
|
if(get_class(DB::get_conn()->getQueryBuilder()) === 'SilverStripe\\ORM\\Connect\\DBQueryBuilder') {
|
||||||
$this->assertSQLEquals(
|
$this->assertSQLEquals(
|
||||||
'INSERT INTO "SQLInsertTestBase" ("Title", "Age", "Description") VALUES (?, ?, ?), (?, ?, ?)',
|
'INSERT INTO "SQLInsertTestBase" ("Title", "Age", "Description") VALUES (?, ?, ?), (?, ?, ?)',
|
||||||
$sql
|
$sql
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLDatabase;
|
||||||
|
use SilverStripe\ORM\Queries\SQLSelect;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -747,7 +752,7 @@ class SQLSelectTest_DO extends DataObject implements TestOnly {
|
|||||||
"Name" => "Varchar",
|
"Name" => "Varchar",
|
||||||
"Meta" => "Varchar",
|
"Meta" => "Varchar",
|
||||||
"Common" => "Varchar",
|
"Common" => "Varchar",
|
||||||
"Date" => "SS_Datetime"
|
"Date" => "Datetime"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for {@see SQLUpdate}
|
* Tests for {@see SQLUpdate}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
@ -12,7 +14,7 @@ class TimeTest extends SapphireTest {
|
|||||||
$time = DBField::create_field('Time', '17:15:55');
|
$time = DBField::create_field('Time', '17:15:55');
|
||||||
$this->assertEquals('5:15pm', $time->Nice());
|
$this->assertEquals('5:15pm', $time->Nice());
|
||||||
|
|
||||||
Config::inst()->update('SilverStripe\Model\FieldType\DBTime', 'nice_format', 'H:i:s');
|
Config::inst()->update('SilverStripe\\ORM\\FieldType\\DBTime', 'nice_format', 'H:i:s');
|
||||||
$this->assertEquals('17:15:55', $time->Nice());
|
$this->assertEquals('17:15:55', $time->Nice());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class UnsavedRelationListTest extends SapphireTest {
|
class UnsavedRelationListTest extends SapphireTest {
|
||||||
protected static $fixture_file = 'UnsavedRelationListTest.yml';
|
protected static $fixture_file = 'UnsavedRelationListTest.yml';
|
||||||
|
|
||||||
@ -15,10 +17,10 @@ class UnsavedRelationListTest extends SapphireTest {
|
|||||||
'Returned UnsavedRelationList should be the same.');
|
'Returned UnsavedRelationList should be the same.');
|
||||||
|
|
||||||
$object->write();
|
$object->write();
|
||||||
$this->assertInstanceOf('RelationList', $object->Children());
|
$this->assertInstanceOf('SilverStripe\\ORM\\RelationList', $object->Children());
|
||||||
$this->assertNotEquals($children, $object->Children(),
|
$this->assertNotEquals($children, $object->Children(),
|
||||||
'Return should be a RelationList after first write');
|
'Return should be a RelationList after first write');
|
||||||
$this->assertInstanceOf('RelationList', $object->Siblings());
|
$this->assertInstanceOf('SilverStripe\\ORM\\RelationList', $object->Siblings());
|
||||||
$this->assertNotEquals($siblings, $object->Siblings(),
|
$this->assertNotEquals($siblings, $object->Siblings(),
|
||||||
'Return should be a RelationList after first write');
|
'Return should be a RelationList after first write');
|
||||||
}
|
}
|
||||||
@ -242,7 +244,7 @@ class UnsavedRelationListTest_DataObject extends DataObject implements TestOnly
|
|||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
'Parent' => 'UnsavedRelationListTest_DataObject',
|
'Parent' => 'UnsavedRelationListTest_DataObject',
|
||||||
'RelatedObject' => 'DataObject'
|
'RelatedObject' => 'SilverStripe\\ORM\\DataObject'
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_many = array(
|
private static $has_many = array(
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ValidationResult;
|
||||||
|
use SilverStripe\ORM\ValidationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage Testing
|
* @subpackage Testing
|
||||||
|
@ -1,4 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
use SilverStripe\ORM\Versioning\VersionableExtension;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -9,7 +14,7 @@ class VersionableExtensionsTest extends SapphireTest
|
|||||||
protected static $fixture_file = 'VersionableExtensionsFixtures.yml';
|
protected static $fixture_file = 'VersionableExtensionsFixtures.yml';
|
||||||
|
|
||||||
protected $requiredExtensions = array(
|
protected $requiredExtensions = array(
|
||||||
'VersionableExtensionsTest_DataObject' => array('Versioned'),
|
'VersionableExtensionsTest_DataObject' => array('SilverStripe\\ORM\\Versioning\\Versioned'),
|
||||||
);
|
);
|
||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
@ -21,7 +26,7 @@ class VersionableExtensionsTest extends SapphireTest
|
|||||||
{
|
{
|
||||||
Config::nest();
|
Config::nest();
|
||||||
|
|
||||||
VersionableExtensionsTest_DataObject::add_extension('Versioned');
|
VersionableExtensionsTest_DataObject::add_extension('SilverStripe\\ORM\\Versioning\\Versioned');
|
||||||
VersionableExtensionsTest_DataObject::add_extension('VersionableExtensionsTest_Extension');
|
VersionableExtensionsTest_DataObject::add_extension('VersionableExtensionsTest_Extension');
|
||||||
|
|
||||||
$cfg = Config::inst();
|
$cfg = Config::inst();
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests ownership API of versioned DataObjects
|
* Tests ownership API of versioned DataObjects
|
||||||
*/
|
*/
|
||||||
@ -37,15 +41,15 @@ class VersionedOwnershipTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual "sleep" that doesn't actually slow execution, only advances SS_DateTime::now()
|
* Virtual "sleep" that doesn't actually slow execution, only advances DBDateTime::now()
|
||||||
*
|
*
|
||||||
* @param int $minutes
|
* @param int $minutes
|
||||||
*/
|
*/
|
||||||
protected function sleep($minutes) {
|
protected function sleep($minutes) {
|
||||||
$now = SS_Datetime::now();
|
$now = DBDatetime::now();
|
||||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $now->getValue());
|
$date = DateTime::createFromFormat('Y-m-d H:i:s', $now->getValue());
|
||||||
$date->modify("+{$minutes} minutes");
|
$date->modify("+{$minutes} minutes");
|
||||||
SS_Datetime::set_mock_now($date->format('Y-m-d H:i:s'));
|
DBDatetime::set_mock_now($date->format('Y-m-d H:i:s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,7 +197,7 @@ class VersionedOwnershipTest extends SapphireTest {
|
|||||||
|
|
||||||
// Check that stage record is ok
|
// Check that stage record is ok
|
||||||
/** @var VersionedOwnershipTest_Subclass $subclass2Stage */
|
/** @var VersionedOwnershipTest_Subclass $subclass2Stage */
|
||||||
$subclass2Stage = \Versioned::get_by_stage('VersionedOwnershipTest_Subclass', 'Stage')->byID($subclass2ID);
|
$subclass2Stage = Versioned::get_by_stage('VersionedOwnershipTest_Subclass', 'Stage')->byID($subclass2ID);
|
||||||
$this->assertDOSEquals(
|
$this->assertDOSEquals(
|
||||||
[
|
[
|
||||||
['Title' => 'Related 2 Modified'],
|
['Title' => 'Related 2 Modified'],
|
||||||
@ -215,7 +219,7 @@ class VersionedOwnershipTest extends SapphireTest {
|
|||||||
|
|
||||||
// Live records are unchanged
|
// Live records are unchanged
|
||||||
/** @var VersionedOwnershipTest_Subclass $subclass2Live */
|
/** @var VersionedOwnershipTest_Subclass $subclass2Live */
|
||||||
$subclass2Live = \Versioned::get_by_stage('VersionedOwnershipTest_Subclass', 'Live')->byID($subclass2ID);
|
$subclass2Live = Versioned::get_by_stage('VersionedOwnershipTest_Subclass', 'Live')->byID($subclass2ID);
|
||||||
$this->assertDOSEquals(
|
$this->assertDOSEquals(
|
||||||
[
|
[
|
||||||
['Title' => 'Related 2'],
|
['Title' => 'Related 2'],
|
||||||
@ -588,7 +592,7 @@ class VersionedOwnershipTest extends SapphireTest {
|
|||||||
*/
|
*/
|
||||||
class VersionedOwnershipTest_Object extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_Object extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
@ -630,7 +634,7 @@ class VersionedOwnershipTest_Subclass extends VersionedOwnershipTest_Object impl
|
|||||||
*/
|
*/
|
||||||
class VersionedOwnershipTest_Related extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_Related extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
@ -662,7 +666,7 @@ class VersionedOwnershipTest_Related extends DataObject implements TestOnly {
|
|||||||
*/
|
*/
|
||||||
class VersionedOwnershipTest_RelatedMany extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_RelatedMany extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
@ -684,7 +688,7 @@ class VersionedOwnershipTest_RelatedMany extends DataObject implements TestOnly
|
|||||||
class VersionedOwnershipTest_Attachment extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_Attachment extends DataObject implements TestOnly {
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
@ -707,7 +711,7 @@ class VersionedOwnershipTest_Attachment extends DataObject implements TestOnly {
|
|||||||
*/
|
*/
|
||||||
class VersionedOwnershipTest_Page extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_Page extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
@ -742,7 +746,7 @@ class VersionedOwnershipTest_Page extends DataObject implements TestOnly {
|
|||||||
*/
|
*/
|
||||||
class VersionedOwnershipTest_Banner extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_Banner extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
@ -766,7 +770,7 @@ class VersionedOwnershipTest_Banner extends DataObject implements TestOnly {
|
|||||||
*/
|
*/
|
||||||
class VersionedOwnershipTest_CustomRelation extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_CustomRelation extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
@ -796,7 +800,7 @@ class VersionedOwnershipTest_CustomRelation extends DataObject implements TestOn
|
|||||||
*/
|
*/
|
||||||
class VersionedOwnershipTest_Image extends DataObject implements TestOnly {
|
class VersionedOwnershipTest_Image extends DataObject implements TestOnly {
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned',
|
'SilverStripe\\ORM\\Versioning\\Versioned',
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
@ -22,8 +28,8 @@ class VersionedTest extends SapphireTest {
|
|||||||
);
|
);
|
||||||
|
|
||||||
protected $requiredExtensions = array(
|
protected $requiredExtensions = array(
|
||||||
"VersionedTest_DataObject" => array('Versioned'),
|
"VersionedTest_DataObject" => array('SilverStripe\\ORM\\Versioning\\Versioned'),
|
||||||
"VersionedTest_WithIndexes" => array('Versioned'),
|
"VersionedTest_WithIndexes" => array('SilverStripe\\ORM\\Versioning\\Versioned'),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function testUniqueIndexes() {
|
public function testUniqueIndexes() {
|
||||||
@ -198,11 +204,11 @@ class VersionedTest extends SapphireTest {
|
|||||||
public function testVersionedFieldsAdded() {
|
public function testVersionedFieldsAdded() {
|
||||||
$obj = new VersionedTest_DataObject();
|
$obj = new VersionedTest_DataObject();
|
||||||
// Check that the Version column is added as a full-fledged column
|
// Check that the Version column is added as a full-fledged column
|
||||||
$this->assertInstanceOf('SilverStripe\\Model\\FieldType\\DBInt', $obj->dbObject('Version'));
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBInt', $obj->dbObject('Version'));
|
||||||
|
|
||||||
$obj2 = new VersionedTest_Subclass();
|
$obj2 = new VersionedTest_Subclass();
|
||||||
// Check that the Version column is added as a full-fledged column
|
// Check that the Version column is added as a full-fledged column
|
||||||
$this->assertInstanceOf('SilverStripe\\Model\\FieldType\\DBInt', $obj2->dbObject('Version'));
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBInt', $obj2->dbObject('Version'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testVersionedFieldsNotInCMS() {
|
public function testVersionedFieldsNotInCMS() {
|
||||||
@ -412,15 +418,15 @@ class VersionedTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual "sleep" that doesn't actually slow execution, only advances SS_DateTime::now()
|
* Virtual "sleep" that doesn't actually slow execution, only advances DBDateTime::now()
|
||||||
*
|
*
|
||||||
* @param int $minutes
|
* @param int $minutes
|
||||||
*/
|
*/
|
||||||
protected function sleep($minutes) {
|
protected function sleep($minutes) {
|
||||||
$now = SS_Datetime::now();
|
$now = DBDatetime::now();
|
||||||
$date = DateTime::createFromFormat('Y-m-d H:i:s', $now->getValue());
|
$date = DateTime::createFromFormat('Y-m-d H:i:s', $now->getValue());
|
||||||
$date->modify("+{$minutes} minutes");
|
$date->modify("+{$minutes} minutes");
|
||||||
SS_Datetime::set_mock_now($date->format('Y-m-d H:i:s'));
|
DBDatetime::set_mock_now($date->format('Y-m-d H:i:s'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -936,7 +942,7 @@ class VersionedTest extends SapphireTest {
|
|||||||
"NewField" => "Varchar",
|
"NewField" => "Varchar",
|
||||||
));
|
));
|
||||||
|
|
||||||
VersionedTest_RelatedWithoutVersion::add_extension("Versioned");
|
VersionedTest_RelatedWithoutVersion::add_extension("SilverStripe\\ORM\\Versioning\\Versioned");
|
||||||
$this->resetDBSchema(true);
|
$this->resetDBSchema(true);
|
||||||
$testData = new VersionedTest_RelatedWithoutVersion();
|
$testData = new VersionedTest_RelatedWithoutVersion();
|
||||||
$testData->NewField = 'Test';
|
$testData->NewField = 'Test';
|
||||||
@ -1050,7 +1056,7 @@ class VersionedTest_DataObject extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned",
|
"SilverStripe\\ORM\\Versioning\\Versioned",
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
@ -1085,7 +1091,7 @@ class VersionedTest_WithIndexes extends DataObject implements TestOnly {
|
|||||||
'UniqS' => 'Int',
|
'UniqS' => 'Int',
|
||||||
);
|
);
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned"
|
"SilverStripe\\ORM\\Versioning\\Versioned"
|
||||||
);
|
);
|
||||||
private static $indexes = array(
|
private static $indexes = array(
|
||||||
'UniqS_idx' => 'unique ("UniqS")',
|
'UniqS_idx' => 'unique ("UniqS")',
|
||||||
@ -1147,7 +1153,7 @@ class VersionedTest_SingleStage extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
'Versioned("Versioned")'
|
'SilverStripe\ORM\Versioning\Versioned("Versioned")'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1162,7 +1168,7 @@ class VersionedTest_PublicStage extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned"
|
"SilverStripe\\ORM\\Versioning\\Versioned"
|
||||||
);
|
);
|
||||||
|
|
||||||
public function canView($member = null) {
|
public function canView($member = null) {
|
||||||
@ -1200,7 +1206,7 @@ class VersionedTest_PublicViaExtension extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned",
|
"SilverStripe\\ORM\\Versioning\\Versioned",
|
||||||
"VersionedTest_PublicExtension"
|
"VersionedTest_PublicExtension"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLDatabase;
|
||||||
|
use SilverStripe\ORM\Connect\MySQLSchemaManager;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class FulltextFilterTest extends SapphireTest {
|
class FulltextFilterTest extends SapphireTest {
|
||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
@ -115,7 +120,7 @@ class FulltextFilterTest_DataObject extends DataObject implements TestOnly {
|
|||||||
);
|
);
|
||||||
|
|
||||||
private static $create_table_options = array(
|
private static $create_table_options = array(
|
||||||
"MySQLDatabase" => "ENGINE=MyISAM",
|
MySQLSchemaManager::ID => "ENGINE=MyISAM",
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class SearchContextTest extends SapphireTest {
|
class SearchContextTest extends SapphireTest {
|
||||||
|
|
||||||
protected static $fixture_file = 'SearchContextTest.yml';
|
protected static $fixture_file = 'SearchContextTest.yml';
|
||||||
@ -238,7 +240,7 @@ class SearchContextTest_Project extends DataObject implements TestOnly {
|
|||||||
class SearchContextTest_Deadline extends DataObject implements TestOnly {
|
class SearchContextTest_Deadline extends DataObject implements TestOnly {
|
||||||
|
|
||||||
private static $db = array(
|
private static $db = array(
|
||||||
"CompletionDate" => "SS_Datetime"
|
"CompletionDate" => "Datetime"
|
||||||
);
|
);
|
||||||
|
|
||||||
private static $has_one = array(
|
private static $has_one = array(
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This test class will focus on the when an search filter contains relational
|
* This test class will focus on the when an search filter contains relational
|
||||||
* component such as has_one, has_many, many_many, the {@link SearchFilter::applyRelation($query)}
|
* component such as has_one, has_many, many_many, the {@link SearchFilter::applyRelation($query)}
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -169,7 +172,7 @@ class MemberAuthenticatorTest extends SapphireTest {
|
|||||||
{
|
{
|
||||||
Config::inst()->update('Member', 'lock_out_after_incorrect_logins', 1);
|
Config::inst()->update('Member', 'lock_out_after_incorrect_logins', 1);
|
||||||
Config::inst()->update('Member', 'lock_out_delay_mins', 10);
|
Config::inst()->update('Member', 'lock_out_delay_mins', 10);
|
||||||
SS_Datetime::set_mock_now('2016-04-18 00:00:00');
|
DBDatetime::set_mock_now('2016-04-18 00:00:00');
|
||||||
$controller = new Security();
|
$controller = new Security();
|
||||||
$form = new Form($controller, 'Form', new FieldList(), new FieldList());
|
$form = new Form($controller, 'Form', new FieldList(), new FieldList());
|
||||||
|
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\DataExtension;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
@ -48,7 +54,7 @@ class MemberTest extends FunctionalTest {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException ValidationException
|
* @expectedException SilverStripe\ORM\ValidationException
|
||||||
*/
|
*/
|
||||||
public function testWriteDoesntMergeNewRecordWithExistingMember() {
|
public function testWriteDoesntMergeNewRecordWithExistingMember() {
|
||||||
$m1 = new Member();
|
$m1 = new Member();
|
||||||
@ -61,7 +67,7 @@ class MemberTest extends FunctionalTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException ValidationException
|
* @expectedException SilverStripe\ORM\ValidationException
|
||||||
*/
|
*/
|
||||||
public function testWriteDoesntMergeExistingMemberOnIdentifierChange() {
|
public function testWriteDoesntMergeExistingMemberOnIdentifierChange() {
|
||||||
$m1 = new Member();
|
$m1 = new Member();
|
||||||
@ -169,7 +175,7 @@ class MemberTest extends FunctionalTest {
|
|||||||
$this->assertTrue($passwords->current()->checkPassword('test1'), "Password test1 not found in MemberRecord");
|
$this->assertTrue($passwords->current()->checkPassword('test1'), "Password test1 not found in MemberRecord");
|
||||||
|
|
||||||
$passwords->next();
|
$passwords->next();
|
||||||
$this->assertInstanceOf('DataObject', $passwords->current());
|
$this->assertInstanceOf('SilverStripe\\ORM\\DataObject', $passwords->current());
|
||||||
$this->assertTrue($passwords->current()->checkPassword('1nitialPassword'),
|
$this->assertTrue($passwords->current()->checkPassword('1nitialPassword'),
|
||||||
"Password 1nitialPassword not found in MemberRecord");
|
"Password 1nitialPassword not found in MemberRecord");
|
||||||
|
|
||||||
@ -913,7 +919,7 @@ class MemberTest extends FunctionalTest {
|
|||||||
$firstHash->ExpiryDate = '2000-01-01 00:00:00';
|
$firstHash->ExpiryDate = '2000-01-01 00:00:00';
|
||||||
$firstHash->write();
|
$firstHash->write();
|
||||||
|
|
||||||
SS_DateTime::set_mock_now('1999-12-31 23:59:59');
|
DBDateTime::set_mock_now('1999-12-31 23:59:59');
|
||||||
|
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
'Security/login',
|
'Security/login',
|
||||||
@ -939,7 +945,7 @@ class MemberTest extends FunctionalTest {
|
|||||||
$firstHash->ExpiryDate = '2000-01-01 00:00:00';
|
$firstHash->ExpiryDate = '2000-01-01 00:00:00';
|
||||||
$firstHash->write();
|
$firstHash->write();
|
||||||
|
|
||||||
SS_DateTime::set_mock_now('2000-01-01 00:00:01');
|
DBDateTime::set_mock_now('2000-01-01 00:00:01');
|
||||||
|
|
||||||
$response = $this->get(
|
$response = $this->get(
|
||||||
'Security/login',
|
'Security/login',
|
||||||
@ -952,7 +958,7 @@ class MemberTest extends FunctionalTest {
|
|||||||
);
|
);
|
||||||
$this->assertNotContains($message, $response->getBody());
|
$this->assertNotContains($message, $response->getBody());
|
||||||
$this->session()->inst_set('loggedInAs', null);
|
$this->session()->inst_set('loggedInAs', null);
|
||||||
SS_Datetime::clear_mock_now();
|
DBDatetime::clear_mock_now();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRememberMeMultipleDevices() {
|
public function testRememberMeMultipleDevices() {
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBDatetime;
|
|
||||||
use SilverStripe\Model\FieldType\DBClassName;
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||||
|
use SilverStripe\ORM\FieldType\DBClassName;
|
||||||
|
use SilverStripe\ORM\DB;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test the security class, including log-in form, change password form, etc
|
* Test the security class, including log-in form, change password form, etc
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
/**
|
/**
|
||||||
* @package framework
|
* @package framework
|
||||||
* @subpackage tests
|
* @subpackage tests
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class YamlFixtureTest extends SapphireTest {
|
class YamlFixtureTest extends SapphireTest {
|
||||||
|
|
||||||
protected $extraDataObjects = array(
|
protected $extraDataObjects = array(
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
use SilverStripe\ORM\Versioning\Versioned;
|
||||||
|
|
||||||
// Not actually a data object, we just want a ViewableData object that's just for us
|
// Not actually a data object, we just want a ViewableData object that's just for us
|
||||||
class SSViewerCacheBlockTest_Model extends DataObject implements TestOnly {
|
class SSViewerCacheBlockTest_Model extends DataObject implements TestOnly {
|
||||||
|
|
||||||
@ -25,7 +28,7 @@ class SSViewerCacheBlockTest_VersionedModel extends DataObject implements TestOn
|
|||||||
protected $entropy = 'default';
|
protected $entropy = 'default';
|
||||||
|
|
||||||
private static $extensions = array(
|
private static $extensions = array(
|
||||||
"Versioned('Stage', 'Live')"
|
"SilverStripe\\ORM\\Versioning\\Versioned('Stage', 'Live')"
|
||||||
);
|
);
|
||||||
|
|
||||||
public function setEntropy($entropy) {
|
public function setEntropy($entropy) {
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\ArrayList;
|
||||||
|
use SilverStripe\ORM\DataObject;
|
||||||
|
|
||||||
class SSViewerTest extends SapphireTest {
|
class SSViewerTest extends SapphireTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -153,7 +153,7 @@ class ViewableDataTest extends SapphireTest {
|
|||||||
|
|
||||||
// Casted data should be the string wrapped in a DBField-object.
|
// Casted data should be the string wrapped in a DBField-object.
|
||||||
$this->assertNotEmpty($castedData, 'Casted data was empty.');
|
$this->assertNotEmpty($castedData, 'Casted data was empty.');
|
||||||
$this->assertInstanceOf('SilverStripe\Model\FieldType\DBField', $castedData, 'Casted data should be instance of DBField.');
|
$this->assertInstanceOf('SilverStripe\\ORM\\FieldType\\DBField', $castedData, 'Casted data should be instance of DBField.');
|
||||||
|
|
||||||
$this->assertEquals($uncastedData, $castedData->getValue(), 'Casted and uncasted strings are not equal.');
|
$this->assertEquals($uncastedData, $castedData->getValue(), 'Casted and uncasted strings are not equal.');
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use SilverStripe\ORM\DataList;
|
||||||
|
use SilverStripe\ORM\DataModel;
|
||||||
class GenericTemplateGlobalProvider implements TemplateGlobalProvider {
|
class GenericTemplateGlobalProvider implements TemplateGlobalProvider {
|
||||||
|
|
||||||
public static function get_template_global_variables() {
|
public static function get_template_global_variables() {
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBField;
|
|
||||||
|
use SilverStripe\ORM\FieldType\DBField;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This tracks the current scope for an SSViewer instance. It has three goals:
|
* This tracks the current scope for an SSViewer instance. It has three goals:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use SilverStripe\Model\FieldType\DBVarchar;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ViewableData object is any object that can be rendered into a template/view.
|
* A ViewableData object is any object that can be rendered into a template/view.
|
||||||
@ -315,7 +315,7 @@ class ViewableData extends Object implements IteratorAggregate {
|
|||||||
|
|
||||||
foreach($ancestry as $class) {
|
foreach($ancestry as $class) {
|
||||||
if(!isset(self::$casting_cache[$class]) && $merge) {
|
if(!isset(self::$casting_cache[$class]) && $merge) {
|
||||||
$mergeFields = is_subclass_of($class, 'DataObject') ? array('db', 'casting') : array('casting');
|
$mergeFields = is_subclass_of($class, 'SilverStripe\\ORM\\DataObject') ? array('db', 'casting') : array('casting');
|
||||||
|
|
||||||
if($mergeFields) foreach($mergeFields as $field) {
|
if($mergeFields) foreach($mergeFields as $field) {
|
||||||
$casting = Config::inst()->get($class, $field, Config::UNINHERITED);
|
$casting = Config::inst()->get($class, $field, Config::UNINHERITED);
|
||||||
|
Loading…
Reference in New Issue
Block a user