mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
API Move various classes to more appropriate namespaces (#11370)
Also rename ViewableData to ModelData ahead of the template layer lift-and-shift
This commit is contained in:
parent
7793664efe
commit
e2e32317d6
@ -96,6 +96,8 @@
|
||||
"SilverStripe\\i18n\\Tests\\": "tests/php/i18n/",
|
||||
"SilverStripe\\Logging\\": "src/Logging/",
|
||||
"SilverStripe\\Logging\\Tests\\": "tests/php/Logging/",
|
||||
"SilverStripe\\Model\\": "src/Model/",
|
||||
"SilverStripe\\Model\\Tests\\": "tests/php/Model/",
|
||||
"SilverStripe\\ORM\\": "src/ORM/",
|
||||
"SilverStripe\\ORM\\Tests\\": "tests/php/ORM/",
|
||||
"SilverStripe\\Security\\": "src/Security/",
|
||||
|
@ -230,7 +230,7 @@ class Controller extends RequestHandler implements TemplateGlobalProvider
|
||||
}
|
||||
$this->setResponse($response);
|
||||
} else {
|
||||
// Could be Controller, or ViewableData_Customised controller wrapper
|
||||
// Could be Controller, or ModelDataCustomised controller wrapper
|
||||
if (ClassInfo::hasMethod($response, 'getViewer')) {
|
||||
if (isset($_REQUEST['debug_request'])) {
|
||||
$class = static::class;
|
||||
|
@ -13,11 +13,11 @@ use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ThemeResourceLoader;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Email as SymfonyEmail;
|
||||
@ -56,9 +56,9 @@ class Email extends SymfonyEmail
|
||||
|
||||
/**
|
||||
* Additional data available in a template.
|
||||
* Used in the same way than {@link ViewableData->customize()}.
|
||||
* Used in the same way than {@link ModelData->customize()}.
|
||||
*/
|
||||
private ViewableData $data;
|
||||
private ModelData $data;
|
||||
|
||||
private bool $dataHasBeenSet = false;
|
||||
|
||||
@ -194,7 +194,7 @@ class Email extends SymfonyEmail
|
||||
if ($returnPath) {
|
||||
$this->setReturnPath($returnPath);
|
||||
}
|
||||
$this->data = ViewableData::create();
|
||||
$this->data = ModelData::create();
|
||||
}
|
||||
|
||||
private function getDefaultFrom(): string|array
|
||||
@ -336,7 +336,7 @@ class Email extends SymfonyEmail
|
||||
* IsEmail: used to detect if rendering an email template rather than a page template
|
||||
* BaseUrl: used to get the base URL for the email
|
||||
*/
|
||||
public function getData(): ViewableData
|
||||
public function getData(): ModelData
|
||||
{
|
||||
$extraData = [
|
||||
'IsEmail' => true,
|
||||
@ -357,7 +357,7 @@ class Email extends SymfonyEmail
|
||||
*
|
||||
* Calling setData() once means that any content set via text()/html()/setBody() will have no effect
|
||||
*/
|
||||
public function setData(array|ViewableData $data)
|
||||
public function setData(array|ModelData $data)
|
||||
{
|
||||
if (is_array($data)) {
|
||||
$data = ArrayData::create($data);
|
||||
|
@ -6,7 +6,7 @@ use ArrayAccess;
|
||||
use BadMethodCallException;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
|
||||
/**
|
||||
* Represents a HTTP-request, including a URL that is tokenised for parsing, and a request method
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace SilverStripe\Control\RSS;
|
||||
|
||||
use SilverStripe\Control\Middleware\HTTPCacheControlMiddleware;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\Director;
|
||||
@ -12,14 +12,14 @@ use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\HTTP;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* RSSFeed class
|
||||
*
|
||||
* This class is used to create an RSS feed.
|
||||
*/
|
||||
class RSSFeed extends ViewableData
|
||||
class RSSFeed extends ModelData
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Control\RSS;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use BadMethodCallException;
|
||||
|
||||
/**
|
||||
@ -15,7 +15,7 @@ use BadMethodCallException;
|
||||
*
|
||||
* @see RSSFeed
|
||||
*/
|
||||
class RSSFeed_Entry extends ViewableData
|
||||
class RSSFeed_Entry extends ModelData
|
||||
{
|
||||
/**
|
||||
* Name of the title field of feed entries
|
||||
@ -40,7 +40,7 @@ class RSSFeed_Entry extends ViewableData
|
||||
|
||||
/**
|
||||
* Create a new RSSFeed entry.
|
||||
* @param ViewableData $entry
|
||||
* @param ModelData $entry
|
||||
* @param string $titleField
|
||||
* @param string $descriptionField
|
||||
* @param string $authorField
|
||||
|
@ -13,7 +13,7 @@ use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\PermissionFailureException;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* This class is the base class of any SilverStripe object that can be used to handle HTTP requests.
|
||||
@ -45,7 +45,7 @@ use SilverStripe\View\ViewableData;
|
||||
*
|
||||
* {@link RequestHandler::handleRequest()} is where this behaviour is implemented.
|
||||
*/
|
||||
class RequestHandler extends ViewableData
|
||||
class RequestHandler extends ModelData
|
||||
{
|
||||
|
||||
/**
|
||||
@ -130,7 +130,7 @@ class RequestHandler extends ViewableData
|
||||
/**
|
||||
* Handles URL requests.
|
||||
*
|
||||
* - ViewableData::handleRequest() iterates through each rule in {@link RequestHandler::$url_handlers}.
|
||||
* - ModelData::handleRequest() iterates through each rule in {@link RequestHandler::$url_handlers}.
|
||||
* - If the rule matches, the named method will be called.
|
||||
* - If there is still more URL to be processed, then handleRequest()
|
||||
* is called on the object that that method returns.
|
||||
@ -248,8 +248,8 @@ class RequestHandler extends ViewableData
|
||||
{
|
||||
$handlerClass = static::class;
|
||||
|
||||
// We stop after RequestHandler; in other words, at ViewableData
|
||||
while ($handlerClass && $handlerClass != ViewableData::class) {
|
||||
// We stop after RequestHandler; in other words, at ModelData
|
||||
while ($handlerClass && $handlerClass != ModelData::class) {
|
||||
$urlHandlers = Config::inst()->get($handlerClass, 'url_handlers', Config::UNINHERITED);
|
||||
|
||||
if ($urlHandlers) {
|
||||
|
@ -1,24 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Core;
|
||||
|
||||
use Generator;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use InvalidArgumentException;
|
||||
|
||||
/**
|
||||
* Library of static methods for manipulating arrays.
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib
|
||||
*/
|
||||
class ArrayLib
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Inverses the first and second level keys of an associative
|
||||
* array, keying the result by the second level, and combines
|
||||
@ -54,14 +45,9 @@ class ArrayLib
|
||||
*
|
||||
* @param array $arr
|
||||
* @return array
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::invert()
|
||||
*/
|
||||
public static function invert($arr)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invert()');
|
||||
});
|
||||
|
||||
if (!$arr) {
|
||||
return [];
|
||||
}
|
||||
@ -82,14 +68,9 @@ class ArrayLib
|
||||
*
|
||||
* @param $arr array
|
||||
* @return array
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::valuekey()
|
||||
*/
|
||||
public static function valuekey($arr)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::valuekey()');
|
||||
});
|
||||
|
||||
return array_combine($arr ?? [], $arr ?? []);
|
||||
}
|
||||
|
||||
@ -98,14 +79,9 @@ class ArrayLib
|
||||
*
|
||||
* @param array $array
|
||||
* @return array
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_values_recursive()
|
||||
*/
|
||||
public static function array_values_recursive($array)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::invearray_values_recursivert()');
|
||||
});
|
||||
|
||||
return ArrayLib::flatten($array, false);
|
||||
}
|
||||
|
||||
@ -117,14 +93,9 @@ class ArrayLib
|
||||
* @param $keys array
|
||||
*
|
||||
* @return array
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::filter_keys()
|
||||
*/
|
||||
public static function filter_keys($arr, $keys)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::filter_keys()');
|
||||
});
|
||||
|
||||
foreach ($arr as $key => $v) {
|
||||
if (!in_array($key, $keys ?? [])) {
|
||||
unset($arr[$key]);
|
||||
@ -143,14 +114,9 @@ class ArrayLib
|
||||
* @param array $array
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::is_associative()
|
||||
*/
|
||||
public static function is_associative($array)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::is_associative()');
|
||||
});
|
||||
|
||||
$isAssociative = !empty($array)
|
||||
&& is_array($array)
|
||||
&& ($array !== array_values($array ?? []));
|
||||
@ -169,14 +135,9 @@ class ArrayLib
|
||||
* @param boolean $strict
|
||||
*
|
||||
* @return boolean
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::in_array_recursive()
|
||||
*/
|
||||
public static function in_array_recursive($needle, $haystack, $strict = false)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::in_array_recursive()');
|
||||
});
|
||||
|
||||
if (!is_array($haystack)) {
|
||||
return false;
|
||||
}
|
||||
@ -202,14 +163,9 @@ class ArrayLib
|
||||
* @param $f callback to apply
|
||||
* @param $array array
|
||||
* @return array
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_map_recursive()
|
||||
*/
|
||||
public static function array_map_recursive($f, $array)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_map_recursive()');
|
||||
});
|
||||
|
||||
$applyOrRecurse = function ($v) use ($f) {
|
||||
return is_array($v) ? ArrayLib::array_map_recursive($f, $v) : call_user_func($f, $v);
|
||||
};
|
||||
@ -228,14 +184,9 @@ class ArrayLib
|
||||
* @param array $array
|
||||
*
|
||||
* @return array
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::array_merge_recursive()
|
||||
*/
|
||||
public static function array_merge_recursive($array)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::array_merge_recursive()');
|
||||
});
|
||||
|
||||
$arrays = func_get_args();
|
||||
$merged = [];
|
||||
|
||||
@ -248,7 +199,7 @@ class ArrayLib
|
||||
|
||||
if (!is_array($array)) {
|
||||
trigger_error(
|
||||
'SilverStripe\ORM\ArrayLib::array_merge_recursive() encountered a non array argument',
|
||||
'SilverStripe\Core\ArrayLib::array_merge_recursive() encountered a non array argument',
|
||||
E_USER_WARNING
|
||||
);
|
||||
return [];
|
||||
@ -278,14 +229,9 @@ class ArrayLib
|
||||
* @param array $out
|
||||
*
|
||||
* @return array
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::flatten()
|
||||
*/
|
||||
public static function flatten($array, $preserveKeys = true, &$out = [])
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::flatten()');
|
||||
});
|
||||
|
||||
array_walk_recursive(
|
||||
$array,
|
||||
function ($value, $key) use (&$out, $preserveKeys) {
|
||||
@ -310,14 +256,9 @@ class ArrayLib
|
||||
*
|
||||
* @param array $list
|
||||
* @return Generator
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::iterateVolatile()
|
||||
*/
|
||||
public static function iterateVolatile(array &$list)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::iterateVolatile()');
|
||||
});
|
||||
|
||||
// Keyed by already-iterated items
|
||||
$iterated = [];
|
||||
// Get all items not yet iterated
|
||||
@ -337,14 +278,9 @@ class ArrayLib
|
||||
/**
|
||||
* Similar to shuffle, but retains the existing association between the keys and the values.
|
||||
* Shuffles the array in place.
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative()
|
||||
*/
|
||||
public static function shuffleAssociative(array &$array): void
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\ArrayLib::shuffleAssociative()');
|
||||
});
|
||||
|
||||
$shuffledArray = [];
|
||||
$keys = array_keys($array);
|
||||
shuffle($keys);
|
@ -9,7 +9,7 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Manifest\ClassLoader;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use Psr\SimpleCache\CacheInterface;
|
||||
use SilverStripe\Core\Flushable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
@ -585,7 +585,7 @@ class ClassInfo implements Flushable
|
||||
|
||||
// only keep classes with the Extension applied
|
||||
$classes = array_filter($classes ?? [], function ($class) use ($extensionClass) {
|
||||
return ViewableData::has_extension($class, $extensionClass);
|
||||
return ModelData::has_extension($class, $extensionClass);
|
||||
});
|
||||
|
||||
return $classes;
|
||||
|
@ -21,7 +21,7 @@ use SilverStripe\View\Parsers\URLSegmentFilter;
|
||||
* html: HTML source suitable for use in a page or email
|
||||
* text: Plain-text content, suitable for display to a user as-is, or insertion in a plaintext email.
|
||||
*
|
||||
* Objects of type {@link ViewableData} can have an "escaping type",
|
||||
* Objects of type {@link ModelData} can have an "escaping type",
|
||||
* which determines if they are automatically escaped before output by {@link SSViewer}.
|
||||
*/
|
||||
class Convert
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Core;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Allows an object to have extensions applied to it.
|
||||
@ -43,7 +43,7 @@ trait Extensible
|
||||
* @var array
|
||||
*/
|
||||
private static $unextendable_classes = [
|
||||
ViewableData::class,
|
||||
ModelData::class,
|
||||
];
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Core\Validation;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Symfony\Component\Validator\ConstraintViolationInterface;
|
||||
use Symfony\Component\Validator\Validation;
|
||||
|
@ -1,18 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Core\Validation;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* 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
|
||||
* can be used as a successful test.
|
||||
*
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\Validation\ValidationException
|
||||
*/
|
||||
class ValidationException extends Exception
|
||||
{
|
||||
@ -34,10 +31,6 @@ class ValidationException extends Exception
|
||||
*/
|
||||
public function __construct($result = null, $code = 0)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationException', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
|
||||
// Catch legacy behaviour where second argument was not code
|
||||
if ($code && !is_numeric($code)) {
|
||||
throw new InvalidArgumentException("Code must be numeric");
|
@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Core\Validation;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* A class that combined as a boolean result with an optional list of error messages.
|
||||
@ -12,8 +11,6 @@ use SilverStripe\Dev\Deprecation;
|
||||
*
|
||||
* Each message can have a code or field which will uniquely identify that message. However,
|
||||
* messages can be stored without a field or message as an "overall" message.
|
||||
*
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Core\Validation\ValidationResult
|
||||
*/
|
||||
class ValidationResult
|
||||
{
|
||||
@ -64,13 +61,6 @@ class ValidationResult
|
||||
*/
|
||||
protected $messages = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Core\Validation\ValidationResult', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Record an error against this validation result,
|
||||
*
|
@ -5,7 +5,7 @@ namespace SilverStripe\Dev;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Core\Environment;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* A base for bulk loaders of content into the SilverStripe database.
|
||||
@ -16,7 +16,7 @@ use SilverStripe\View\ViewableData;
|
||||
* @see http://tools.ietf.org/html/rfc4180
|
||||
* @author Ingo Schommer, Silverstripe Ltd. (<firstname>@silverstripe.com)
|
||||
*/
|
||||
abstract class BulkLoader extends ViewableData
|
||||
abstract class BulkLoader extends ModelData
|
||||
{
|
||||
private bool $checkPermissions = false;
|
||||
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Dev;
|
||||
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Encapsulates the result of a {@link BulkLoader} import
|
||||
|
@ -5,14 +5,14 @@ namespace SilverStripe\Dev\Constraint;
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
/**
|
||||
* Constraint for checking if a ViewableData (e.g. ArrayData or any DataObject) contains fields matching the given
|
||||
* Constraint for checking if a ModelData (e.g. ArrayData or any DataObject) contains fields matching the given
|
||||
* key-value pairs.
|
||||
*/
|
||||
class ViewableDataContains extends Constraint implements TestOnly
|
||||
class ModelDataContains extends Constraint implements TestOnly
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
@ -20,7 +20,7 @@ class ViewableDataContains extends Constraint implements TestOnly
|
||||
private $match;
|
||||
|
||||
/**
|
||||
* ViewableDataContains constructor.
|
||||
* ModelDataContains constructor.
|
||||
*/
|
||||
public function __construct(array $match)
|
||||
{
|
||||
@ -44,7 +44,7 @@ class ViewableDataContains extends Constraint implements TestOnly
|
||||
* a boolean value instead: true in case of success, false in case of a
|
||||
* failure.
|
||||
*
|
||||
* @param ViewableData $other Value or object to evaluate.
|
||||
* @param ModelData $other Value or object to evaluate.
|
||||
* @param string $description Additional information about the test
|
||||
* @param bool $returnResult Whether to return a result or throw an exception
|
||||
*
|
@ -5,8 +5,8 @@ namespace SilverStripe\Dev\Constraint;
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Constraint for checking if a SS_List contains items matching the given
|
||||
@ -72,11 +72,11 @@ class SSListContains extends Constraint implements TestOnly
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function checkIfItemEvaluatesRemainingMatches(ViewableData $item): bool
|
||||
protected function checkIfItemEvaluatesRemainingMatches(ModelData $item): bool
|
||||
{
|
||||
$success = false;
|
||||
foreach ($this->matches as $key => $match) {
|
||||
$constraint = new ViewableDataContains($match);
|
||||
$constraint = new ModelDataContains($match);
|
||||
|
||||
if ($constraint->evaluate($item, '', true)) {
|
||||
$success = true;
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Dev\Constraint;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
|
||||
/**
|
||||
* Constraint for checking if a SS_List contains only items matching the given
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Dev\Constraint;
|
||||
use PHPUnit\Framework\Constraint\Constraint;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
|
||||
/**
|
||||
* Constraint for checking if every item in a SS_List matches a given match,
|
||||
@ -19,13 +19,13 @@ class SSListContainsOnlyMatchingItems extends Constraint implements TestOnly
|
||||
private $match;
|
||||
|
||||
/**
|
||||
* @var ViewableDataContains
|
||||
* @var ModelDataContains
|
||||
*/
|
||||
private $constraint;
|
||||
|
||||
public function __construct($match)
|
||||
{
|
||||
$this->constraint = new ViewableDataContains($match);
|
||||
$this->constraint = new ModelDataContains($match);
|
||||
$this->match = $match;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\Connect\TempDatabase;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\IdentityStore;
|
||||
use SilverStripe\Security\Member;
|
||||
|
@ -11,12 +11,12 @@ use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Manifest\ModuleResourceLoader;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\PermissionProvider;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class TaskRunner extends Controller implements PermissionProvider
|
||||
{
|
||||
@ -92,7 +92,7 @@ class TaskRunner extends Controller implements PermissionProvider
|
||||
'Info' => $renderer->renderInfo('SilverStripe Development Tools: Tasks', $baseUrl),
|
||||
];
|
||||
|
||||
return ViewableData::create()->renderWith(static::class, $data);
|
||||
return ModelData::create()->renderWith(static::class, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Displays a set of checkboxes as a logical group.
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
/**
|
||||
* CompositeValidator can contain between 0 and many different types of Validators. Each Validator is itself still
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\i18n\i18n;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\ORM\FieldType\DBDate;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
/**
|
||||
* Form used for editing a date string
|
||||
|
@ -7,7 +7,7 @@ use InvalidArgumentException;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\FieldType\DBDate;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
/**
|
||||
* Form field used for editing date time strings.
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Dropdown field, created from a select tag.
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
/**
|
||||
* Lets you include a nested group of fields inside a template.
|
||||
|
@ -6,7 +6,7 @@ use InvalidArgumentException;
|
||||
use RuntimeException;
|
||||
use SilverStripe\Forms\Tab;
|
||||
use SilverStripe\Forms\TabSet;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
|
@ -7,13 +7,13 @@ use InvalidArgumentException;
|
||||
use SilverStripe\Assets\File;
|
||||
use SilverStripe\Assets\Storage\AssetContainer;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\RelationList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\UnsavedRelationList;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Provides operations for reading and writing uploaded files to/from
|
||||
|
@ -14,12 +14,12 @@ use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\NullSecurityToken;
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\View\AttributesHTML;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Base class for all forms.
|
||||
@ -62,7 +62,7 @@ use SilverStripe\View\ViewableData;
|
||||
* For example, the "URLSegment" field in a standard CMS form would be
|
||||
* accessible through "admin/EditForm/field/URLSegment/FieldHolder".
|
||||
*/
|
||||
class Form extends ViewableData implements HasRequestHandler
|
||||
class Form extends ModelData implements HasRequestHandler
|
||||
{
|
||||
use AttributesHTML;
|
||||
use FormMessage;
|
||||
@ -135,7 +135,7 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
/**
|
||||
* Populated by {@link loadDataFrom()}.
|
||||
*
|
||||
* @var ViewableData|null
|
||||
* @var ModelData|null
|
||||
*/
|
||||
protected $record;
|
||||
|
||||
@ -1225,7 +1225,7 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
* Returns the record that has given this form its data
|
||||
* through {@link loadDataFrom()}.
|
||||
*
|
||||
* @return ViewableData
|
||||
* @return ModelData
|
||||
*/
|
||||
public function getRecord()
|
||||
{
|
||||
@ -1305,7 +1305,7 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
* @uses FormField::setSubmittedValue()
|
||||
* @uses FormField::setValue()
|
||||
*
|
||||
* @param array|ViewableData $data
|
||||
* @param array|ModelData $data
|
||||
* @param int $mergeStrategy
|
||||
* For every field, {@link $data} is interrogated whether it contains a relevant property/key, and
|
||||
* what that property/key's value is.
|
||||
@ -1402,7 +1402,7 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
// There's no other way to tell whether the relation actually exists
|
||||
$exists = false;
|
||||
}
|
||||
// Regular ViewableData access
|
||||
// Regular ModelData access
|
||||
} else {
|
||||
$exists = (
|
||||
isset($data->$name) ||
|
||||
@ -1478,7 +1478,7 @@ class Form extends ViewableData implements HasRequestHandler
|
||||
* Save the contents of this form into the given data object.
|
||||
* It will make use of setCastedField() to do this.
|
||||
*
|
||||
* @param ViewableData&DataObjectInterface $dataObject The object to save data into
|
||||
* @param ModelData&DataObjectInterface $dataObject The object to save data into
|
||||
* @param array<string>|null $fieldList An optional list of fields to process. This can be useful when you have a
|
||||
* form that has some fields that save to one object, and some that save to another.
|
||||
*/
|
||||
|
@ -11,10 +11,10 @@ use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\View\AttributesHTML;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a field in a form.
|
||||
@ -325,7 +325,7 @@ class FormField extends RequestHandler
|
||||
* Creates a new field.
|
||||
*
|
||||
* @param string $name The internal field name, passed to forms.
|
||||
* @param null|string|\SilverStripe\View\ViewableData $title The human-readable field label.
|
||||
* @param null|string|\SilverStripe\Model\ModelData $title The human-readable field label.
|
||||
* @param mixed $value The value of the field.
|
||||
*/
|
||||
public function __construct($name, $title = null, $value = null)
|
||||
@ -458,7 +458,7 @@ class FormField extends RequestHandler
|
||||
*
|
||||
* By default, makes use of $this->dataValue()
|
||||
*
|
||||
* @param ViewableData|DataObjectInterface $record Record to save data into
|
||||
* @param ModelData|DataObjectInterface $record Record to save data into
|
||||
*/
|
||||
public function saveInto(DataObjectInterface $record)
|
||||
{
|
||||
@ -697,7 +697,7 @@ class FormField extends RequestHandler
|
||||
* or a submitted form value they should override setSubmittedValue() instead.
|
||||
*
|
||||
* @param mixed $value Either the parent object, or array of source data being loaded
|
||||
* @param array|ViewableData $data {@see Form::loadDataFrom}
|
||||
* @param array|ModelData $data {@see Form::loadDataFrom}
|
||||
* @return $this
|
||||
*/
|
||||
public function setValue($value, $data = null)
|
||||
@ -712,7 +712,7 @@ class FormField extends RequestHandler
|
||||
* data formats.
|
||||
*
|
||||
* @param mixed $value
|
||||
* @param array|ViewableData $data
|
||||
* @param array|ModelData $data
|
||||
* @return $this
|
||||
*/
|
||||
public function setSubmittedValue($value, $data = null)
|
||||
|
@ -3,13 +3,13 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Form component which contains a castable message
|
||||
*
|
||||
* @mixin ViewableData
|
||||
* @mixin ModelData
|
||||
*/
|
||||
trait FormMessage
|
||||
{
|
||||
|
@ -11,9 +11,9 @@ use SilverStripe\Control\HTTPResponse_Exception;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
|
||||
class FormRequestHandler extends RequestHandler
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class Form_FieldMap extends ViewableData
|
||||
class Form_FieldMap extends ModelData
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -18,16 +18,16 @@ use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\GridField\FormAction\SessionStore;
|
||||
use SilverStripe\Forms\GridField\FormAction\StateStore;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\ORM\Limitable;
|
||||
use SilverStripe\ORM\Sortable;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\Model\List\Limitable;
|
||||
use SilverStripe\Model\List\Sortable;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\View\HTML;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Displays a {@link SS_List} in a grid format.
|
||||
@ -767,7 +767,7 @@ class GridField extends FormField
|
||||
/**
|
||||
* @param int $total
|
||||
* @param int $index
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param array $attributes
|
||||
* @param string $content
|
||||
*
|
||||
@ -785,7 +785,7 @@ class GridField extends FormField
|
||||
/**
|
||||
* @param int $total
|
||||
* @param int $index
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param array $attributes
|
||||
* @param string $content
|
||||
*
|
||||
@ -803,7 +803,7 @@ class GridField extends FormField
|
||||
/**
|
||||
* @param int $total
|
||||
* @param int $index
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -821,7 +821,7 @@ class GridField extends FormField
|
||||
/**
|
||||
* @param int $total
|
||||
* @param int $index
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -892,7 +892,7 @@ class GridField extends FormField
|
||||
/**
|
||||
* Get the value from a column.
|
||||
*
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param string $column
|
||||
*
|
||||
* @return string
|
||||
@ -945,7 +945,7 @@ class GridField extends FormField
|
||||
* Use of this method ensures that any special rules around the data for this gridfield are
|
||||
* followed.
|
||||
*
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param string $fieldName
|
||||
*
|
||||
* @return mixed
|
||||
@ -972,7 +972,7 @@ class GridField extends FormField
|
||||
/**
|
||||
* Get extra columns attributes used as HTML attributes.
|
||||
*
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param string $column
|
||||
*
|
||||
* @return array
|
||||
|
@ -9,11 +9,11 @@ use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use LogicException;
|
||||
use SilverStripe\Control\HTTPResponse_Exception;
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\RelationList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
/**
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Forms\GridField;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
|
||||
/**
|
||||
* Encapsulates a collection of components following the
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Forms\GridField;
|
||||
use SilverStripe\Core\Convert;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* @see GridField
|
||||
@ -155,7 +155,7 @@ class GridFieldDataColumns extends AbstractGridFieldComponent implements GridFie
|
||||
* HTML for the column, content of the <td> element.
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record Record displayed in this row
|
||||
* @param ModelData $record Record displayed in this row
|
||||
* @param string $columnName
|
||||
* @return string HTML for the column. Return NULL to skip.
|
||||
*/
|
||||
@ -189,7 +189,7 @@ class GridFieldDataColumns extends AbstractGridFieldComponent implements GridFie
|
||||
* Attributes for the element containing the content returned by {@link getColumnContent()}.
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record displayed in this row
|
||||
* @param ModelData $record displayed in this row
|
||||
* @param string $columnName
|
||||
* @return array
|
||||
*/
|
||||
@ -225,7 +225,7 @@ class GridFieldDataColumns extends AbstractGridFieldComponent implements GridFie
|
||||
/**
|
||||
* Translate a Object.RelationName.ColumnName $columnName into the value that ColumnName returns
|
||||
*
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param string $columnName
|
||||
* @return string|null - returns null if it could not found a value
|
||||
*/
|
||||
@ -278,7 +278,7 @@ class GridFieldDataColumns extends AbstractGridFieldComponent implements GridFie
|
||||
/**
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $item
|
||||
* @param ModelData $item
|
||||
* @param string $fieldName
|
||||
* @param string $value
|
||||
* @return string
|
||||
|
@ -6,8 +6,8 @@ use LogicException;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* This class is a {@link GridField} component that adds a delete action for
|
||||
@ -75,7 +75,7 @@ class GridFieldDeleteAction extends AbstractGridFieldComponent implements GridFi
|
||||
/**
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param DataObjectInterface&ViewableData $record
|
||||
* @param DataObjectInterface&ModelData $record
|
||||
* @param string $columnName
|
||||
* @return string|null the attribles for the action
|
||||
*/
|
||||
@ -107,7 +107,7 @@ class GridFieldDeleteAction extends AbstractGridFieldComponent implements GridFi
|
||||
* Return any special attributes that will be used for FormField::create_tag()
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param DataObjectInterface&ViewableData $record
|
||||
* @param DataObjectInterface&ModelData $record
|
||||
* @param string $columnName
|
||||
* @return array
|
||||
*/
|
||||
@ -155,7 +155,7 @@ class GridFieldDeleteAction extends AbstractGridFieldComponent implements GridFi
|
||||
/**
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param DataObjectInterface&ViewableData $record
|
||||
* @param DataObjectInterface&ModelData $record
|
||||
* @param string $columnName
|
||||
* @return string|null the HTML for the column
|
||||
*/
|
||||
@ -183,7 +183,7 @@ class GridFieldDeleteAction extends AbstractGridFieldComponent implements GridFi
|
||||
{
|
||||
$list = $gridField->getList();
|
||||
if ($actionName == 'deleterecord' || $actionName == 'unlinkrelation') {
|
||||
/** @var DataObjectInterface&ViewableData $item */
|
||||
/** @var DataObjectInterface&ModelData $item */
|
||||
$item = $list->byID($arguments['RecordID']);
|
||||
if (!$item) {
|
||||
return;
|
||||
@ -221,7 +221,7 @@ class GridFieldDeleteAction extends AbstractGridFieldComponent implements GridFi
|
||||
/**
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param DataObjectInterface&ViewableData $record
|
||||
* @param DataObjectInterface&ModelData $record
|
||||
* @param string $columnName
|
||||
* @return GridField_FormAction|null
|
||||
*/
|
||||
|
@ -18,7 +18,7 @@ use SilverStripe\Forms\FieldsValidator;
|
||||
use SilverStripe\Forms\Validator;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Provides view and edit forms at GridField-specific URLs.
|
||||
@ -156,9 +156,9 @@ class GridFieldDetailForm extends AbstractGridFieldComponent implements GridFiel
|
||||
return $handler->handleRequest($request);
|
||||
}
|
||||
|
||||
protected function getRecordFromRequest(GridField $gridField, HTTPRequest $request): ?ViewableData
|
||||
protected function getRecordFromRequest(GridField $gridField, HTTPRequest $request): ?ModelData
|
||||
{
|
||||
/** @var ViewableData $record */
|
||||
/** @var ModelData $record */
|
||||
if (is_numeric($request->param('ID'))) {
|
||||
$dataList = $gridField->getList();
|
||||
$record = $dataList->byID($request->param('ID'));
|
||||
@ -219,7 +219,7 @@ class GridFieldDetailForm extends AbstractGridFieldComponent implements GridFiel
|
||||
* Build a request handler for the given record
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param RequestHandler $requestHandler
|
||||
* @return GridFieldDetailForm_ItemRequest
|
||||
*/
|
||||
|
@ -17,7 +17,7 @@ use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormAction;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
@ -25,13 +25,13 @@ use SilverStripe\ORM\HasManyList;
|
||||
use SilverStripe\ORM\ManyManyList;
|
||||
use SilverStripe\ORM\PolymorphicHasManyList;
|
||||
use SilverStripe\ORM\RelationList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\HTML;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
{
|
||||
@ -68,7 +68,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
protected $component;
|
||||
|
||||
/**
|
||||
* @var ViewableData
|
||||
* @var ModelData
|
||||
*/
|
||||
protected $record;
|
||||
|
||||
@ -100,7 +100,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param GridFieldDetailForm $component
|
||||
* @param ViewableData&DataObjectInterface $record
|
||||
* @param ModelData&DataObjectInterface $record
|
||||
* @param RequestHandler $requestHandler
|
||||
* @param string $popupFormName
|
||||
*/
|
||||
@ -528,7 +528,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
* Handles detection of falsey values explicitly saved into the
|
||||
* record by formfields
|
||||
*
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param SS_List $list
|
||||
* @return array List of data to write to the relation
|
||||
*/
|
||||
@ -785,7 +785,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
* @param array $data
|
||||
* @param Form $form
|
||||
* @throws ValidationException On error
|
||||
* @return ViewableData&DataObjectInterface Saved record
|
||||
* @return ModelData&DataObjectInterface Saved record
|
||||
*/
|
||||
protected function saveFormIntoRecord($data, $form)
|
||||
{
|
||||
@ -905,7 +905,7 @@ class GridFieldDetailForm_ItemRequest extends RequestHandler
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ViewableData
|
||||
* @return ModelData
|
||||
*/
|
||||
public function getRecord()
|
||||
{
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Provides the entry point to editing a single record presented by the
|
||||
@ -91,7 +91,7 @@ class GridFieldEditButton extends AbstractGridFieldComponent implements GridFiel
|
||||
* Return any special attributes that will be used for FormField::create_tag()
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param string $columnName
|
||||
* @return array
|
||||
*/
|
||||
@ -139,7 +139,7 @@ class GridFieldEditButton extends AbstractGridFieldComponent implements GridFiel
|
||||
|
||||
/**
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
* @param string $columnName
|
||||
* @return string The HTML for the column
|
||||
*/
|
||||
|
@ -8,8 +8,8 @@ use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Adds an "Export list" button to the bottom of a {@link GridField}.
|
||||
@ -228,7 +228,7 @@ class GridFieldExportButton extends AbstractGridFieldComponent implements GridFi
|
||||
? $gridFieldColumnsComponent->getColumnsHandled($gridField)
|
||||
: [];
|
||||
|
||||
/** @var SS_List<ViewableData> $items */
|
||||
/** @var SS_List<ModelData> $items */
|
||||
// Remove limit as the list may be paginated, we want the full list for the export
|
||||
$items = $items->limit(null);
|
||||
|
||||
|
@ -11,10 +11,10 @@ use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\Schema\FormSchema;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\ORM\Search\SearchContext;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\Security;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
class GridFieldImportButton extends AbstractGridFieldComponent implements GridField_HTMLProvider
|
||||
|
@ -4,9 +4,9 @@ namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\TabSet;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
|
||||
/**
|
||||
* GridFieldLazyLoader alters the {@link GridField} behavior to delay rendering of rows until the tab containing the
|
||||
|
@ -6,7 +6,7 @@ use LogicException;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\Hierarchy\Hierarchy;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\HTML;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\ORM\Limitable;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\Limitable;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\UnsavedRelationList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use LogicException;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
@ -6,13 +6,13 @@ use LogicException;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Adds an "Print" button to the bottom or top of a GridField.
|
||||
@ -233,7 +233,7 @@ class GridFieldPrintButton extends AbstractGridFieldComponent implements GridFie
|
||||
|
||||
$gridFieldColumnsComponent = $gridField->getConfig()->getComponentByType(GridFieldDataColumns::class);
|
||||
|
||||
/** @var ViewableData $item */
|
||||
/** @var ModelData $item */
|
||||
foreach ($items->limit(null) as $item) {
|
||||
// Assume item can be viewed if canView() isn't implemented
|
||||
if (!$item->hasMethod('canView') || $item->canView()) {
|
||||
|
@ -4,11 +4,11 @@ namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\ORM\DataObjectSchema;
|
||||
use SilverStripe\ORM\Sortable;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\Sortable;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use LogicException;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* GridField action menu item interface, this provides data so the action
|
||||
@ -21,7 +21,7 @@ interface GridField_ActionMenuItem extends GridFieldComponent
|
||||
* @see {@link GridField_ActionMenu->getColumnContent()}
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
*
|
||||
* @return string $title
|
||||
*/
|
||||
@ -33,7 +33,7 @@ interface GridField_ActionMenuItem extends GridFieldComponent
|
||||
* @see {@link GridField_ActionMenu->getColumnContent()}
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
*
|
||||
* @return array $data
|
||||
*/
|
||||
@ -46,7 +46,7 @@ interface GridField_ActionMenuItem extends GridFieldComponent
|
||||
* @see {@link GridField_ActionMenu->getColumnContent()}
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
*
|
||||
* @return string|null $group
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Allows GridField_ActionMenuItem to act as a link
|
||||
@ -15,7 +15,7 @@ interface GridField_ActionMenuLink extends GridField_ActionMenuItem
|
||||
* @see {@link GridField_ActionMenu->getColumnContent()}
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record
|
||||
* @param ModelData $record
|
||||
*
|
||||
* @return string $url
|
||||
*/
|
||||
|
@ -34,7 +34,7 @@ interface GridField_ColumnProvider extends GridFieldComponent
|
||||
* HTML for the column, content of the <td> element.
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record - Record displayed in this row
|
||||
* @param ModelData $record - Record displayed in this row
|
||||
* @param string $columnName
|
||||
* @return string - HTML for the column. Return NULL to skip.
|
||||
*/
|
||||
@ -44,7 +44,7 @@ interface GridField_ColumnProvider extends GridFieldComponent
|
||||
* Attributes for the element containing the content returned by {@link getColumnContent()}.
|
||||
*
|
||||
* @param GridField $gridField
|
||||
* @param ViewableData $record displayed in this row
|
||||
* @param ModelData $record displayed in this row
|
||||
* @param string $columnName
|
||||
* @return array
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
|
||||
/**
|
||||
* Can modify the data list.
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\GridField;
|
||||
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* A component which is used to handle when a {@link GridField} is saved into
|
||||
@ -16,7 +16,7 @@ interface GridField_SaveHandler extends GridFieldComponent
|
||||
* Called when a grid field is saved - i.e. the form is submitted.
|
||||
*
|
||||
* @param GridField $grid
|
||||
* @param DataObjectInterface&ViewableData $record
|
||||
* @param DataObjectInterface&ModelData $record
|
||||
*/
|
||||
public function handleSave(GridField $grid, DataObjectInterface $record);
|
||||
}
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Grouped dropdown, using optgroup tags.
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Multi-line listbox field, created from a select tag.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* This field lets you put an arbitrary piece of HTML into your forms.
|
||||
@ -51,7 +51,7 @@ class LiteralField extends DatalessField
|
||||
*/
|
||||
public function FieldHolder($properties = [])
|
||||
{
|
||||
if ($this->content instanceof ViewableData) {
|
||||
if ($this->content instanceof ModelData) {
|
||||
$context = $this->content;
|
||||
|
||||
if ($properties) {
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\ORM\FieldType\DBMoney;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
|
||||
|
@ -3,8 +3,8 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Set of radio buttons designed to emulate a dropdown.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
|
||||
/**
|
||||
* Required Fields allows you to set which fields need to be present before
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Forms\CompositeField;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
|
@ -8,14 +8,14 @@ use LogicException;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\Relation;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\ORM\Search\SearchContext;
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\ORM\RelationList;
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
|
||||
/**
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use ArrayAccess;
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\View\HTML;
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Forms;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
|
||||
/**
|
||||
|
@ -5,15 +5,15 @@ namespace SilverStripe\Forms;
|
||||
use http\Exception\InvalidArgumentException;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\ORM\Relation;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* This formfield represents many-many joins using a tree selector shown in a dropdown styled element
|
||||
@ -211,7 +211,7 @@ class TreeMultiselectField extends TreeDropdownField
|
||||
if ($items && count($items ?? [])) {
|
||||
foreach ($items as $item) {
|
||||
$idArray[] = $item->ID;
|
||||
$titleArray[] = ($item instanceof ViewableData)
|
||||
$titleArray[] = ($item instanceof ModelData)
|
||||
? $item->obj($this->getLabelField())->forTemplate()
|
||||
: Convert::raw2xml($item->{$this->getLabelField()});
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Forms;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
/**
|
||||
* This validation class handles all form and custom form validation through the use of Required
|
||||
|
@ -1,14 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View;
|
||||
namespace SilverStripe\Model;
|
||||
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
* Lets you wrap a bunch of array data, or object members, into a {@link ViewableData} object.
|
||||
* Lets you wrap a bunch of array data, or object members, into a {@link ModelData} object.
|
||||
*
|
||||
* <code>
|
||||
* new ArrayData(array(
|
||||
@ -16,10 +15,8 @@ use stdClass;
|
||||
* "AddAction" => "Add a new Page page",
|
||||
* ));
|
||||
* </code>
|
||||
*
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ArrayData
|
||||
*/
|
||||
class ArrayData extends ViewableData
|
||||
class ArrayData extends ModelData
|
||||
{
|
||||
|
||||
/**
|
||||
@ -34,10 +31,6 @@ class ArrayData extends ViewableData
|
||||
*/
|
||||
public function __construct($value = [])
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ArrayData', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
|
||||
if (is_object($value)) {
|
||||
$this->array = get_object_vars($value);
|
||||
} elseif (is_array($value)) {
|
||||
@ -72,7 +65,7 @@ class ArrayData extends ViewableData
|
||||
*
|
||||
*
|
||||
* If the value is an object but not an instance of
|
||||
* ViewableData, it will be converted recursively to an
|
||||
* ModelData, it will be converted recursively to an
|
||||
* ArrayData.
|
||||
*
|
||||
* If the value is an associative array, it will likewise be
|
||||
@ -81,7 +74,7 @@ class ArrayData extends ViewableData
|
||||
public function getField(string $fieldName): mixed
|
||||
{
|
||||
$value = $this->array[$fieldName];
|
||||
if (is_object($value) && !($value instanceof ViewableData) && !is_iterable($value)) {
|
||||
if (is_object($value) && !($value instanceof ModelData) && !is_iterable($value)) {
|
||||
return new ArrayData($value);
|
||||
} elseif (ArrayLib::is_associative($value)) {
|
||||
return new ArrayData($value);
|
@ -1,19 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
use ArrayIterator;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\ORM\Filters\ExactMatchFilter;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use SilverStripe\ORM\Filters\SearchFilterable;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
@ -35,9 +31,8 @@ use Traversable;
|
||||
* @implements Filterable<T>
|
||||
* @implements Sortable<T>
|
||||
* @implements Limitable<T>
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\ArrayList
|
||||
*/
|
||||
class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, Limitable
|
||||
class ArrayList extends ModelData implements SS_List, Filterable, Sortable, Limitable
|
||||
{
|
||||
use SearchFilterable;
|
||||
|
||||
@ -61,10 +56,6 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
|
||||
*/
|
||||
public function __construct(array $items = [])
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ArrayList', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
|
||||
$this->items = array_values($items ?? []);
|
||||
parent::__construct();
|
||||
}
|
||||
@ -584,7 +575,7 @@ class ArrayList extends ViewableData implements SS_List, Filterable, Sortable, L
|
||||
return array_key_exists($by, $firstRecord);
|
||||
}
|
||||
|
||||
if ($firstRecord instanceof ViewableData) {
|
||||
if ($firstRecord instanceof ModelData) {
|
||||
return $firstRecord->hasField($by);
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
/**
|
||||
* Additional interface for {@link SS_List} classes that are filterable.
|
||||
@ -14,7 +14,6 @@ namespace SilverStripe\ORM;
|
||||
*
|
||||
* @template T
|
||||
* @extends SS_List<T>
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Filterable
|
||||
*/
|
||||
interface Filterable extends SS_List
|
||||
{
|
@ -1,9 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* A list decorator that allows a list to be grouped into sub-lists by common
|
||||
@ -12,19 +11,9 @@ use SilverStripe\View\ArrayData;
|
||||
* @template TList
|
||||
* @template T
|
||||
* @extends ListDecorator<TList, T>
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\GroupedList
|
||||
*/
|
||||
class GroupedList extends ListDecorator
|
||||
{
|
||||
|
||||
public function __construct(SS_List&Sortable&Filterable&Limitable $list)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\GroupedList', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
parent::__construct($list);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $index
|
||||
* @return array
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
/**
|
||||
* Additional interface for {@link SS_List} classes that are limitable - able to have a subset of the list extracted.
|
||||
@ -14,7 +14,6 @@ namespace SilverStripe\ORM;
|
||||
*
|
||||
* @template T
|
||||
* @implements SS_List<T>
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Limitable
|
||||
*/
|
||||
interface Limitable extends SS_List
|
||||
{
|
@ -1,10 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use LogicException;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
@ -18,9 +17,8 @@ use Traversable;
|
||||
* @implements Sortable<T>
|
||||
* @implements Filterable<T>
|
||||
* @implements Limitable<T>
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\ListDecorator
|
||||
*/
|
||||
abstract class ListDecorator extends ViewableData implements SS_List, Sortable, Filterable, Limitable
|
||||
abstract class ListDecorator extends ModelData implements SS_List, Sortable, Filterable, Limitable
|
||||
{
|
||||
/**
|
||||
* @var TList<T>
|
||||
@ -32,12 +30,7 @@ abstract class ListDecorator extends ViewableData implements SS_List, Sortable,
|
||||
*/
|
||||
public function __construct(SS_List&Sortable&Filterable&Limitable $list)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\ListDecorator', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
|
||||
$this->setList($list);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
@ -1,18 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
use ArrayAccess;
|
||||
use BadMethodCallException;
|
||||
use Countable;
|
||||
use IteratorAggregate;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
* Creates a map from an SS_List by defining a key column and a value column.
|
||||
*
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Map
|
||||
*/
|
||||
class Map implements ArrayAccess, Countable, IteratorAggregate
|
||||
{
|
||||
@ -42,10 +39,6 @@ class Map implements ArrayAccess, Countable, IteratorAggregate
|
||||
*/
|
||||
public function __construct(SS_List $list, $keyField = "ID", $valueField = "Title")
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\Map', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
|
||||
$this->list = $list;
|
||||
$this->keyField = $keyField;
|
||||
$this->valueField = $valueField;
|
@ -1,15 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
use SilverStripe\Control\HTTP;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use ArrayAccess;
|
||||
use Exception;
|
||||
use IteratorIterator;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
@ -18,7 +17,6 @@ use Traversable;
|
||||
* @template TList of SS_List
|
||||
* @template T
|
||||
* @extends ListDecorator<TList, T>
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\PaginatedList
|
||||
*/
|
||||
class PaginatedList extends ListDecorator
|
||||
{
|
||||
@ -41,10 +39,6 @@ class PaginatedList extends ListDecorator
|
||||
*/
|
||||
public function __construct(SS_List $list, $request = [])
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\List\PaginatedList', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
|
||||
if (!is_array($request) && !$request instanceof ArrayAccess) {
|
||||
throw new Exception('The request must be readable as an array.');
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
use ArrayAccess;
|
||||
use Countable;
|
||||
@ -12,8 +12,6 @@ use IteratorAggregate;
|
||||
* @template T
|
||||
* @extends ArrayAccess<array-key, T>
|
||||
* @extends IteratorAggregate<array-key, T>
|
||||
*
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\SS_List
|
||||
*/
|
||||
interface SS_List extends ArrayAccess, Countable, IteratorAggregate
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
namespace SilverStripe\Model\List;
|
||||
|
||||
/**
|
||||
* Additional interface for {@link SS_List} classes that are sortable.
|
||||
@ -14,7 +14,6 @@ namespace SilverStripe\ORM;
|
||||
*
|
||||
* @template T
|
||||
* @implements SS_List<T>
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\List\Sortable
|
||||
*/
|
||||
interface Sortable extends SS_List
|
||||
{
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View;
|
||||
namespace SilverStripe\Model;
|
||||
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
@ -14,24 +14,22 @@ use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use UnexpectedValueException;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* A ViewableData object is any object that can be rendered into a template/view.
|
||||
* A ModelData object is any object that can be rendered into a template/view.
|
||||
*
|
||||
* A view interrogates the object being currently rendered in order to get data to render into the template. This data
|
||||
* is provided and automatically escaped by ViewableData. Any class that needs to be available to a view (controllers,
|
||||
* is provided and automatically escaped by ModelData. Any class that needs to be available to a view (controllers,
|
||||
* {@link DataObject}s, page controls) should inherit from this class.
|
||||
*
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelData
|
||||
*/
|
||||
class ViewableData
|
||||
class ModelData
|
||||
{
|
||||
use Extensible {
|
||||
defineMethods as extensibleDefineMethods;
|
||||
@ -70,17 +68,15 @@ class ViewableData
|
||||
/**
|
||||
* A failover object to attempt to get data from if it is not present on this object.
|
||||
*/
|
||||
protected ?ViewableData $failover = null;
|
||||
protected ?ModelData $failover = null;
|
||||
|
||||
protected ?ViewableData $customisedObject = null;
|
||||
protected ?ModelData $customisedObject = null;
|
||||
|
||||
private array $objCache = [];
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelData', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
// no-op
|
||||
}
|
||||
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
@ -110,7 +106,7 @@ class ViewableData
|
||||
|
||||
/**
|
||||
* Get the value of a property/field on this object. This will check if a method called get{$property} exists, then
|
||||
* check if a field is available using {@link ViewableData::getField()}, then fall back on a failover object.
|
||||
* check if a field is available using {@link ModelData::getField()}, then fall back on a failover object.
|
||||
*/
|
||||
public function __get(string $property): mixed
|
||||
{
|
||||
@ -131,7 +127,7 @@ class ViewableData
|
||||
|
||||
/**
|
||||
* Set a property/field on this object. This will check for the existence of a method called set{$property}, then
|
||||
* use the {@link ViewableData::setField()} method.
|
||||
* use the {@link ModelData::setField()} method.
|
||||
*/
|
||||
public function __set(string $property, mixed $value): void
|
||||
{
|
||||
@ -148,7 +144,7 @@ class ViewableData
|
||||
/**
|
||||
* Set a failover object to attempt to get data from if it is not present on this object.
|
||||
*/
|
||||
public function setFailover(ViewableData $failover): void
|
||||
public function setFailover(ModelData $failover): void
|
||||
{
|
||||
// Ensure cached methods from previous failover are removed
|
||||
if ($this->failover) {
|
||||
@ -162,7 +158,7 @@ class ViewableData
|
||||
/**
|
||||
* Get the current failover object if set
|
||||
*/
|
||||
public function getFailover(): ?ViewableData
|
||||
public function getFailover(): ?ModelData
|
||||
{
|
||||
return $this->failover;
|
||||
}
|
||||
@ -192,7 +188,7 @@ class ViewableData
|
||||
public function setField(string $fieldName, mixed $value): static
|
||||
{
|
||||
$this->objCacheClear();
|
||||
// prior to PHP 8.2 support ViewableData::setField() simply used `$this->field = $value;`
|
||||
// prior to PHP 8.2 support ModelData::setField() simply used `$this->field = $value;`
|
||||
// so the following logic essentially mimics this behaviour, though without the use
|
||||
// of now deprecated dynamic properties
|
||||
if ($this->isAccessibleProperty($fieldName)) {
|
||||
@ -219,7 +215,7 @@ class ViewableData
|
||||
|
||||
/**
|
||||
* Returns true if a method exists for the current class which isn't private.
|
||||
* Also returns true for private methods if $this is ViewableData (not a subclass)
|
||||
* Also returns true for private methods if $this is ModelData (not a subclass)
|
||||
*/
|
||||
private function isAccessibleMethod(string $method): bool
|
||||
{
|
||||
@ -227,25 +223,25 @@ class ViewableData
|
||||
// Methods added via extensions are accessible
|
||||
return $this->hasCustomMethod($method);
|
||||
}
|
||||
// All methods defined on ViewableData are accessible to ViewableData
|
||||
if (static::class === ViewableData::class) {
|
||||
// All methods defined on ModelData are accessible to ModelData
|
||||
if (static::class === ModelData::class) {
|
||||
return true;
|
||||
}
|
||||
// Private methods defined on subclasses are not accessible to ViewableData
|
||||
// Private methods defined on subclasses are not accessible to ModelData
|
||||
$reflectionMethod = new ReflectionMethod($this, $method);
|
||||
return !$reflectionMethod->isPrivate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if a property exists for the current class which isn't private.
|
||||
* Also returns true for private properties if $this is ViewableData (not a subclass)
|
||||
* Also returns true for private properties if $this is ModelData (not a subclass)
|
||||
*/
|
||||
private function isAccessibleProperty(string $property): bool
|
||||
{
|
||||
if (!property_exists($this, $property)) {
|
||||
return false;
|
||||
}
|
||||
if (static::class === ViewableData::class) {
|
||||
if (static::class === ModelData::class) {
|
||||
return true;
|
||||
}
|
||||
$reflectionProperty = new ReflectionProperty($this, $property);
|
||||
@ -255,15 +251,15 @@ class ViewableData
|
||||
// -----------------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Add methods from the {@link ViewableData::$failover} object, as well as wrapping any methods prefixed with an
|
||||
* underscore into a {@link ViewableData::cachedCall()}.
|
||||
* Add methods from the {@link ModelData::$failover} object, as well as wrapping any methods prefixed with an
|
||||
* underscore into a {@link ModelData::cachedCall()}.
|
||||
*
|
||||
* @throws LogicException
|
||||
*/
|
||||
public function defineMethods()
|
||||
{
|
||||
if ($this->failover && !is_object($this->failover)) {
|
||||
throw new LogicException("ViewableData::\$failover set to a non-object");
|
||||
throw new LogicException("ModelData::\$failover set to a non-object");
|
||||
}
|
||||
if ($this->failover) {
|
||||
$this->addMethodsFrom('failover');
|
||||
@ -278,23 +274,23 @@ class ViewableData
|
||||
}
|
||||
|
||||
/**
|
||||
* Merge some arbitrary data in with this object. This method returns a {@link ViewableData_Customised} instance
|
||||
* Merge some arbitrary data in with this object. This method returns a {@link ModelDataCustomised} instance
|
||||
* with references to both this and the new custom data.
|
||||
*
|
||||
* Note that any fields you specify will take precedence over the fields on this object.
|
||||
*/
|
||||
public function customise(array|ViewableData $data): ViewableData
|
||||
public function customise(array|ModelData $data): ModelData
|
||||
{
|
||||
if (is_array($data) && (empty($data) || ArrayLib::is_associative($data))) {
|
||||
$data = new ArrayData($data);
|
||||
}
|
||||
|
||||
if ($data instanceof ViewableData) {
|
||||
return new ViewableData_Customised($this, $data);
|
||||
if ($data instanceof ModelData) {
|
||||
return new ModelDataCustomised($this, $data);
|
||||
}
|
||||
|
||||
throw new InvalidArgumentException(
|
||||
'ViewableData->customise(): $data must be an associative array or a ViewableData instance'
|
||||
'ModelData->customise(): $data must be an associative array or a ModelData instance'
|
||||
);
|
||||
}
|
||||
|
||||
@ -317,12 +313,12 @@ class ViewableData
|
||||
return static::class;
|
||||
}
|
||||
|
||||
public function getCustomisedObj(): ?ViewableData
|
||||
public function getCustomisedObj(): ?ModelData
|
||||
{
|
||||
return $this->customisedObject;
|
||||
}
|
||||
|
||||
public function setCustomisedObj(ViewableData $object)
|
||||
public function setCustomisedObj(ModelData $object)
|
||||
{
|
||||
$this->customisedObject = $object;
|
||||
}
|
||||
@ -421,9 +417,9 @@ class ViewableData
|
||||
* - an SSViewer instance
|
||||
*
|
||||
* @param string|array|SSViewer $template the template to render into
|
||||
* @param ViewableData|array|null $customFields fields to customise() the object with before rendering
|
||||
* @param ModelData|array|null $customFields fields to customise() the object with before rendering
|
||||
*/
|
||||
public function renderWith($template, ViewableData|array|null $customFields = null): DBHTMLText
|
||||
public function renderWith($template, ModelData|array|null $customFields = null): DBHTMLText
|
||||
{
|
||||
if (!is_object($template)) {
|
||||
$template = SSViewer::create($template);
|
||||
@ -431,7 +427,7 @@ class ViewableData
|
||||
|
||||
$data = $this->getCustomisedObj() ?: $this;
|
||||
|
||||
if ($customFields instanceof ViewableData) {
|
||||
if ($customFields instanceof ModelData) {
|
||||
$data = $data->customise($customFields);
|
||||
}
|
||||
if ($template instanceof SSViewer) {
|
||||
@ -439,7 +435,7 @@ class ViewableData
|
||||
}
|
||||
|
||||
throw new UnexpectedValueException(
|
||||
"ViewableData::renderWith(): unexpected " . get_class($template) . " object, expected an SSViewer instance"
|
||||
"ModelData::renderWith(): unexpected " . get_class($template) . " object, expected an SSViewer instance"
|
||||
);
|
||||
}
|
||||
|
||||
@ -546,7 +542,7 @@ class ViewableData
|
||||
}
|
||||
}
|
||||
|
||||
// Wrap list arrays in ViewableData so templates can handle them
|
||||
// Wrap list arrays in ModelData so templates can handle them
|
||||
if (is_array($value) && array_is_list($value)) {
|
||||
$value = ArrayList::create($value);
|
||||
}
|
||||
@ -569,7 +565,7 @@ class ViewableData
|
||||
}
|
||||
|
||||
/**
|
||||
* A simple wrapper around {@link ViewableData::obj()} that automatically caches the result so it can be used again
|
||||
* A simple wrapper around {@link ModelData::obj()} that automatically caches the result so it can be used again
|
||||
* without re-running the method.
|
||||
*
|
||||
* @return Object|DBField
|
||||
@ -586,7 +582,7 @@ class ViewableData
|
||||
public function hasValue(string $field, array $arguments = [], bool $cache = true): bool
|
||||
{
|
||||
$result = $this->obj($field, $arguments, $cache);
|
||||
if ($result instanceof ViewableData) {
|
||||
if ($result instanceof ModelData) {
|
||||
return $result->exists();
|
||||
}
|
||||
return (bool) $result;
|
||||
@ -629,7 +625,7 @@ class ViewableData
|
||||
*/
|
||||
public function getViewerTemplates(string $suffix = ''): array
|
||||
{
|
||||
return SSViewer::get_templates_by_class(static::class, $suffix, ViewableData::class);
|
||||
return SSViewer::get_templates_by_class(static::class, $suffix, ModelData::class);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -645,12 +641,12 @@ class ViewableData
|
||||
* Get part of the current classes ancestry to be used as a CSS class.
|
||||
*
|
||||
* This method returns an escaped string of CSS classes representing the current classes ancestry until it hits a
|
||||
* stop point - e.g. "Page DataObject ViewableData".
|
||||
* stop point - e.g. "Page DataObject ModelData".
|
||||
*
|
||||
* @param string $stopAtClass the class to stop at (default: ViewableData)
|
||||
* @param string $stopAtClass the class to stop at (default: ModelData)
|
||||
* @uses ClassInfo
|
||||
*/
|
||||
public function CSSClasses(string $stopAtClass = ViewableData::class): string
|
||||
public function CSSClasses(string $stopAtClass = ModelData::class): string
|
||||
{
|
||||
$classes = [];
|
||||
$classAncestry = array_reverse(ClassInfo::ancestry(static::class) ?? []);
|
||||
@ -677,8 +673,8 @@ class ViewableData
|
||||
/**
|
||||
* Return debug information about this object that can be rendered into a template
|
||||
*/
|
||||
public function Debug(): ViewableData|string
|
||||
public function Debug(): ModelData|string
|
||||
{
|
||||
return ViewableData_Debugger::create($this);
|
||||
return ModelDataDebugger::create($this);
|
||||
}
|
||||
}
|
@ -1,27 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View;
|
||||
namespace SilverStripe\Model;
|
||||
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelDataCustomised
|
||||
*/
|
||||
class ViewableData_Customised extends ViewableData
|
||||
class ModelDataCustomised extends ModelData
|
||||
{
|
||||
protected ViewableData $original;
|
||||
protected ModelData $original;
|
||||
|
||||
protected ViewableData $customised;
|
||||
protected ModelData $customised;
|
||||
|
||||
/**
|
||||
* Instantiate a new customised ViewableData object
|
||||
* Instantiate a new customised ModelData object
|
||||
*/
|
||||
public function __construct(ViewableData $originalObject, ViewableData $customisedObject)
|
||||
public function __construct(ModelData $originalObject, ModelData $customisedObject)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataCustomised', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
|
||||
$this->original = $originalObject;
|
||||
$this->customised = $customisedObject;
|
||||
|
@ -1,23 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View;
|
||||
namespace SilverStripe\Model;
|
||||
|
||||
use ReflectionObject;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
|
||||
/**
|
||||
* Allows you to render debug information about a {@link ViewableData} object into a template.
|
||||
* @deprecated 5.4.0 Will be renamed to SilverStripe\Model\ModelDataDebugger
|
||||
* Allows you to render debug information about a {@link ModelData} object into a template.
|
||||
*/
|
||||
class ViewableData_Debugger extends ViewableData
|
||||
class ModelDataDebugger extends ModelData
|
||||
{
|
||||
protected ViewableData $object;
|
||||
protected ModelData $object;
|
||||
|
||||
public function __construct(ViewableData $object)
|
||||
public function __construct(ModelData $object)
|
||||
{
|
||||
Deprecation::withNoReplacement(function () {
|
||||
Deprecation::notice('5.4.0', 'Will be renamed to SilverStripe\Model\ModelDataDebugger', Deprecation::SCOPE_CLASS);
|
||||
});
|
||||
$this->object = $object;
|
||||
parent::__construct();
|
||||
}
|
||||
@ -77,7 +72,7 @@ class ViewableData_Debugger extends ViewableData
|
||||
|
||||
// check for an extra attached data
|
||||
if ($this->object->hasMethod('data') && $this->object->data() != $this->object) {
|
||||
$debug .= ViewableData_Debugger::create($this->object->data())->forTemplate();
|
||||
$debug .= ModelDataDebugger::create($this->object->data())->forTemplate();
|
||||
}
|
||||
|
||||
return $debug;
|
@ -12,8 +12,8 @@ use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\ListDecorator;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\Model\List\ListDecorator;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use SilverStripe\ORM\Queries\SQLExpression;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\ORM\Queries\SQLDelete;
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\PaginatedList;
|
||||
use SilverStripe\Model\List\PaginatedList;
|
||||
use SilverStripe\ORM\Queries\SQLUpdate;
|
||||
use SilverStripe\ORM\Queries\SQLInsert;
|
||||
use BadMethodCallException;
|
||||
|
@ -6,9 +6,9 @@ use SilverStripe\Assets\File;
|
||||
use SilverStripe\CMS\Model\SiteTree;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\ORM\PaginatedList;
|
||||
use SilverStripe\Model\List\PaginatedList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use Exception;
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\ORM;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\ORM\Queries\SQLConditionGroup;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
@ -13,7 +13,12 @@ use BadMethodCallException;
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
use Traversable;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\Model\List\Limitable;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use SilverStripe\Model\List\Sortable;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\Filters\SearchFilterable;
|
||||
|
||||
/**
|
||||
@ -42,7 +47,7 @@ use SilverStripe\ORM\Filters\SearchFilterable;
|
||||
* @implements Sortable<T>
|
||||
* @implements Limitable<T>
|
||||
*/
|
||||
class DataList extends ViewableData implements SS_List, Filterable, Sortable, Limitable
|
||||
class DataList extends ModelData implements SS_List, Filterable, Sortable, Limitable
|
||||
{
|
||||
use SearchFilterable;
|
||||
|
||||
@ -924,7 +929,7 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
|
||||
|
||||
private function setDataObjectEagerLoadedData(DataObject $item): void
|
||||
{
|
||||
// cache $item->ID at the top of this method to reduce calls to ViewableData::__get()
|
||||
// cache $item->ID at the top of this method to reduce calls to ModelData::__get()
|
||||
$itemID = $item->ID;
|
||||
foreach (array_keys($this->eagerLoadedData) as $relation) {
|
||||
if (array_key_exists($itemID, $this->eagerLoadedData[$relation])) {
|
||||
|
@ -11,6 +11,8 @@ use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Resettable;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
@ -24,6 +26,8 @@ use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\SearchableDropdownField;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\i18n\i18nEntityProvider;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\Connect\MySQLSchemaManager;
|
||||
use SilverStripe\ORM\FieldType\DBComposite;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
@ -40,7 +44,7 @@ use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use stdClass;
|
||||
|
||||
/**
|
||||
@ -111,7 +115,7 @@ use stdClass;
|
||||
* @property string $Created Date and time of DataObject creation.
|
||||
* @property string $ObsoleteClassName If ClassName no longer exists this will be set to the legacy value
|
||||
*/
|
||||
class DataObject extends ViewableData implements DataObjectInterface, i18nEntityProvider, Resettable
|
||||
class DataObject extends ModelData implements DataObjectInterface, i18nEntityProvider, Resettable
|
||||
{
|
||||
/**
|
||||
* Human-readable singular name.
|
||||
@ -3280,7 +3284,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
* can throw a LogicException.
|
||||
*
|
||||
* @param string $fieldPath List of paths on this object. All items in this path
|
||||
* must be ViewableData implementors
|
||||
* must be ModelData implementors
|
||||
*
|
||||
* @return mixed DBField of the field on the object or a DataList instance.
|
||||
* @throws LogicException If accessing invalid relations
|
||||
@ -3305,7 +3309,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$component = $singleton->dbObject($relation) ?: $component->relation($relation);
|
||||
} elseif ($component instanceof DataObject && ($dbObject = $component->dbObject($relation))) {
|
||||
$component = $dbObject;
|
||||
} elseif ($component instanceof ViewableData && $component->hasField($relation)) {
|
||||
} elseif ($component instanceof ModelData && $component->hasField($relation)) {
|
||||
$component = $component->obj($relation);
|
||||
} else {
|
||||
throw new LogicException(
|
||||
@ -3944,7 +3948,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
|
||||
$ancestry = array_reverse($ancestry ?? []);
|
||||
if ($ancestry) {
|
||||
foreach ($ancestry as $ancestorClass) {
|
||||
if ($ancestorClass === ViewableData::class) {
|
||||
if ($ancestorClass === ModelData::class) {
|
||||
break;
|
||||
}
|
||||
$types = [
|
||||
|
@ -5,6 +5,7 @@ namespace SilverStripe\ORM;
|
||||
use Exception;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
|
@ -3,12 +3,19 @@
|
||||
namespace SilverStripe\ORM;
|
||||
|
||||
use SilverStripe\Dev\Debug;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use SilverStripe\ORM\Connect\DatabaseException;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use BadMethodCallException;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\Model\List\Limitable;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use SilverStripe\Model\List\Sortable;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\Filters\SearchFilterable;
|
||||
use Traversable;
|
||||
|
||||
@ -29,7 +36,7 @@ use Traversable;
|
||||
* @implements Sortable<T>
|
||||
* @implements Limitable<T>
|
||||
*/
|
||||
class EagerLoadedList extends ViewableData implements Relation, SS_List, Filterable, Sortable, Limitable
|
||||
class EagerLoadedList extends ModelData implements Relation, SS_List, Filterable, Sortable, Limitable
|
||||
{
|
||||
use SearchFilterable;
|
||||
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Forms\CheckboxField;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a boolean field.
|
||||
@ -44,7 +44,7 @@ class DBBoolean extends DBField
|
||||
return ($this->value) ? 'true' : 'false';
|
||||
}
|
||||
|
||||
public function saveInto(ViewableData $dataObject): void
|
||||
public function saveInto(ModelData $dataObject): void
|
||||
{
|
||||
$fieldName = $this->name;
|
||||
if ($fieldName) {
|
||||
|
@ -6,7 +6,7 @@ use RuntimeException;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
trait DBClassNameTrait
|
||||
{
|
||||
@ -98,7 +98,7 @@ trait DBClassNameTrait
|
||||
return array_values($classNames ?? []);
|
||||
}
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
parent::setValue($value, $record, $markChanged);
|
||||
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Extend this class when designing a {@link DBField} that doesn't have a 1-1 mapping with a database field.
|
||||
@ -42,7 +42,7 @@ abstract class DBComposite extends DBField
|
||||
/**
|
||||
* Either the parent dataobject link, or a record of saved values for each field
|
||||
*/
|
||||
protected array|ViewableData $record = [];
|
||||
protected array|ModelData $record = [];
|
||||
|
||||
public function __set(string $property, mixed $value): void
|
||||
{
|
||||
@ -157,11 +157,11 @@ abstract class DBComposite extends DBField
|
||||
* If $record is assigned to a dataobject, this field becomes a loose wrapper over
|
||||
* the records on that object instead.
|
||||
*
|
||||
* {@see ViewableData::obj}
|
||||
* {@see ModelData::obj}
|
||||
*
|
||||
* @param null|array|ViewableData $record Parent object to this field, which could be a DataObject, record array, or other
|
||||
* @param null|array|ModelData $record Parent object to this field, which could be a DataObject, record array, or other
|
||||
*/
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
$this->isChanged = $markChanged;
|
||||
|
||||
@ -198,7 +198,7 @@ abstract class DBComposite extends DBField
|
||||
$this->record = $dataObject;
|
||||
}
|
||||
|
||||
public function saveInto(ViewableData $dataObject): void
|
||||
public function saveInto(ModelData $dataObject): void
|
||||
{
|
||||
foreach ($this->compositeDatabaseFields() as $field => $spec) {
|
||||
// Save into record
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\FieldType;
|
||||
|
||||
use SilverStripe\Forms\CurrencyField;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a decimal field containing a currency amount.
|
||||
@ -51,7 +51,7 @@ class DBCurrency extends DBDecimal
|
||||
return $val;
|
||||
}
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
$matches = null;
|
||||
if (is_numeric($value)) {
|
||||
|
@ -11,7 +11,7 @@ use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a date field.
|
||||
@ -42,7 +42,7 @@ class DBDate extends DBField
|
||||
*/
|
||||
public const ISO_LOCALE = 'en_US';
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
$value = $this->parseDate($value);
|
||||
if ($value === false) {
|
||||
|
@ -12,7 +12,7 @@ use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\TemplateGlobalProvider;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a date-time field.
|
||||
@ -69,7 +69,7 @@ class DBDatetime extends DBDate implements TemplateGlobalProvider
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
if ($this->immutable) {
|
||||
// This field is set as immutable so we have to create a new field instance
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\ORM\FieldType;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a Decimal field.
|
||||
@ -67,7 +67,7 @@ class DBDecimal extends DBField
|
||||
DB::require_field($this->tableName, $this->name, $values);
|
||||
}
|
||||
|
||||
public function saveInto(ViewableData $model): void
|
||||
public function saveInto(ModelData $model): void
|
||||
{
|
||||
$fieldName = $this->name;
|
||||
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\SelectField;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\ORM\Connect\MySQLDatabase;
|
||||
use SilverStripe\ORM\DB;
|
||||
|
||||
|
@ -9,7 +9,7 @@ use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Single field in the database.
|
||||
@ -41,7 +41,7 @@ use SilverStripe\View\ViewableData;
|
||||
* }
|
||||
* </code>
|
||||
*/
|
||||
abstract class DBField extends ViewableData implements DBIndexable
|
||||
abstract class DBField extends ModelData implements DBIndexable
|
||||
{
|
||||
|
||||
/**
|
||||
@ -198,12 +198,12 @@ abstract class DBField extends ViewableData implements DBIndexable
|
||||
* and actually changing its values, it needs a {@link $markChanged}
|
||||
* parameter.
|
||||
*
|
||||
* @param null|ViewableData|array $record An array or object that this field is part of
|
||||
* @param null|ModelData|array $record An array or object that this field is part of
|
||||
* @param bool $markChanged Indicate whether this field should be marked changed.
|
||||
* Set to FALSE if you are initializing this field after construction, rather
|
||||
* than setting a new value.
|
||||
*/
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
$this->value = $value;
|
||||
return $this;
|
||||
@ -453,7 +453,7 @@ abstract class DBField extends ViewableData implements DBIndexable
|
||||
/**
|
||||
* Saves this field to the given data object.
|
||||
*/
|
||||
public function saveInto(ViewableData $model): void
|
||||
public function saveInto(ModelData $model): void
|
||||
{
|
||||
$fieldName = $this->name;
|
||||
if (empty($fieldName)) {
|
||||
|
@ -10,7 +10,7 @@ use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\SearchableDropdownField;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* A special type Int field used for foreign keys in has_one relationships.
|
||||
@ -58,7 +58,7 @@ class DBForeignKey extends DBInt
|
||||
return $field;
|
||||
}
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
if ($record instanceof DataObject) {
|
||||
$this->object = $record;
|
||||
|
@ -4,10 +4,10 @@ namespace SilverStripe\ORM\FieldType;
|
||||
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Represents a signed 32 bit integer field.
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM\FieldType;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a decimal field from 0-1 containing a percentage value.
|
||||
@ -37,7 +37,7 @@ class DBPercentage extends DBDecimal
|
||||
return number_format($this->value * 100, $this->decimalSize - 2) . '%';
|
||||
}
|
||||
|
||||
public function saveInto(ViewableData $model): void
|
||||
public function saveInto(ModelData $model): void
|
||||
{
|
||||
parent::saveInto($model);
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\FieldType;
|
||||
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* A special ForeignKey class that handles relations with arbitrary class types
|
||||
@ -61,7 +61,7 @@ class DBPolymorphicForeignKey extends DBComposite
|
||||
$this->setField('ID', $value, $markChanged);
|
||||
}
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
// Map dataobject value to array
|
||||
if ($value instanceof DataObject) {
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\ORM\FieldType;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* A special type Int field used for primary keys.
|
||||
@ -54,7 +54,7 @@ class DBPrimaryKey extends DBInt
|
||||
return parent::scaffoldFormField($title);
|
||||
}
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
parent::setValue($value, $record, $markChanged);
|
||||
|
||||
|
@ -10,7 +10,7 @@ use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Represents a column in the database with the type 'Time'.
|
||||
@ -29,7 +29,7 @@ class DBTime extends DBField
|
||||
*/
|
||||
public const ISO_TIME = 'HH:mm:ss';
|
||||
|
||||
public function setValue(mixed $value, null|array|ViewableData $record = null, bool $markChanged = true): static
|
||||
public function setValue(mixed $value, null|array|ModelData $record = null, bool $markChanged = true): static
|
||||
{
|
||||
$value = $this->parseTime($value);
|
||||
if ($value === false) {
|
||||
|
@ -6,9 +6,9 @@ use SilverStripe\Admin\LeftAndMain;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\DB;
|
||||
@ -16,7 +16,7 @@ use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Convert;
|
||||
use Exception;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* DataObjects that use the Hierarchy extension can be be organised as a hierarchy, with children and parents. The most
|
||||
@ -416,7 +416,7 @@ class Hierarchy extends Extension
|
||||
{
|
||||
$ancestry = ClassInfo::ancestry($this->owner);
|
||||
$ancestorClass = array_shift($ancestry);
|
||||
while ($ancestorClass && !ViewableData::has_extension($ancestorClass, Hierarchy::class)) {
|
||||
while ($ancestorClass && !ModelData::has_extension($ancestorClass, Hierarchy::class)) {
|
||||
$ancestorClass = array_shift($ancestry);
|
||||
}
|
||||
|
||||
|
@ -5,12 +5,12 @@ namespace SilverStripe\ORM\Hierarchy;
|
||||
use InvalidArgumentException;
|
||||
use LogicException;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Contains a set of hierarchical objects generated from a marking compilation run.
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\ORM\RelatedData;
|
||||
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
|
||||
/**
|
||||
* Interface used to find all other DataObject instances that are related to a DataObject instance
|
||||
|
@ -6,8 +6,8 @@ use ReflectionException;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\Connect\Query;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectSchema;
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
namespace SilverStripe\ORM;
|
||||
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\Model\List\Limitable;
|
||||
use SilverStripe\Model\List\Sortable;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
|
||||
/**
|
||||
|
@ -8,11 +8,11 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\Deprecation;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\ORM\Filters\PartialMatchFilter;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use SilverStripe\ORM\Limitable;
|
||||
use SilverStripe\ORM\Sortable;
|
||||
use SilverStripe\Model\List\Limitable;
|
||||
use SilverStripe\Model\List\Sortable;
|
||||
|
||||
/**
|
||||
* A SearchContext that can be used with non-ORM data.
|
||||
|
@ -11,8 +11,8 @@ use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Forms\SelectField;
|
||||
use SilverStripe\Forms\CheckboxField;
|
||||
use InvalidArgumentException;
|
||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\ORM;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use ArrayIterator;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use Traversable;
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* An AuthenticationHandler is responsible for providing an identity (in the form of a Member object) for
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\Middleware\HTTPMiddleware;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\ORM\Connect\DatabaseException;
|
||||
|
||||
class AuthenticationMiddleware implements HTTPMiddleware
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Security;
|
||||
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\MemberAuthenticator\LoginHandler;
|
||||
use SilverStripe\Security\MemberAuthenticator\LogoutHandler;
|
||||
|
||||
|
@ -11,7 +11,7 @@ use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\HeaderField;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\Forms\LabelField;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
|
||||
/**
|
||||
* Basic confirmation form implementation.
|
||||
|
@ -30,7 +30,7 @@ use SilverStripe\Forms\TextareaField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\TreeDropdownField;
|
||||
use SilverStripe\Forms\TreeMultiselectField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\ORM\HasManyList;
|
||||
|
@ -23,18 +23,18 @@ use SilverStripe\Forms\ListboxField;
|
||||
use SilverStripe\Forms\Tab;
|
||||
use SilverStripe\Forms\TabSet;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\HasManyList;
|
||||
use SilverStripe\ORM\ManyManyList;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\UnsavedRelationList;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Exception\RfcComplianceException;
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Security\MemberAuthenticator;
|
||||
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Authenticator as BaseAuthenticator;
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
|
@ -10,7 +10,7 @@ use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Security\Authenticator;
|
||||
use SilverStripe\Security\IdentityStore;
|
||||
use SilverStripe\Security\LoginAttempt;
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Authenticator;
|
||||
use SilverStripe\Security\PasswordExpirationMiddleware;
|
||||
use SilverStripe\Security\IdentityStore;
|
||||
|
@ -7,7 +7,7 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\HTTPResponse;
|
||||
use SilverStripe\Control\RequestHandler;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\IdentityStore;
|
||||
use SilverStripe\Security\LogoutForm;
|
||||
use SilverStripe\Security\Member;
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Security\MemberAuthenticator;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Authenticator;
|
||||
use SilverStripe\Security\DefaultAdminService;
|
||||
use SilverStripe\Security\LoginAttempt;
|
||||
|
@ -12,7 +12,7 @@ use SilverStripe\Forms\LiteralField;
|
||||
use SilverStripe\Forms\PasswordField;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\LoginForm as BaseLoginForm;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\RememberLoginHash;
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Security;
|
||||
use SilverStripe\Core\Config\Configurable;
|
||||
use SilverStripe\Core\Extensible;
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
/**
|
||||
* This class represents a validator for member passwords.
|
||||
|
@ -6,10 +6,10 @@ use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Core\Resettable;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\i18n\i18nEntityProvider;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\View\TemplateGlobalProvider;
|
||||
|
||||
/**
|
||||
@ -375,7 +375,7 @@ class Permission extends DataObject implements TemplateGlobalProvider, Resettabl
|
||||
public static function grant($groupID, $code, $arg = "any")
|
||||
{
|
||||
$permissions = Permission::get()->filter(['GroupID' => $groupID, 'Code' => $code]);
|
||||
|
||||
|
||||
if ($permissions && $permissions->count() > 0) {
|
||||
$perm = $permissions->last();
|
||||
} else {
|
||||
|
@ -5,10 +5,10 @@ namespace SilverStripe\Security;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Forms\FormField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DataObjectInterface;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use Traversable;
|
||||
|
||||
/**
|
||||
|
@ -18,13 +18,13 @@ use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\TemplateGlobalProvider;
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\View;
|
||||
use SilverStripe\Core\Convert;
|
||||
|
||||
/**
|
||||
* This trait can be applied to a ViewableData class to add the logic to render attributes in an SS template.
|
||||
* This trait can be applied to a ModelData class to add the logic to render attributes in an SS template.
|
||||
*
|
||||
* When applying this trait to a class, you also need to add the following casting configuration.
|
||||
* ```
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\View\Parsers;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use Masterminds\HTML5;
|
||||
use DOMNodeList;
|
||||
use DOMXPath;
|
||||
@ -16,7 +16,7 @@ use SilverStripe\View\HTML;
|
||||
*
|
||||
* @mixin DOMDocument
|
||||
*/
|
||||
class HTMLValue extends ViewableData
|
||||
class HTMLValue extends ModelData
|
||||
{
|
||||
public function __construct($fragment = null)
|
||||
{
|
||||
|
@ -275,7 +275,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
|
||||
/**
|
||||
* The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to
|
||||
* get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
|
||||
* get the next ModelData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
|
||||
* depending on the context the lookup is used in.
|
||||
*/
|
||||
function Lookup_AddLookupStep(&$res, $sub, $method)
|
||||
|
@ -766,7 +766,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
|
||||
/**
|
||||
* The basic generated PHP of LookupStep and LastLookupStep is the same, except that LookupStep calls 'obj' to
|
||||
* get the next ViewableData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
|
||||
* get the next ModelData in the sequence, and LastLookupStep calls different methods (XML_val, hasValue, obj)
|
||||
* depending on the context the lookup is used in.
|
||||
*/
|
||||
function Lookup_AddLookupStep(&$res, $sub, $method)
|
||||
@ -1187,7 +1187,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
$matchrule = "QuotedString"; $result = $this->construct($matchrule, $matchrule, null);
|
||||
$_154 = NULL;
|
||||
do {
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "q" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "q" );
|
||||
if (( $subres = $this->rx( '/[\'"]/' ) ) !== FALSE) {
|
||||
$result["text"] .= $subres;
|
||||
$subres = $result; $result = array_pop($stack);
|
||||
@ -1197,7 +1197,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
$result = array_pop($stack);
|
||||
$_154 = FALSE; break;
|
||||
}
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "String" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "String" );
|
||||
if (( $subres = $this->rx( '/ (\\\\\\\\ | \\\\. | [^'.$this->expression($result, $stack, 'q').'\\\\])* /' ) ) !== FALSE) {
|
||||
$result["text"] .= $subres;
|
||||
$subres = $result; $result = array_pop($stack);
|
||||
@ -1840,7 +1840,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
$pos_255 = $this->pos;
|
||||
$_254 = NULL;
|
||||
do {
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Not" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Not" );
|
||||
if (( $subres = $this->literal( 'not' ) ) !== FALSE) {
|
||||
$result["text"] .= $subres;
|
||||
$subres = $result; $result = array_pop($stack);
|
||||
@ -2235,7 +2235,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
else { $_330 = FALSE; break; }
|
||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
else { $_330 = FALSE; break; }
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Call" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Call" );
|
||||
$_326 = NULL;
|
||||
do {
|
||||
$matcher = 'match_'.'Word'; $key = $matcher; $pos = $this->pos;
|
||||
@ -2740,7 +2740,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
$_423 = NULL;
|
||||
do {
|
||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
||||
$_419 = NULL;
|
||||
do {
|
||||
$_417 = NULL;
|
||||
@ -3166,7 +3166,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
else { $_555 = FALSE; break; }
|
||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "CacheTag" );
|
||||
$_508 = NULL;
|
||||
do {
|
||||
$_506 = NULL;
|
||||
@ -3225,7 +3225,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
$_524 = NULL;
|
||||
do {
|
||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Conditional" );
|
||||
$_520 = NULL;
|
||||
do {
|
||||
$_518 = NULL;
|
||||
@ -4165,7 +4165,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
unset( $pos_685 );
|
||||
}
|
||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Zap" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Zap" );
|
||||
if (( $subres = $this->literal( '%>' ) ) !== FALSE) {
|
||||
$result["text"] .= $subres;
|
||||
$subres = $result; $result = array_pop($stack);
|
||||
@ -4575,7 +4575,7 @@ class SSTemplateParser extends Parser implements TemplateParser
|
||||
if (( $subres = $this->literal( '<%' ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
else { $_743 = FALSE; break; }
|
||||
if (( $subres = $this->whitespace( ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Tag" );
|
||||
$stack[] = $result; $result = $this->construct( $matchrule, "Tag" );
|
||||
$_737 = NULL;
|
||||
do {
|
||||
if (( $subres = $this->literal( 'end_' ) ) !== FALSE) { $result["text"] .= $subres; }
|
||||
|
@ -15,6 +15,7 @@ use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\FieldType\DBHTMLText;
|
||||
use SilverStripe\Security\Permission;
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Parses a template file with an *.ss file extension.
|
||||
@ -324,7 +325,7 @@ class SSViewer implements Flushable
|
||||
/**
|
||||
* Get the current item being processed
|
||||
*
|
||||
* @return ViewableData
|
||||
* @return ModelData
|
||||
*/
|
||||
public static function topLevel()
|
||||
{
|
||||
@ -549,10 +550,10 @@ class SSViewer implements Flushable
|
||||
* Effectively this is the common code that both SSViewer#process and SSViewer_FromString#process call
|
||||
*
|
||||
* @param string $cacheFile The path to the file that contains the template compiled to PHP
|
||||
* @param ViewableData $item The item to use as the root scope for the template
|
||||
* @param ModelData $item The item to use as the root scope for the template
|
||||
* @param array $overlay Any variables to layer on top of the scope
|
||||
* @param array $underlay Any variables to layer underneath the scope
|
||||
* @param ViewableData $inheritedScope The current scope of a parent template including a sub-template
|
||||
* @param ModelData $inheritedScope The current scope of a parent template including a sub-template
|
||||
* @return string The result of executing the template
|
||||
*/
|
||||
protected function includeGeneratedTemplate($cacheFile, $item, $overlay, $underlay, $inheritedScope = null)
|
||||
@ -587,11 +588,11 @@ class SSViewer implements Flushable
|
||||
*
|
||||
* The method injects extra HTML in the header via {@link Requirements::includeInHTML()}.
|
||||
*
|
||||
* Note: You can call this method indirectly by {@link ViewableData->renderWith()}.
|
||||
* Note: You can call this method indirectly by {@link ModelData->renderWith()}.
|
||||
*
|
||||
* @param ViewableData $item
|
||||
* @param ModelData $item
|
||||
* @param array|null $arguments Arguments to an included template
|
||||
* @param ViewableData $inheritedScope The current scope of a parent template including a sub-template
|
||||
* @param ModelData $inheritedScope The current scope of a parent template including a sub-template
|
||||
* @return DBHTMLText Parsed template output.
|
||||
*/
|
||||
public function process($item, $arguments = null, $inheritedScope = null)
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\View;
|
||||
|
||||
/**
|
||||
* Defines an extra set of basic methods that can be used in templates
|
||||
* that are not defined on sub-classes of {@link ViewableData}.
|
||||
* that are not defined on sub-classes of {@link ModelData}.
|
||||
*/
|
||||
class SSViewer_BasicIteratorSupport implements TemplateIteratorProvider
|
||||
{
|
||||
|
@ -4,6 +4,7 @@ namespace SilverStripe\View;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use SilverStripe\Core\ClassInfo;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
|
||||
/**
|
||||
@ -130,7 +131,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope
|
||||
if (!is_array($details)) {
|
||||
$details = [
|
||||
'method' => $details,
|
||||
'casting' => ViewableData::config()->uninherited('default_cast')
|
||||
'casting' => ModelData::config()->uninherited('default_cast')
|
||||
];
|
||||
}
|
||||
|
||||
@ -313,7 +314,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope
|
||||
if ($val) {
|
||||
$obj = $val['obj'];
|
||||
if ($name === 'hasValue') {
|
||||
$result = ($obj instanceof ViewableData) ? $obj->exists() : (bool)$obj;
|
||||
$result = ($obj instanceof ModelData) ? $obj->exists() : (bool)$obj;
|
||||
} elseif (is_null($obj) || (is_scalar($obj) && !is_string($obj))) {
|
||||
$result = $obj; // Nulls and non-string scalars don't need casting
|
||||
} else {
|
||||
@ -434,7 +435,7 @@ class SSViewer_DataPresenter extends SSViewer_Scope
|
||||
|
||||
// Get provided or default cast
|
||||
$casting = empty($source['casting'])
|
||||
? ViewableData::config()->uninherited('default_cast')
|
||||
? ModelData::config()->uninherited('default_cast')
|
||||
: $source['casting'];
|
||||
|
||||
return DBField::create_field($casting, $value);
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\View;
|
||||
use ArrayIterator;
|
||||
use Countable;
|
||||
use Iterator;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBBoolean;
|
||||
use SilverStripe\ORM\FieldType\DBText;
|
||||
use SilverStripe\ORM\FieldType\DBFloat;
|
||||
@ -16,7 +16,7 @@ use SilverStripe\ORM\FieldType\DBField;
|
||||
* This tracks the current scope for an SSViewer instance. It has three goals:
|
||||
* - Handle entering & leaving sub-scopes in loops and withs
|
||||
* - Track Up and Top
|
||||
* - (As a side effect) Inject data that needs to be available globally (used to live in ViewableData)
|
||||
* - (As a side effect) Inject data that needs to be available globally (used to live in ModelData)
|
||||
*
|
||||
* In order to handle up, rather than tracking it using a tree, which would involve constructing new objects
|
||||
* for each step, we use indexes into the itemStack (which already has to exist).
|
||||
@ -132,7 +132,7 @@ class SSViewer_Scope
|
||||
$item = $this->convertScalarToDBField($item);
|
||||
}
|
||||
|
||||
// Wrap list arrays in ViewableData so templates can handle them
|
||||
// Wrap list arrays in ModelData so templates can handle them
|
||||
if (is_array($item) && array_is_list($item)) {
|
||||
$item = ArrayList::create($item);
|
||||
}
|
||||
|
@ -8,9 +8,9 @@ use Psr\SimpleCache\CacheInterface;
|
||||
use Psr\SimpleCache\InvalidArgumentException;
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\Embed\Embeddable;
|
||||
use SilverStripe\View\HTML;
|
||||
use SilverStripe\View\Parsers\ShortcodeHandler;
|
||||
|
@ -19,7 +19,7 @@ interface TemplateGlobalProvider
|
||||
* If the method to call is not included for a particular template variable, a method named the same as the
|
||||
* template variable will be called
|
||||
*
|
||||
* If the casting class is not specified for a particular template variable, ViewableData::$default_cast is used
|
||||
* If the casting class is not specified for a particular template variable, ModelData::$default_cast is used
|
||||
*
|
||||
* The first letter of the template variable is case-insensitive. However the method name is always case sensitive.
|
||||
*
|
||||
|
@ -19,7 +19,7 @@ interface TemplateIteratorProvider
|
||||
* If the method to call is not included for a particular template variable, a method named the same as the
|
||||
* template variable will be called
|
||||
*
|
||||
* If the casting class is not specified for a particular template variable, ViewableData::$default_cast is used
|
||||
* If the casting class is not specified for a particular template variable, ModelData::$default_cast is used
|
||||
*
|
||||
* The first letter of the template variable is case-insensitive. However the method name is always case sensitive.
|
||||
*
|
||||
|
@ -11,7 +11,7 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\TestMailer;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Address;
|
||||
use Symfony\Component\Mime\Part\DataPart;
|
||||
@ -394,12 +394,12 @@ class EmailTest extends SapphireTest
|
||||
$this->assertSame('My content', $email->getData()->Content);
|
||||
}
|
||||
|
||||
public function testDataWithViewableData(): void
|
||||
public function testDataWithModelData(): void
|
||||
{
|
||||
$email = new Email();
|
||||
$viewableData = new ViewableData();
|
||||
$viewableData->ABC = 'XYZ';
|
||||
$email->setData($viewableData);
|
||||
$model = new ModelData();
|
||||
$model->ABC = 'XYZ';
|
||||
$email->setData($model);
|
||||
$data = $email->getData();
|
||||
$this->assertSame('XYZ', $data->ABC);
|
||||
$this->assertSame(true, $data->IsEmail);
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\RSS\RSSFeed;
|
||||
use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\View\Parsers\ShortcodeParser;
|
||||
|
||||
class RSSFeedTest extends SapphireTest
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Control\Tests\RSS\RSSFeedTest;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class ItemA extends ViewableData
|
||||
class ItemA extends ModelData
|
||||
{
|
||||
// RSS-feed items must have $casting/$db information.
|
||||
private static $casting = [
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace SilverStripe\Control\Tests\RSS\RSSFeedTest;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class ItemB extends ViewableData
|
||||
class ItemB extends ModelData
|
||||
{
|
||||
// ItemB tests without $casting
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace SilverStripe\Control\Tests\RSS\RSSFeedTest;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class ItemC extends ViewableData
|
||||
class ItemC extends ModelData
|
||||
{
|
||||
// ItemC tests fields - Title has casting, Content doesn't.
|
||||
private static $casting = [
|
||||
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace SilverStripe\Control\Tests\RSS\RSSFeedTest;
|
||||
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class ItemD extends ViewableData
|
||||
class ItemD extends ModelData
|
||||
{
|
||||
// ItemD test fields - all fields use casting but Content & AltContent cast as HTMLText
|
||||
private static $casting = [
|
||||
|
@ -3,9 +3,9 @@
|
||||
namespace SilverStripe\Control\Tests\RequestHandlingTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class ControllerFailover extends ViewableData implements TestOnly
|
||||
class ControllerFailover extends ModelData implements TestOnly
|
||||
{
|
||||
public function failoverMethod()
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
@ -23,7 +23,7 @@ use SilverStripe\Core\Tests\ClassInfoTest\WithCustomTable;
|
||||
use SilverStripe\Core\Tests\ClassInfoTest\WithRelation;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class ClassInfoTest extends SapphireTest
|
||||
@ -150,7 +150,7 @@ class ClassInfoTest extends SapphireTest
|
||||
{
|
||||
$ancestry = ClassInfo::ancestry(ChildClass::class);
|
||||
$expect = [
|
||||
'silverstripe\\view\\viewabledata' => ViewableData::class,
|
||||
'silverstripe\\model\\modeldata' => ModelData::class,
|
||||
'silverstripe\\orm\\dataobject' => DataObject::class,
|
||||
'silverstripe\\core\tests\classinfotest\\baseclass' => BaseClass::class,
|
||||
'silverstripe\\core\tests\classinfotest\\childclass' => ChildClass::class,
|
||||
|
@ -3,12 +3,12 @@
|
||||
namespace SilverStripe\Core\Tests\Injector\InjectorTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* Make sure DI works with ViewableData's implementation of __isset
|
||||
* Make sure DI works with ModelData's implementation of __isset
|
||||
*/
|
||||
class TestSetterInjections extends ViewableData implements TestOnly
|
||||
class TestSetterInjections extends ModelData implements TestOnly
|
||||
{
|
||||
|
||||
protected $backend;
|
||||
|
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
namespace SilverStripe\Core\Tests\Validation;
|
||||
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
class ValidationExceptionTest extends SapphireTest
|
@ -1,10 +1,10 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
namespace SilverStripe\Core\Tests\Validation;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
class ValidationResultTest extends SapphireTest
|
||||
{
|
@ -2,14 +2,14 @@
|
||||
|
||||
namespace SilverStripe\Dev\Tests;
|
||||
|
||||
use SilverStripe\Dev\Constraint\ViewableDataContains;
|
||||
use SilverStripe\Dev\Constraint\ModelDataContains;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Dev\Tests\ViewableDataContainsTest\TestObject;
|
||||
use SilverStripe\Dev\Tests\ModelDataContainsTest\TestObject;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class ViewableDataContainsTest extends SapphireTest
|
||||
class ModelDataContainsTest extends SapphireTest
|
||||
{
|
||||
private $test_data = [
|
||||
'FirstName' => 'Ingo',
|
||||
@ -53,7 +53,7 @@ class ViewableDataContainsTest extends SapphireTest
|
||||
#[DataProvider('provideMatchesForList')]
|
||||
public function testEvaluateMatchesCorrectlyArrayData($match)
|
||||
{
|
||||
$constraint = new ViewableDataContains($match);
|
||||
$constraint = new ModelDataContains($match);
|
||||
|
||||
$item = ArrayData::create($this->test_data);
|
||||
|
||||
@ -66,7 +66,7 @@ class ViewableDataContainsTest extends SapphireTest
|
||||
#[DataProvider('provideMatchesForList')]
|
||||
public function testEvaluateMatchesCorrectlyDataObject($match)
|
||||
{
|
||||
$constraint = new ViewableDataContains($match);
|
||||
$constraint = new ModelDataContains($match);
|
||||
|
||||
$item = Member::create($this->test_data);
|
||||
|
||||
@ -79,7 +79,7 @@ class ViewableDataContainsTest extends SapphireTest
|
||||
#[DataProvider('provideInvalidMatchesForList')]
|
||||
public function testEvaluateDoesNotMatchWrongMatchInArrayData($match)
|
||||
{
|
||||
$constraint = new ViewableDataContains($match);
|
||||
$constraint = new ModelDataContains($match);
|
||||
|
||||
$item = ArrayData::create($this->test_data);
|
||||
|
||||
@ -92,7 +92,7 @@ class ViewableDataContainsTest extends SapphireTest
|
||||
#[DataProvider('provideInvalidMatchesForList')]
|
||||
public function testEvaluateDoesNotMatchWrongMatchInDataObject($match)
|
||||
{
|
||||
$constraint = new ViewableDataContains($match);
|
||||
$constraint = new ModelDataContains($match);
|
||||
|
||||
$item = Member::create($this->test_data);
|
||||
|
||||
@ -102,10 +102,10 @@ class ViewableDataContainsTest extends SapphireTest
|
||||
public function testFieldAccess()
|
||||
{
|
||||
$data = new TestObject(['name' => 'Damian']);
|
||||
$constraint = new ViewableDataContains(['name' => 'Damian', 'Something' => 'something']);
|
||||
$constraint = new ModelDataContains(['name' => 'Damian', 'Something' => 'something']);
|
||||
$this->assertTrue($constraint->evaluate($data, '', true));
|
||||
|
||||
$constraint = new ViewableDataContains(['name' => 'Damian', 'Something' => 'notthing']);
|
||||
$constraint = new ModelDataContains(['name' => 'Damian', 'Something' => 'notthing']);
|
||||
$this->assertFalse($constraint->evaluate($data, '', true));
|
||||
}
|
||||
}
|
@ -5,7 +5,7 @@ namespace SilverStripe\Dev\Tests;
|
||||
use SilverStripe\Dev\Constraint\SSListContainsOnly;
|
||||
use SilverStripe\Dev\Constraint\SSListContainsOnlyMatchingItems;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
class SSListContainsOnlyMatchingItemsTest extends SapphireTest
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Dev\Tests;
|
||||
|
||||
use SilverStripe\Dev\Constraint\SSListContainsOnly;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Security\Member;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Dev\Tests;
|
||||
|
||||
use SilverStripe\Dev\Constraint\SSListContains;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Security\Member;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Dev\Tests;
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Permission;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Dev\Tests\ViewableDataContainsTest;
|
||||
namespace SilverStripe\Dev\Tests\ModelDataContainsTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class TestObject extends ViewableData implements TestOnly
|
||||
class TestObject extends ModelData implements TestOnly
|
||||
{
|
||||
protected $data = null;
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Forms\Tests;
|
||||
|
||||
use SilverStripe\Forms\Tests\CheckboxSetFieldTest\Article;
|
||||
use SilverStripe\Forms\Tests\CheckboxSetFieldTest\Tag;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Security\Member;
|
||||
@ -16,7 +16,7 @@ use SilverStripe\Forms\CheckboxSetField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class CheckboxSetFieldTest extends SapphireTest
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\Tests;
|
||||
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\DropdownField;
|
||||
@ -11,8 +11,8 @@ use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\Forms\FormTemplateHelper;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class DropdownFieldTest extends SapphireTest
|
||||
@ -171,7 +171,7 @@ class DropdownFieldTest extends SapphireTest
|
||||
|
||||
$form->method('getHTMLID')
|
||||
->willReturn($formName);
|
||||
|
||||
|
||||
$source = [
|
||||
'first' => 'value',
|
||||
0 => 'otherValue'
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Forms\Tests\EmailFieldTest;
|
||||
|
||||
use Exception;
|
||||
use SilverStripe\Forms\Validator;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
class TestValidator extends Validator
|
||||
{
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\Forms\Tests;
|
||||
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\ORM\FieldType\DBEnum;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
@ -31,7 +31,7 @@ use SilverStripe\Forms\Tip;
|
||||
use SilverStripe\Forms\ToggleCompositeField;
|
||||
use SilverStripe\Forms\TreeDropdownField;
|
||||
use SilverStripe\Forms\TreeDropdownField_Readonly;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\PermissionCheckboxSetField;
|
||||
|
@ -27,11 +27,11 @@ use SilverStripe\Forms\Tests\FormTest\TestController;
|
||||
use SilverStripe\Forms\TextareaField;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\TimeField;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\NullSecurityToken;
|
||||
use SilverStripe\Security\RandomGenerator;
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
@ -765,9 +765,9 @@ class FormTest extends FunctionalTest
|
||||
): void {
|
||||
|
||||
$this->get('FormTest_ControllerWithSecurityToken');
|
||||
|
||||
|
||||
[ $form, $button, $data, $withSecurityToken ] = [ ...$formData ];
|
||||
|
||||
|
||||
if (is_null($button)) {
|
||||
$response = $this->submitForm($form, $button, $data, $withSecurityToken);
|
||||
$this->assertEquals($statusCode, $response->getStatusCode(), $testMessage);
|
||||
|
@ -14,8 +14,8 @@ use SilverStripe\Forms\MoneyField;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
class ControllerWithSpecialSubmittedValueFields extends Controller implements TestOnly
|
||||
|
@ -13,8 +13,8 @@ use SilverStripe\Forms\FormAction;
|
||||
use SilverStripe\Forms\NumericField;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\View\SSViewer;
|
||||
|
||||
class TestController extends Controller implements TestOnly
|
||||
|
@ -17,7 +17,7 @@ use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
|
@ -17,8 +17,8 @@ use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Stadium;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldAddExistingAutocompleterTest extends FunctionalTest
|
||||
{
|
||||
|
@ -15,9 +15,9 @@ use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\Person;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\PeopleGroup;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\Category;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\TestController;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldAddNewButtonTest extends SapphireTest
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Forms\Tests\GridField;
|
||||
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldConfigTest\MyOtherComponent;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldConfigTest\MyComponent;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||
use SilverStripe\Forms\GridField\GridField_URLHandler;
|
||||
|
@ -9,8 +9,8 @@ use SilverStripe\Security\Member;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig_Base;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use stdClass;
|
||||
|
||||
class GridFieldDataColumnsTest extends SapphireTest
|
||||
|
@ -20,12 +20,12 @@ use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class GridFieldDeleteActionTest extends SapphireTest
|
||||
|
@ -24,8 +24,8 @@ use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\PeopleGroup;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\Person;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\PolymorphicPeopleGroup;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest\TestController;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class GridFieldDetailFormTest extends FunctionalTest
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\Tests\GridField\GridFieldDetailFormTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class ArrayDataWithID extends ArrayData implements TestOnly
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
||||
use SilverStripe\Forms\GridField\GridFieldEditButton;
|
||||
use SilverStripe\Forms\GridField\GridFieldToolbarHeader;
|
||||
use SilverStripe\Forms\GridField\GridFieldViewButton;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
|
||||
class TestController extends Controller implements TestOnly
|
||||
{
|
||||
|
@ -9,8 +9,8 @@ use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig_Base;
|
||||
use SilverStripe\Forms\GridField\GridFieldDetailForm;
|
||||
use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldDetailForm_ItemRequestTest extends SapphireTest
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Dev\CSSContentParser;
|
||||
|
@ -8,7 +8,7 @@ use ReflectionMethod;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldExportButtonTest\NoView;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldExportButtonTest\Team;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||
@ -17,7 +17,7 @@ use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
||||
use SilverStripe\Forms\GridField\GridFieldPaginator;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldExportButtonTest extends SapphireTest
|
||||
{
|
||||
|
@ -18,10 +18,10 @@ use SilverStripe\Forms\Tests\GridField\GridFieldFilterHeaderTest\Mom;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldFilterHeaderTest\NonDataObject;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldFilterHeaderTest\Team;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldFilterHeaderTest\TeamGroup;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldFilterHeaderTest extends SapphireTest
|
||||
{
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Forms\Tests\GridField\GridFieldFilterHeaderTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class NonDataObject extends ArrayData implements TestOnly
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
|
||||
class GridFieldLazyLoaderTest extends SapphireTest
|
||||
|
@ -6,7 +6,7 @@ use LogicException;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldLevelup;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldLevelupTest extends SapphireTest
|
||||
{
|
||||
|
@ -15,7 +15,7 @@ use SilverStripe\Forms\GridField\GridFieldToolbarHeader;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Cheerleader;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataList;
|
||||
|
||||
class GridFieldPaginatorTest extends FunctionalTest
|
||||
|
@ -14,8 +14,8 @@ use SilverStripe\Forms\GridField\GridFieldPaginator;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldDataColumns;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldPrintButtonTest\TestObject;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldPrintButtonTest extends SapphireTest
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ use SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest;
|
||||
use SilverStripe\Forms\GridField\GridFieldStateManager;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldPrintButtonTest\TestObject;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class GridFieldStateManagerTest extends SapphireTest
|
||||
{
|
||||
|
@ -33,8 +33,8 @@ use SilverStripe\Forms\Tests\GridField\GridFieldTest\Permissions;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Player;
|
||||
use SilverStripe\Forms\Tests\GridField\GridFieldTest\Team;
|
||||
use SilverStripe\Forms\Tests\ValidatorTest\TestValidator;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Versioned\VersionedGridFieldStateExtension;
|
||||
|
@ -5,8 +5,8 @@ namespace SilverStripe\Forms\Tests\GridField\GridFieldTest;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridField_DataManipulator;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
|
||||
class Component2 implements GridField_DataManipulator, TestOnly
|
||||
{
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\Form;
|
||||
use SilverStripe\Forms\GridField\GridField;
|
||||
use SilverStripe\Forms\GridField\GridFieldConfig;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
|
||||
class TestController extends Controller implements TestOnly
|
||||
{
|
||||
|
@ -10,7 +10,7 @@ use SilverStripe\Dev\CSSContentParser;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\ListboxField;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class ListboxFieldTest extends SapphireTest
|
||||
{
|
||||
|
@ -1,19 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests;
|
||||
namespace SilverStripe\Model\Tests;
|
||||
|
||||
use SilverStripe\ORM\ArrayLib;
|
||||
use SilverStripe\Core\ArrayLib;
|
||||
use SilverStripe\ORM\FieldType\DBVarchar;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use stdClass;
|
||||
|
||||
class ArrayDataTest extends SapphireTest
|
||||
{
|
||||
|
||||
public function testViewableDataItemsInsideArraydataArePreserved()
|
||||
public function testModelDataItemsInsideArraydataArePreserved()
|
||||
{
|
||||
/* ViewableData objects will be preserved, but other objects will be converted */
|
||||
/* ModelData objects will be preserved, but other objects will be converted */
|
||||
$arrayData = new ArrayData(
|
||||
[
|
||||
"A" => new DBVarchar("A"),
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ArrayDataTest;
|
||||
namespace SilverStripe\Model\Tests\ArrayDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
@ -1,12 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
namespace SilverStripe\Model\Tests\List;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use stdClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
@ -331,7 +332,7 @@ class ArrayListTest extends SapphireTest
|
||||
$map = $list->map('ID', 'Name');
|
||||
// Items added after calling map should not be included retroactively
|
||||
$list->add(['ID' => 7, 'Name' => 'Andrew']);
|
||||
$this->assertInstanceOf('SilverStripe\\ORM\\Map', $map);
|
||||
$this->assertInstanceOf(Map::class, $map);
|
||||
$this->assertEquals(
|
||||
[
|
||||
1 => 'Steve',
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests\ArrayListTest;
|
||||
namespace SilverStripe\Model\Tests\List\ArrayListTest;
|
||||
|
||||
class TestObject
|
||||
{
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
namespace SilverStripe\Model\Tests\List;
|
||||
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\GroupedList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\GroupedList;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
/**
|
||||
* Tests for the {@link GroupedList} list decorator.
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
namespace SilverStripe\Model\Tests\List;
|
||||
|
||||
use ArrayIterator;
|
||||
use LogicException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\ORM\ListDecorator;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\List\ListDecorator;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
@ -1,25 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
namespace SilverStripe\Model\Tests\List;
|
||||
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\Team;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\TeamComment;
|
||||
use SilverStripe\Model\Tests\List\MapTest\SubTeam;
|
||||
use SilverStripe\Model\Tests\List\MapTest\Team;
|
||||
use SilverStripe\Model\Tests\List\MapTest\TeamComment;
|
||||
|
||||
class MapTest extends SapphireTest
|
||||
{
|
||||
|
||||
// Borrow the model from DataObjectTest
|
||||
protected static $fixture_file = 'DataObjectTest.yml';
|
||||
protected static $fixture_file = 'MapTest.yml';
|
||||
|
||||
public static function getExtraDataObjects()
|
||||
{
|
||||
return array_merge(
|
||||
DataObjectTest::$extra_data_objects,
|
||||
ManyManyListTest::$extra_data_objects
|
||||
);
|
||||
return [
|
||||
Team::class,
|
||||
TeamComment::class,
|
||||
SubTeam::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function testValues()
|
||||
@ -99,7 +99,7 @@ class MapTest extends SapphireTest
|
||||
{
|
||||
$list = Team::get();
|
||||
$map = new Map($list);
|
||||
$this->assertEquals('Team 1', $map[$this->idFromFixture(DataObjectTest\Team::class, 'team1')]);
|
||||
$this->assertEquals('Team 1', $map[$this->idFromFixture(Team::class, 'team1')]);
|
||||
}
|
||||
|
||||
public function testSetKeyFieldAndValueField()
|
32
tests/php/Model/List/MapTest.yml
Normal file
32
tests/php/Model/List/MapTest.yml
Normal file
@ -0,0 +1,32 @@
|
||||
SilverStripe\Model\Tests\List\MapTest\Team:
|
||||
team1:
|
||||
Title: Team 1
|
||||
NumericField: 2
|
||||
team2:
|
||||
Title: Team 2
|
||||
NumericField: 20
|
||||
team3:
|
||||
Title: Team 3
|
||||
NumericField: 5
|
||||
SilverStripe\Model\Tests\List\MapTest\SubTeam:
|
||||
subteam1:
|
||||
Title: Subteam 1
|
||||
NumericField: 7
|
||||
ParentTeam: =>SilverStripe\Model\Tests\List\MapTest\Team.team1
|
||||
subteam2_with_player_relation:
|
||||
Title: Subteam 2
|
||||
subteam3_with_empty_fields:
|
||||
Title: Subteam 3
|
||||
SilverStripe\Model\Tests\List\MapTest\TeamComment:
|
||||
comment1:
|
||||
Name: Joe
|
||||
Comment: This is a team comment by Joe
|
||||
Team: =>SilverStripe\Model\Tests\List\MapTest\Team.team1
|
||||
comment2:
|
||||
Name: Bob
|
||||
Comment: This is a team comment by Bob
|
||||
Team: =>SilverStripe\Model\Tests\List\MapTest\Team.team1
|
||||
comment3:
|
||||
Name: Phil
|
||||
Comment: Phil is a unique guy, and comments on team2
|
||||
Team: =>SilverStripe\Model\Tests\List\MapTest\Team.team2
|
14
tests/php/Model/List/MapTest/SubTeam.php
Normal file
14
tests/php/Model/List/MapTest/SubTeam.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\List\MapTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
class SubTeam extends Team implements TestOnly
|
||||
{
|
||||
private static $table_name = 'MapTest_SubTeam';
|
||||
|
||||
private static $has_one = [
|
||||
"ParentTeam" => Team::class,
|
||||
];
|
||||
}
|
39
tests/php/Model/List/MapTest/Team.php
Normal file
39
tests/php/Model/List/MapTest/Team.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\List\MapTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\HasManyList;
|
||||
|
||||
/**
|
||||
* @property string Title
|
||||
* @property string DatabaseField
|
||||
* @property array SalaryCap
|
||||
* @property string FoundationYear
|
||||
* @property bool CustomHydratedField
|
||||
* @method HasManyList SubTeams()
|
||||
* @method HasManyList Comments()
|
||||
*/
|
||||
class Team extends DataObject implements TestOnly
|
||||
{
|
||||
private static $table_name = 'MapTest_Team';
|
||||
|
||||
private static $db = [
|
||||
'Title' => 'Varchar',
|
||||
'DatabaseField' => 'HTMLVarchar',
|
||||
'NumericField' => 'Int',
|
||||
];
|
||||
|
||||
private static $has_many = [
|
||||
'SubTeams' => SubTeam::class,
|
||||
'Comments' => TeamComment::class,
|
||||
];
|
||||
|
||||
private static $default_sort = '"Title"';
|
||||
|
||||
public function MyTitle()
|
||||
{
|
||||
return 'Team ' . $this->Title;
|
||||
}
|
||||
}
|
22
tests/php/Model/List/MapTest/TeamComment.php
Normal file
22
tests/php/Model/List/MapTest/TeamComment.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\List\MapTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class TeamComment extends DataObject implements TestOnly
|
||||
{
|
||||
private static $table_name = 'MapTest_TeamComment';
|
||||
|
||||
private static $db = [
|
||||
'Name' => 'Varchar',
|
||||
'Comment' => 'Text'
|
||||
];
|
||||
|
||||
private static $has_one = [
|
||||
'Team' => Team::class
|
||||
];
|
||||
|
||||
private static $default_sort = '"Name" ASC';
|
||||
}
|
@ -1,30 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
namespace SilverStripe\Model\Tests\List;
|
||||
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\PaginatedList;
|
||||
use SilverStripe\Model\List\PaginatedList;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\Player;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Control\HTTPRequest;
|
||||
use SilverStripe\Model\Tests\List\PaginatedListTest\Player;
|
||||
|
||||
/**
|
||||
* Tests for the {@link SilverStripe\ORM\PaginatedList} class.
|
||||
* Tests for the {@link SilverStripe\Model\List\PaginatedList} class.
|
||||
*/
|
||||
class PaginatedListTest extends SapphireTest
|
||||
{
|
||||
|
||||
protected static $fixture_file = 'DataObjectTest.yml';
|
||||
protected static $fixture_file = 'PaginatedListTest.yml';
|
||||
|
||||
public static function getExtraDataObjects()
|
||||
{
|
||||
return array_merge(
|
||||
DataObjectTest::$extra_data_objects,
|
||||
ManyManyListTest::$extra_data_objects
|
||||
);
|
||||
return [
|
||||
Player::class,
|
||||
];
|
||||
}
|
||||
|
||||
public function testPageStart()
|
13
tests/php/Model/List/PaginatedListTest.yml
Normal file
13
tests/php/Model/List/PaginatedListTest.yml
Normal file
@ -0,0 +1,13 @@
|
||||
SilverStripe\Model\Tests\List\PaginatedListTest\Player:
|
||||
captain1:
|
||||
FirstName: Captain
|
||||
Surname: Zookeeper
|
||||
ShirtNumber: '007'
|
||||
IsRetired: 1
|
||||
captain2:
|
||||
FirstName: Captain 2
|
||||
Surname: Aaron
|
||||
player1:
|
||||
FirstName: Player 1
|
||||
player2:
|
||||
FirstName: Player 2
|
21
tests/php/Model/List/PaginatedListTest/Player.php
Normal file
21
tests/php/Model/List/PaginatedListTest/Player.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\List\PaginatedListTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Security\Member;
|
||||
|
||||
class Player extends Member implements TestOnly
|
||||
{
|
||||
private static $table_name = 'PaginatedListTest_Player';
|
||||
|
||||
private static $db = [
|
||||
'IsRetired' => 'Boolean',
|
||||
'ShirtNumber' => 'Varchar',
|
||||
];
|
||||
|
||||
private static $searchable_fields = [
|
||||
'IsRetired',
|
||||
'ShirtNumber'
|
||||
];
|
||||
}
|
55
tests/php/Model/ModelDataCustomisedTest.php
Normal file
55
tests/php/Model/ModelDataCustomisedTest.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests;
|
||||
|
||||
use SilverStripe\Dev\Constraint\ModelDataContains;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Model\ModelDataCustomised;
|
||||
|
||||
/**
|
||||
* Test for ModelDataCustomised.
|
||||
*/
|
||||
class ModelDataCustomisedTest extends SapphireTest
|
||||
{
|
||||
public function testNestedModelDataCustomisedAsCustomised()
|
||||
{
|
||||
$outerCustomised = ModelDataCustomised::create($this->makeOuterOriginal(), $this->makeInnerModelDataCustomised());
|
||||
$this->assertThat($outerCustomised, $this->makeTestConstraint());
|
||||
}
|
||||
|
||||
public function testNestedModelDataCustomisedAsOriginal()
|
||||
{
|
||||
$outerCustomised = ModelDataCustomised::create($this->makeInnerModelDataCustomised(), $this->makeOuterOriginal());
|
||||
$this->assertThat($outerCustomised, $this->makeTestConstraint());
|
||||
}
|
||||
|
||||
private function makeTestConstraint()
|
||||
{
|
||||
return new ModelDataContains([
|
||||
'outerOriginal' => 'foobar',
|
||||
'innerOriginal' => 'hello',
|
||||
'innerCustomised' => 'world',
|
||||
]);
|
||||
}
|
||||
|
||||
private function makeOuterOriginal()
|
||||
{
|
||||
return ArrayData::create([
|
||||
'outerOriginal' => 'foobar',
|
||||
]);
|
||||
}
|
||||
|
||||
private function makeInnerModelDataCustomised()
|
||||
{
|
||||
$original = ArrayData::create([
|
||||
'innerOriginal' => 'hello',
|
||||
]);
|
||||
|
||||
$customised = ArrayData::create([
|
||||
'innerCustomised' => 'world',
|
||||
]);
|
||||
|
||||
return ModelDataCustomised::create($original, $customised);
|
||||
}
|
||||
}
|
@ -1,28 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests;
|
||||
namespace SilverStripe\Model\Tests;
|
||||
|
||||
use ReflectionMethod;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\FieldType\DBText;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\Tests\ViewableDataTest\ViewableDataTestExtension;
|
||||
use SilverStripe\View\Tests\ViewableDataTest\ViewableDataTestObject;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Model\Tests\ModelDataTest\ModelDataTestExtension;
|
||||
use SilverStripe\Model\Tests\ModelDataTest\ModelDataTestObject;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
/**
|
||||
* See {@link SSViewerTest->testCastingHelpers()} for more tests related to casting and ViewableData behaviour,
|
||||
* See {@link SSViewerTest->testCastingHelpers()} for more tests related to casting and ModelData behaviour,
|
||||
* from a template-parsing perspective.
|
||||
*/
|
||||
class ViewableDataTest extends SapphireTest
|
||||
class ModelDataTest extends SapphireTest
|
||||
{
|
||||
protected static $required_extensions = [
|
||||
ViewableDataTestObject::class => [
|
||||
ViewableDataTestExtension::class,
|
||||
ModelDataTestObject::class => [
|
||||
ModelDataTestExtension::class,
|
||||
],
|
||||
];
|
||||
|
||||
@ -57,10 +56,10 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testRequiresCasting()
|
||||
{
|
||||
$caster = new ViewableDataTest\Castable();
|
||||
$caster = new ModelDataTest\Castable();
|
||||
|
||||
$this->assertInstanceOf(ViewableDataTest\RequiresCasting::class, $caster->obj('alwaysCasted'));
|
||||
$this->assertInstanceOf(ViewableDataTest\Caster::class, $caster->obj('noCastingInformation'));
|
||||
$this->assertInstanceOf(ModelDataTest\RequiresCasting::class, $caster->obj('alwaysCasted'));
|
||||
$this->assertInstanceOf(ModelDataTest\Caster::class, $caster->obj('noCastingInformation'));
|
||||
|
||||
$this->assertInstanceOf(DBText::class, $caster->obj('arrayOne'));
|
||||
$this->assertInstanceOf(ArrayList::class, $caster->obj('arrayTwo'));
|
||||
@ -68,20 +67,20 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testFailoverRequiresCasting()
|
||||
{
|
||||
$caster = new ViewableDataTest\Castable();
|
||||
$container = new ViewableDataTest\Container();
|
||||
$caster = new ModelDataTest\Castable();
|
||||
$container = new ModelDataTest\Container();
|
||||
$container->setFailover($caster);
|
||||
|
||||
$this->assertInstanceOf(ViewableDataTest\RequiresCasting::class, $container->obj('alwaysCasted'));
|
||||
$this->assertInstanceOf(ViewableDataTest\RequiresCasting::class, $caster->obj('alwaysCasted'));
|
||||
$this->assertInstanceOf(ModelDataTest\RequiresCasting::class, $container->obj('alwaysCasted'));
|
||||
$this->assertInstanceOf(ModelDataTest\RequiresCasting::class, $caster->obj('alwaysCasted'));
|
||||
|
||||
$this->assertInstanceOf(ViewableDataTest\Caster::class, $container->obj('noCastingInformation'));
|
||||
$this->assertInstanceOf(ViewableDataTest\Caster::class, $caster->obj('noCastingInformation'));
|
||||
$this->assertInstanceOf(ModelDataTest\Caster::class, $container->obj('noCastingInformation'));
|
||||
$this->assertInstanceOf(ModelDataTest\Caster::class, $caster->obj('noCastingInformation'));
|
||||
}
|
||||
|
||||
public function testCastingXMLVal()
|
||||
{
|
||||
$caster = new ViewableDataTest\Castable();
|
||||
$caster = new ModelDataTest\Castable();
|
||||
|
||||
$this->assertEquals('casted', $caster->XML_val('alwaysCasted'));
|
||||
$this->assertEquals('casted', $caster->XML_val('noCastingInformation'));
|
||||
@ -93,43 +92,43 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testArrayCustomise()
|
||||
{
|
||||
$viewableData = new ViewableDataTest\Castable();
|
||||
$newViewableData = $viewableData->customise(
|
||||
$modelData = new ModelDataTest\Castable();
|
||||
$newModelData = $modelData->customise(
|
||||
[
|
||||
'test' => 'overwritten',
|
||||
'alwaysCasted' => 'overwritten'
|
||||
]
|
||||
);
|
||||
|
||||
$this->assertEquals('test', $viewableData->XML_val('test'));
|
||||
$this->assertEquals('casted', $viewableData->XML_val('alwaysCasted'));
|
||||
$this->assertEquals('test', $modelData->XML_val('test'));
|
||||
$this->assertEquals('casted', $modelData->XML_val('alwaysCasted'));
|
||||
|
||||
$this->assertEquals('overwritten', $newViewableData->XML_val('test'));
|
||||
$this->assertEquals('overwritten', $newViewableData->XML_val('alwaysCasted'));
|
||||
$this->assertEquals('overwritten', $newModelData->XML_val('test'));
|
||||
$this->assertEquals('overwritten', $newModelData->XML_val('alwaysCasted'));
|
||||
|
||||
$this->assertEquals('castable', $viewableData->forTemplate());
|
||||
$this->assertEquals('castable', $newViewableData->forTemplate());
|
||||
$this->assertEquals('castable', $modelData->forTemplate());
|
||||
$this->assertEquals('castable', $newModelData->forTemplate());
|
||||
}
|
||||
|
||||
public function testObjectCustomise()
|
||||
{
|
||||
$viewableData = new ViewableDataTest\Castable();
|
||||
$newViewableData = $viewableData->customise(new ViewableDataTest\RequiresCasting());
|
||||
$modelData = new ModelDataTest\Castable();
|
||||
$newModelData = $modelData->customise(new ModelDataTest\RequiresCasting());
|
||||
|
||||
$this->assertEquals('test', $viewableData->XML_val('test'));
|
||||
$this->assertEquals('casted', $viewableData->XML_val('alwaysCasted'));
|
||||
$this->assertEquals('test', $modelData->XML_val('test'));
|
||||
$this->assertEquals('casted', $modelData->XML_val('alwaysCasted'));
|
||||
|
||||
$this->assertEquals('overwritten', $newViewableData->XML_val('test'));
|
||||
$this->assertEquals('casted', $newViewableData->XML_val('alwaysCasted'));
|
||||
$this->assertEquals('overwritten', $newModelData->XML_val('test'));
|
||||
$this->assertEquals('casted', $newModelData->XML_val('alwaysCasted'));
|
||||
|
||||
$this->assertEquals('castable', $viewableData->forTemplate());
|
||||
$this->assertEquals('casted', $newViewableData->forTemplate());
|
||||
$this->assertEquals('castable', $modelData->forTemplate());
|
||||
$this->assertEquals('casted', $newModelData->forTemplate());
|
||||
}
|
||||
|
||||
public function testDefaultValueWrapping()
|
||||
{
|
||||
$data = new ArrayData(['Title' => 'SomeTitleValue']);
|
||||
// this results in a cached raw string in ViewableData:
|
||||
// this results in a cached raw string in ModelData:
|
||||
$this->assertTrue($data->hasValue('Title'));
|
||||
$this->assertFalse($data->hasValue('SomethingElse'));
|
||||
// this should cast the raw string to a StringField since we are
|
||||
@ -148,7 +147,7 @@ class ViewableDataTest extends SapphireTest
|
||||
'Argument' => 'ArgumentType',
|
||||
'ArrayArgument' => 'ArrayArgumentType'
|
||||
];
|
||||
$obj = new ViewableDataTest\CastingClass();
|
||||
$obj = new ModelDataTest\CastingClass();
|
||||
|
||||
foreach ($expected as $field => $class) {
|
||||
$this->assertEquals(
|
||||
@ -161,7 +160,7 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testObjWithCachedStringValueReturnsValidObject()
|
||||
{
|
||||
$obj = new ViewableDataTest\NoCastingInformation();
|
||||
$obj = new ModelDataTest\NoCastingInformation();
|
||||
|
||||
// Save a literal string into cache
|
||||
$cache = true;
|
||||
@ -184,8 +183,8 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testCaching()
|
||||
{
|
||||
$objCached = new ViewableDataTest\Cached();
|
||||
$objNotCached = new ViewableDataTest\NotCached();
|
||||
$objCached = new ModelDataTest\Cached();
|
||||
$objNotCached = new ModelDataTest\NotCached();
|
||||
|
||||
$objCached->Test = 'AAA';
|
||||
$objNotCached->Test = 'AAA';
|
||||
@ -203,15 +202,15 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testSetFailover()
|
||||
{
|
||||
$failover = new ViewableData();
|
||||
$container = new ViewableDataTest\Container();
|
||||
$failover = new ModelData();
|
||||
$container = new ModelDataTest\Container();
|
||||
$container->setFailover($failover);
|
||||
|
||||
$this->assertSame($failover, $container->getFailover(), 'getFailover() returned a different object');
|
||||
$this->assertFalse($container->hasMethod('testMethod'), 'testMethod() is already defined when it shouldn’t be');
|
||||
|
||||
// Ensure that defined methods detected from the failover aren't cached when setting a new failover
|
||||
$container->setFailover(new ViewableDataTest\Failover);
|
||||
$container->setFailover(new ModelDataTest\Failover);
|
||||
$this->assertTrue($container->hasMethod('testMethod'));
|
||||
|
||||
// Test the reverse - that defined methods previously detected in a failover are removed if they no longer exist
|
||||
@ -222,10 +221,10 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testIsAccessibleMethod()
|
||||
{
|
||||
$reflectionMethod = new ReflectionMethod(ViewableData::class, 'isAccessibleMethod');
|
||||
$reflectionMethod = new ReflectionMethod(ModelData::class, 'isAccessibleMethod');
|
||||
$reflectionMethod->setAccessible(true);
|
||||
$object = new ViewableDataTestObject();
|
||||
$viewableData = new ViewableData();
|
||||
$object = new ModelDataTestObject();
|
||||
$modelData = new ModelData();
|
||||
|
||||
$output = $reflectionMethod->invokeArgs($object, ['privateMethod']);
|
||||
$this->assertFalse($output, 'Method should not be accessible');
|
||||
@ -239,7 +238,7 @@ class ViewableDataTest extends SapphireTest
|
||||
$output = $reflectionMethod->invokeArgs($object, ['missingMethod']);
|
||||
$this->assertFalse($output, 'Method should not be accessible');
|
||||
|
||||
$output = $reflectionMethod->invokeArgs($viewableData, ['isAccessibleProperty']);
|
||||
$output = $reflectionMethod->invokeArgs($modelData, ['isAccessibleProperty']);
|
||||
$this->assertTrue($output, 'Method should be accessible');
|
||||
|
||||
$output = $reflectionMethod->invokeArgs($object, ['publicMethodFromExtension']);
|
||||
@ -254,9 +253,9 @@ class ViewableDataTest extends SapphireTest
|
||||
|
||||
public function testIsAccessibleProperty()
|
||||
{
|
||||
$reflectionMethod = new ReflectionMethod(ViewableData::class, 'isAccessibleProperty');
|
||||
$reflectionMethod = new ReflectionMethod(ModelData::class, 'isAccessibleProperty');
|
||||
$reflectionMethod->setAccessible(true);
|
||||
$object = new ViewableDataTestObject();
|
||||
$object = new ModelDataTestObject();
|
||||
|
||||
$output = $reflectionMethod->invokeArgs($object, ['privateProperty']);
|
||||
$this->assertFalse($output, 'Property should not be accessible');
|
||||
@ -270,19 +269,19 @@ class ViewableDataTest extends SapphireTest
|
||||
$output = $reflectionMethod->invokeArgs($object, ['missingProperty']);
|
||||
$this->assertFalse($output, 'Property should not be accessible');
|
||||
|
||||
$output = $reflectionMethod->invokeArgs(new ViewableData(), ['objCache']);
|
||||
$output = $reflectionMethod->invokeArgs(new ModelData(), ['objCache']);
|
||||
$this->assertTrue($output, 'Property should be accessible');
|
||||
}
|
||||
|
||||
public function testDynamicData()
|
||||
{
|
||||
$obj = (object) ['SomeField' => [1, 2, 3]];
|
||||
$viewableData = new ViewableData();
|
||||
$this->assertFalse($viewableData->hasDynamicData('abc'));
|
||||
$viewableData->setDynamicData('abc', $obj);
|
||||
$this->assertTrue($viewableData->hasDynamicData('abc'));
|
||||
$this->assertSame($obj, $viewableData->getDynamicData('abc'));
|
||||
$this->assertSame($obj, $viewableData->abc);
|
||||
$modelData = new ModelData();
|
||||
$this->assertFalse($modelData->hasDynamicData('abc'));
|
||||
$modelData->setDynamicData('abc', $obj);
|
||||
$this->assertTrue($modelData->hasDynamicData('abc'));
|
||||
$this->assertSame($obj, $modelData->getDynamicData('abc'));
|
||||
$this->assertSame($obj, $modelData->abc);
|
||||
}
|
||||
|
||||
public static function provideWrapArrayInObj(): array
|
||||
@ -305,8 +304,8 @@ class ViewableDataTest extends SapphireTest
|
||||
#[DataProvider('provideWrapArrayInObj')]
|
||||
public function testWrapArrayInObj(array $arr, string $expectedClass): void
|
||||
{
|
||||
$viewableData = new ViewableData();
|
||||
$viewableData->arr = $arr;
|
||||
$this->assertInstanceOf($expectedClass, $viewableData->obj('arr'));
|
||||
$modelData = new ModelData();
|
||||
$modelData->arr = $arr;
|
||||
$this->assertInstanceOf($expectedClass, $modelData->obj('arr'));
|
||||
}
|
||||
}
|
11
tests/php/Model/ModelDataTest/Cached.php
Normal file
11
tests/php/Model/ModelDataTest/Cached.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class Cached extends ModelData implements TestOnly
|
||||
{
|
||||
public $Test;
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class Castable extends ViewableData implements TestOnly
|
||||
class Castable extends ModelData implements TestOnly
|
||||
{
|
||||
private static $default_cast = Caster::class;
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class Caster extends ViewableData implements TestOnly
|
||||
class Caster extends ModelData implements TestOnly
|
||||
{
|
||||
|
||||
public function forTemplate(): string
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class CastingClass extends ViewableData implements TestOnly
|
||||
class CastingClass extends ModelData implements TestOnly
|
||||
{
|
||||
private static $casting = [
|
||||
'Field' => 'CastingType',
|
11
tests/php/Model/ModelDataTest/Container.php
Normal file
11
tests/php/Model/ModelDataTest/Container.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class Container extends ModelData implements TestOnly
|
||||
{
|
||||
|
||||
}
|
13
tests/php/Model/ModelDataTest/Failover.php
Normal file
13
tests/php/Model/ModelDataTest/Failover.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class Failover extends ModelData implements TestOnly
|
||||
{
|
||||
public function testMethod()
|
||||
{
|
||||
}
|
||||
}
|
14
tests/php/Model/ModelDataTest/NoCastingInformation.php
Normal file
14
tests/php/Model/ModelDataTest/NoCastingInformation.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class NoCastingInformation extends ModelData implements TestOnly
|
||||
{
|
||||
public function noCastingInformation()
|
||||
{
|
||||
return "No casting information";
|
||||
}
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class NotCached extends ViewableData implements TestOnly
|
||||
class NotCached extends ModelData implements TestOnly
|
||||
{
|
||||
public $Test;
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class RequiresCasting extends ViewableData implements TestOnly
|
||||
class RequiresCasting extends ModelData implements TestOnly
|
||||
{
|
||||
|
||||
public $test = 'overwritten';
|
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class UnescapedCaster extends ViewableData implements TestOnly
|
||||
class UnescapedCaster extends ModelData implements TestOnly
|
||||
{
|
||||
protected $value;
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
|
||||
class ViewableDataTestObject extends DataObject implements TestOnly
|
||||
class ModelDataTestObject extends DataObject implements TestOnly
|
||||
{
|
||||
private string $privateProperty = 'private property';
|
||||
|
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
namespace SilverStripe\Model\Tests\ModelDataTest;
|
||||
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
|
||||
class ViewableDataTestExtension extends Extension implements TestOnly
|
||||
class ModelDataTestExtension extends Extension implements TestOnly
|
||||
{
|
||||
private function privateMethodFromExtension(): string
|
||||
{
|
@ -6,7 +6,7 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class TestDbField extends DBField implements TestOnly
|
||||
{
|
||||
@ -35,7 +35,7 @@ class TestDbField extends DBField implements TestOnly
|
||||
|
||||
public $saveIntoCalledCount = 0;
|
||||
|
||||
public function saveInto(ViewableData $model): void
|
||||
public function saveInto(ModelData $model): void
|
||||
{
|
||||
$this->saveIntoCalledCount++;
|
||||
parent::saveInto($model);
|
||||
|
@ -12,7 +12,7 @@ use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\EagerLoadedList;
|
||||
use SilverStripe\ORM\ManyManyThroughList;
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\Tests\DataListTest\EagerLoading\EagerLoadObject;
|
||||
use SilverStripe\ORM\Tests\DataListTest\EagerLoading\EagerLoadSubClassObject;
|
||||
use SilverStripe\ORM\Tests\DataListTest\EagerLoading\HasOneEagerLoadObject;
|
||||
|
@ -12,7 +12,7 @@ use SilverStripe\ORM\Connect\MySQLiConnector;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\ORM\Filters\ExactMatchFilter;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\DataListQueryCounter;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\Fixture;
|
||||
|
@ -22,9 +22,9 @@ use SilverStripe\ORM\Tests\DataObjectTest\Company;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\Player;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\Team;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\TreeNode;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use ReflectionMethod;
|
||||
use stdClass;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
@ -1586,7 +1586,7 @@ class DataObjectTest extends SapphireTest
|
||||
|
||||
/* Return false if you don't pass it a subclass of DataObject */
|
||||
$this->assertFalse($schema->classHasTable(DataObject::class));
|
||||
$this->assertFalse($schema->classHasTable(ViewableData::class));
|
||||
$this->assertFalse($schema->classHasTable(ModelData::class));
|
||||
|
||||
/* Invalid class name */
|
||||
$this->assertFalse($schema->classHasTable("ThisIsntADataObject"));
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\DataObjectTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
class ValidatedObject extends DataObject implements TestOnly
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ use SilverStripe\ORM\DataQuery;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\ORM\Tests\DataQueryTest\ObjectE;
|
||||
use SilverStripe\Security\Member;
|
||||
|
@ -10,7 +10,7 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Connect\MySQLiConnector;
|
||||
use SilverStripe\ORM\EagerLoadedList;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\Filterable;
|
||||
use SilverStripe\Model\List\Filterable;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\EquipmentCompany;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\Fan;
|
||||
use SilverStripe\ORM\Tests\DataObjectTest\Player;
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\Filters;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Filters\EndsWithFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\ORM\Filters\ExactMatchFilter;
|
||||
use SilverStripe\ORM\Tests\Filters\ExactMatchFilterTest\Task;
|
||||
use SilverStripe\ORM\Tests\Filters\ExactMatchFilterTest\Project;
|
||||
use SilverStripe\ORM\DataList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\Filters;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Filters\GreaterThanFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class GreaterThanFilterTest extends SapphireTest
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\Filters;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Filters\GreaterThanOrEqualFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class GreaterThanOrEqualFilterTest extends SapphireTest
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\Filters;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Filters\LessThanFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class LessThanFilterTest extends SapphireTest
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\Filters;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Filters\LessThanOrEqualFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class LessThanOrEqualFilterTest extends SapphireTest
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\Filters;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Filters\PartialMatchFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\ORM\Tests\Filters;
|
||||
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\Filters\StartsWithFilter;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Versioned\Versioned;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
namespace SilverStripe\ORM\Tests;
|
||||
|
||||
use SilverStripe\ORM\SS_List;
|
||||
use SilverStripe\Model\List\SS_List;
|
||||
use SilverStripe\ORM\Tests\RelatedDataServiceTest\Base;
|
||||
use SilverStripe\ORM\Tests\RelatedDataServiceTest\Belongs;
|
||||
use SilverStripe\ORM\Tests\RelatedDataServiceTest\HasMany;
|
||||
|
@ -10,7 +10,7 @@ use SilverStripe\ORM\Queries\SQLSelect;
|
||||
use SilverStripe\SQLite\SQLite3Database;
|
||||
use SilverStripe\PostgreSQL\PostgreSQLDatabase;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\Connect\DatabaseException;
|
||||
use SilverStripe\ORM\Tests\SQLSelectTest\CteDatesObject;
|
||||
use SilverStripe\ORM\Tests\SQLSelectTest\CteRecursiveObject;
|
||||
|
@ -8,12 +8,12 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\Forms\TextField;
|
||||
use SilverStripe\Forms\FieldList;
|
||||
use SilverStripe\Forms\HiddenField;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\Filters\ExactMatchFilter;
|
||||
use SilverStripe\ORM\Filters\SearchFilter;
|
||||
use SilverStripe\ORM\Filters\StartsWithFilter;
|
||||
use SilverStripe\ORM\Search\BasicSearchContext;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
class BasicSearchContextTest extends SapphireTest
|
||||
|
@ -18,7 +18,7 @@ use SilverStripe\ORM\Filters\EndsWithFilter;
|
||||
use SilverStripe\ORM\Filters\ExactMatchFilter;
|
||||
use SilverStripe\ORM\Filters\PartialMatchFilter;
|
||||
use SilverStripe\ORM\Search\SearchContext;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
|
||||
class SearchContextTest extends SapphireTest
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ use InvalidArgumentException;
|
||||
use SilverStripe\Control\Controller;
|
||||
use SilverStripe\Dev\FunctionalTest;
|
||||
use SilverStripe\Forms\RequiredFields;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\Member;
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Authenticator;
|
||||
use SilverStripe\Security\DefaultAdminService;
|
||||
use SilverStripe\Security\IdentityStore;
|
||||
|
@ -17,9 +17,9 @@ use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\Map;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Model\List\Map;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Group;
|
||||
use SilverStripe\Security\IdentityStore;
|
||||
use SilverStripe\Security\Member;
|
||||
|
@ -4,7 +4,7 @@ namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\Core\Extension;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
|
||||
/**
|
||||
* Extension that does something extra when changing a member's password
|
||||
|
@ -3,7 +3,7 @@
|
||||
namespace SilverStripe\Security\Tests\MemberTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\PasswordValidator;
|
||||
|
||||
class VerySpecificPasswordValidator extends PasswordValidator implements TestOnly
|
||||
|
@ -5,7 +5,7 @@ namespace SilverStripe\Security\Tests;
|
||||
use SilverStripe\Control\Director;
|
||||
use SilverStripe\Control\Tests\HttpRequestMockBuilder;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\ValidationException;
|
||||
use SilverStripe\Core\Validation\ValidationException;
|
||||
use SilverStripe\Security\PasswordExpirationMiddleware;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\Security;
|
||||
|
@ -18,7 +18,7 @@ use SilverStripe\ORM\DB;
|
||||
use SilverStripe\ORM\FieldType\DBEnum;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\LoginAttempt;
|
||||
use SilverStripe\Security\Member;
|
||||
use SilverStripe\Security\MemberAuthenticator\MemberAuthenticator;
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Core\Config\Config;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\ORM\FieldType\DBDatetime;
|
||||
use SilverStripe\ORM\ValidationResult;
|
||||
use SilverStripe\Core\Validation\ValidationResult;
|
||||
use SilverStripe\Security\Authenticator;
|
||||
use SilverStripe\Security\DefaultAdminService;
|
||||
use SilverStripe\Security\IdentityStore;
|
||||
|
@ -8,7 +8,7 @@ use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use Silverstripe\Assets\Dev\TestAssetStore;
|
||||
use SilverStripe\View\Requirements_Backend;
|
||||
use SilverStripe\Core\Manifest\ResourceURLGenerator;
|
||||
|
@ -15,7 +15,7 @@ use Symfony\Component\Cache\Adapter\FilesystemAdapter;
|
||||
use Symfony\Component\Cache\Adapter\NullAdapter;
|
||||
use Symfony\Component\Cache\Psr16Cache;
|
||||
|
||||
// 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 ModelData object that's just for us
|
||||
|
||||
class SSViewerCacheBlockTest extends SapphireTest
|
||||
{
|
||||
|
@ -15,14 +15,14 @@ use SilverStripe\Core\Convert;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\ORM\DataObject;
|
||||
use SilverStripe\ORM\FieldType\DBField;
|
||||
use SilverStripe\ORM\PaginatedList;
|
||||
use SilverStripe\Model\List\PaginatedList;
|
||||
use SilverStripe\Security\Permission;
|
||||
use SilverStripe\Security\Security;
|
||||
use SilverStripe\Security\SecurityToken;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\Requirements;
|
||||
use SilverStripe\View\Requirements_Backend;
|
||||
use SilverStripe\View\SSTemplateParseException;
|
||||
@ -31,8 +31,8 @@ use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\SSViewer_FromString;
|
||||
use SilverStripe\View\Tests\SSViewerTest\SSViewerTestModel;
|
||||
use SilverStripe\View\Tests\SSViewerTest\SSViewerTestModelController;
|
||||
use SilverStripe\View\Tests\SSViewerTest\TestViewableData;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\View\Tests\SSViewerTest\TestModelData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
|
||||
|
||||
@ -598,7 +598,7 @@ SS;
|
||||
#[DataProvider('provideArgumentTypes')]
|
||||
public function testArgumentTypes(string $expected, string $template)
|
||||
{
|
||||
$this->assertEquals($expected, $this->render($template, new TestViewableData()));
|
||||
$this->assertEquals($expected, $this->render($template, new TestModelData()));
|
||||
}
|
||||
|
||||
public function testObjectDotArguments()
|
||||
@ -767,7 +767,7 @@ after'
|
||||
public function testTypesArePreserved($expected, $templateArg)
|
||||
{
|
||||
$data = new ArrayData([
|
||||
'Test' => new TestViewableData()
|
||||
'Test' => new TestModelData()
|
||||
]);
|
||||
|
||||
$this->assertEquals($expected, $this->render("\$Test.Type({$templateArg})", $data));
|
||||
@ -777,7 +777,7 @@ after'
|
||||
public function testTypesArePreservedAsIncludeArguments($expected, $templateArg)
|
||||
{
|
||||
$data = new ArrayData([
|
||||
'Test' => new TestViewableData()
|
||||
'Test' => new TestModelData()
|
||||
]);
|
||||
|
||||
$this->assertEquals(
|
||||
@ -789,7 +789,7 @@ after'
|
||||
public function testTypePreservationInConditionals()
|
||||
{
|
||||
$data = new ArrayData([
|
||||
'Test' => new TestViewableData()
|
||||
'Test' => new TestModelData()
|
||||
]);
|
||||
|
||||
// Types in conditionals
|
||||
@ -1326,12 +1326,12 @@ after'
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link ViewableDataTest} for more extensive casting tests,
|
||||
* See {@link ModelDataTest} for more extensive casting tests,
|
||||
* this test just ensures that basic casting is correctly applied during template parsing.
|
||||
*/
|
||||
public function testCastingHelpers()
|
||||
{
|
||||
$vd = new SSViewerTest\TestViewableData();
|
||||
$vd = new SSViewerTest\TestModelData();
|
||||
$vd->TextValue = '<b>html</b>';
|
||||
$vd->HTMLValue = '<b>html</b>';
|
||||
$vd->UncastedValue = '<b>html</b>';
|
||||
@ -1364,8 +1364,8 @@ after'
|
||||
$t = SSViewer::fromString('$HTMLValue.XML')->process($vd)
|
||||
);
|
||||
|
||||
// Uncasted value (falls back to ViewableData::$default_cast="Text")
|
||||
$vd = new SSViewerTest\TestViewableData();
|
||||
// Uncasted value (falls back to ModelData::$default_cast="Text")
|
||||
$vd = new SSViewerTest\TestModelData();
|
||||
$vd->UncastedValue = '<b>html</b>';
|
||||
$this->assertEquals(
|
||||
'<b>html</b>',
|
||||
@ -1974,7 +1974,7 @@ after'
|
||||
</html>'
|
||||
);
|
||||
$tmpl = new SSViewer($tmplFile);
|
||||
$obj = new ViewableData();
|
||||
$obj = new ModelData();
|
||||
$obj->InsertedLink = DBField::create_field(
|
||||
'HTMLFragment',
|
||||
'<a class="inserted" href="#anchor">InsertedLink</a>'
|
||||
@ -2029,7 +2029,7 @@ after'
|
||||
</html>'
|
||||
);
|
||||
$tmpl = new SSViewer($tmplFile);
|
||||
$obj = new ViewableData();
|
||||
$obj = new ModelData();
|
||||
$obj->InsertedLink = DBField::create_field(
|
||||
'HTMLFragment',
|
||||
'<a class="inserted" href="#anchor">InsertedLink</a>'
|
||||
@ -2171,13 +2171,13 @@ EOC;
|
||||
|
||||
Requirements::set_backend($backend);
|
||||
|
||||
$this->assertEquals(1, substr_count($template->process(new ViewableData()) ?? '', "a.css"));
|
||||
$this->assertEquals(1, substr_count($template->process(new ViewableData()) ?? '', "b.css"));
|
||||
$this->assertEquals(1, substr_count($template->process(new ModelData()) ?? '', "a.css"));
|
||||
$this->assertEquals(1, substr_count($template->process(new ModelData()) ?? '', "b.css"));
|
||||
|
||||
// if we disable the requirements then we should get nothing
|
||||
$template->includeRequirements(false);
|
||||
$this->assertEquals(0, substr_count($template->process(new ViewableData()) ?? '', "a.css"));
|
||||
$this->assertEquals(0, substr_count($template->process(new ViewableData()) ?? '', "b.css"));
|
||||
$this->assertEquals(0, substr_count($template->process(new ModelData()) ?? '', "a.css"));
|
||||
$this->assertEquals(0, substr_count($template->process(new ModelData()) ?? '', "b.css"));
|
||||
}
|
||||
|
||||
public function testRequireCallInTemplateInclude()
|
||||
@ -2190,7 +2190,7 @@ EOC;
|
||||
$this->assertEquals(
|
||||
1,
|
||||
substr_count(
|
||||
$template->process(new ViewableData()) ?? '',
|
||||
$template->process(new ModelData()) ?? '',
|
||||
"tests/php/View/SSViewerTest/javascript/RequirementsTest_a.js"
|
||||
)
|
||||
);
|
||||
|
@ -3,11 +3,11 @@
|
||||
namespace SilverStripe\View\Tests\SSViewerTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class CacheTestData extends ViewableData implements TestOnly
|
||||
class CacheTestData extends ModelData implements TestOnly
|
||||
{
|
||||
|
||||
public $testWithCalls = 0;
|
||||
|
@ -3,10 +3,10 @@
|
||||
namespace SilverStripe\View\Tests\SSViewerTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
class LevelTestData extends ViewableData implements TestOnly
|
||||
class LevelTestData extends ModelData implements TestOnly
|
||||
{
|
||||
protected $depth;
|
||||
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
namespace SilverStripe\View\Tests\SSViewerTest;
|
||||
|
||||
use SilverStripe\ORM\ArrayList;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\List\ArrayList;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* A test fixture that will echo back the template item
|
||||
*/
|
||||
class TestFixture extends ViewableData
|
||||
class TestFixture extends ModelData
|
||||
{
|
||||
protected $name;
|
||||
|
||||
@ -45,7 +45,7 @@ class TestFixture extends ViewableData
|
||||
return $output;
|
||||
} else {
|
||||
if (preg_match('/NotSet/i', $fieldName ?? '')) {
|
||||
return new ViewableData();
|
||||
return new ModelData();
|
||||
} else {
|
||||
return new TestFixture($childName);
|
||||
}
|
||||
|
@ -3,13 +3,13 @@
|
||||
namespace SilverStripe\View\Tests\SSViewerTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
|
||||
/**
|
||||
* @property string $TextValue
|
||||
* @property string $HTMLValue
|
||||
*/
|
||||
class TestViewableData extends ViewableData implements TestOnly
|
||||
class TestModelData extends ModelData implements TestOnly
|
||||
{
|
||||
|
||||
private static $default_cast = 'Text';
|
||||
|
@ -1,55 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests;
|
||||
|
||||
use SilverStripe\Dev\Constraint\ViewableDataContains;
|
||||
use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\View\ViewableData_Customised;
|
||||
|
||||
/**
|
||||
* Test for ViewableData_Customised.
|
||||
*/
|
||||
class ViewableDataCustomisedTest extends SapphireTest
|
||||
{
|
||||
public function testNestedViewableDataCustomisedAsCustomised()
|
||||
{
|
||||
$outerCustomised = ViewableData_Customised::create($this->makeOuterOriginal(), $this->makeInnerViewableDataCustomised());
|
||||
$this->assertThat($outerCustomised, $this->makeTestConstraint());
|
||||
}
|
||||
|
||||
public function testNestedViewableDataCustomisedAsOriginal()
|
||||
{
|
||||
$outerCustomised = ViewableData_Customised::create($this->makeInnerViewableDataCustomised(), $this->makeOuterOriginal());
|
||||
$this->assertThat($outerCustomised, $this->makeTestConstraint());
|
||||
}
|
||||
|
||||
private function makeTestConstraint()
|
||||
{
|
||||
return new ViewableDataContains([
|
||||
'outerOriginal' => 'foobar',
|
||||
'innerOriginal' => 'hello',
|
||||
'innerCustomised' => 'world',
|
||||
]);
|
||||
}
|
||||
|
||||
private function makeOuterOriginal()
|
||||
{
|
||||
return ArrayData::create([
|
||||
'outerOriginal' => 'foobar',
|
||||
]);
|
||||
}
|
||||
|
||||
private function makeInnerViewableDataCustomised()
|
||||
{
|
||||
$original = ArrayData::create([
|
||||
'innerOriginal' => 'hello',
|
||||
]);
|
||||
|
||||
$customised = ArrayData::create([
|
||||
'innerCustomised' => 'world',
|
||||
]);
|
||||
|
||||
return ViewableData_Customised::create($original, $customised);
|
||||
}
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
|
||||
class Cached extends ViewableData implements TestOnly
|
||||
{
|
||||
public $Test;
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
|
||||
class Container extends ViewableData implements TestOnly
|
||||
{
|
||||
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
|
||||
class Failover extends ViewableData implements TestOnly
|
||||
{
|
||||
public function testMethod()
|
||||
{
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace SilverStripe\View\Tests\ViewableDataTest;
|
||||
|
||||
use SilverStripe\Dev\TestOnly;
|
||||
use SilverStripe\View\ViewableData;
|
||||
|
||||
class NoCastingInformation extends ViewableData implements TestOnly
|
||||
{
|
||||
public function noCastingInformation()
|
||||
{
|
||||
return "No casting information";
|
||||
}
|
||||
}
|
@ -10,7 +10,7 @@ use SilverStripe\Dev\SapphireTest;
|
||||
use SilverStripe\i18n\i18n;
|
||||
use SilverStripe\i18n\Messages\MessageProvider;
|
||||
use SilverStripe\i18n\Messages\Symfony\SymfonyMessageProvider;
|
||||
use SilverStripe\View\ArrayData;
|
||||
use SilverStripe\Model\ArrayData;
|
||||
use SilverStripe\View\SSViewer;
|
||||
use PHPUnit\Framework\Attributes\DataProvider;
|
||||
|
||||
|
@ -20,7 +20,7 @@ use SilverStripe\View\SSViewer;
|
||||
use SilverStripe\View\SSViewer_DataPresenter;
|
||||
use SilverStripe\View\ThemeResourceLoader;
|
||||
use SilverStripe\View\ThemeManifest;
|
||||
use SilverStripe\View\ViewableData;
|
||||
use SilverStripe\Model\ModelData;
|
||||
use Symfony\Component\Translation\Loader\ArrayLoader;
|
||||
use Symfony\Component\Translation\Translator;
|
||||
|
||||
@ -73,7 +73,7 @@ trait i18nTestManifest
|
||||
{
|
||||
// force SSViewer_DataPresenter to cache global template vars before we switch to the
|
||||
// test-project class manifest (since it will lose visibility of core classes)
|
||||
$presenter = new SSViewer_DataPresenter(new ViewableData());
|
||||
$presenter = new SSViewer_DataPresenter(new ModelData());
|
||||
unset($presenter);
|
||||
|
||||
// Switch to test manifest
|
||||
|
Loading…
Reference in New Issue
Block a user