Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API Strong typing for the view layer #634

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

GuySartorelli
Copy link
Member

I want a good base of known types for things that will be going into the template layer before I start abstracting it, and this gets me part of the way there.

Issue

Comment on lines +66 to +84
private static array $composite_db = [
"Hash" => "Varchar(255)", // SHA of the base content
"Filename" => "Varchar(255)", // Path identifier of the base content
"Variant" => "Varchar(255)", // Identifier of the variant to the base, if given
];

private static array $casting = [
'URL' => 'Varchar',
'AbsoluteURL' => 'Varchar',
'Basename' => 'Varchar',
'Title' => 'Varchar',
'MimeType' => 'Varchar',
'String' => 'Text',
'Tag' => 'HTMLFragment',
'getTag' => 'HTMLFragment',
'Size' => 'Varchar',
'AttributesHTML' => 'HTMLFragment',
'getAttributesHTML' => 'HTMLFragment',
];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These have just been moved from below, so they're not buried below methods.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are methods in this class I have intentionally not added strict typing for, because they're defined in interfaces or are calling other code that isn't strongly typed, and I didn't want this PR to stretch tooo far beyond the goal of cleaning up the view layer.

@GuySartorelli GuySartorelli marked this pull request as draft August 22, 2024 21:38
@GuySartorelli GuySartorelli marked this pull request as ready for review August 26, 2024 02:26
@emteknetnz emteknetnz merged commit 1e8c034 into silverstripe:3 Aug 27, 2024
5 of 8 checks passed
@emteknetnz emteknetnz deleted the pulls/3/strong-typing branch August 27, 2024 22:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants