Skip to content

Commit 8b76ab8

Browse files
authored
Update access level for types that will go into WordPressData – Round 2 (#24348)
* Update access level for types that will go into WordPressData All the changes are extracted from the "work bench" work from #24242 with the goal of reducing that PRs diff size to make it easier to review and identify errors. * Fix (?) `NullBlogPropertySanitizer` compilation * Update access level for more types that will go into WordPressData
1 parent 8cc7912 commit 8b76ab8

File tree

54 files changed

+222
-216
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+222
-216
lines changed

WordPress/Classes/Extensions/NSManagedObject.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import CoreData
22

3-
extension NSManagedObject {
3+
public extension NSManagedObject {
44
func setRawValue<ValueType: RawRepresentable>(_ value: ValueType?, forKey key: String) {
55
willChangeValue(forKey: key)
66
setPrimitiveValue(value?.rawValue, forKey: key)

WordPress/Classes/Jetpack/Utility/SharedDataIssueSolver.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import WordPressShared
22
import BuildSettingsKit
33

44
@objcMembers
5-
final class SharedDataIssueSolver: NSObject {
5+
public final class SharedDataIssueSolver: NSObject {
66

77
private let contextManager: CoreDataStack
88
private let keychainUtils: KeychainUtils
99
private let sharedDefaults: UserPersistentRepository?
1010
private let localFileStore: LocalFileStore
1111
private let appGroupName: String
1212

13-
init(contextManager: CoreDataStack = ContextManager.shared,
13+
public init(contextManager: CoreDataStack = ContextManager.shared,
1414
keychainUtils: KeychainUtils = KeychainUtils(),
1515
sharedDefaults: UserPersistentRepository? = UserDefaults(suiteName: BuildSettings.current.appGroupName),
1616
localFileStore: LocalFileStore = FileManager.default,
@@ -28,7 +28,7 @@ final class SharedDataIssueSolver: NSObject {
2828
return SharedDataIssueSolver()
2929
}
3030

31-
func migrateAuthKey() {
31+
public func migrateAuthKey() {
3232
guard let account = try? WPAccount.lookupDefaultWordPressComAccount(in: contextManager.mainContext),
3333
let username = account.username else {
3434
return
@@ -40,7 +40,7 @@ final class SharedDataIssueSolver: NSObject {
4040
/// To be safe, the method only "migrates" the data when the user is logged in, and there's a good chance that
4141
/// both apps are logged in with the same account.
4242
///
43-
func migrateAuthKey(for username: String) {
43+
public func migrateAuthKey(for username: String) {
4444
guard AppConfiguration.isJetpack,
4545
let token = try? keychainUtils.getPassword(for: username, serviceName: WPAccountConstants.authToken.rawValue) else {
4646
return
@@ -60,7 +60,7 @@ final class SharedDataIssueSolver: NSObject {
6060
updateExisting: true)
6161
}
6262

63-
func migrateExtensionsData() {
63+
public func migrateExtensionsData() {
6464
copyTodayWidgetDataToJetpack()
6565
copyShareExtensionDataToJetpack()
6666
}

WordPress/Classes/Models/AbstractPost.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import Foundation
2+
import WordPressKit
23
import WordPressShared
34

4-
extension AbstractPost {
5+
public extension AbstractPost {
56
/// Returns the original post by navigating the entire list of revisions
67
/// until it reaches the head.
78
func original() -> AbstractPost {
@@ -106,7 +107,7 @@ extension AbstractPost {
106107

107108
/// The keyPath to access the underlying property.
108109
///
109-
var keyPath: String {
110+
public var keyPath: String {
110111
switch self {
111112
case .dateCreated:
112113
return #keyPath(AbstractPost.date_created_gmt)
@@ -140,7 +141,7 @@ extension AbstractPost {
140141
}
141142
}
142143

143-
@objc override open func featuredImageURLForDisplay() -> URL? {
144+
@objc override func featuredImageURLForDisplay() -> URL? {
144145
return featuredImageURL
145146
}
146147

WordPress/Classes/Models/Account Settings/ManagedAccountSettings+CoreDataProperties.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import CoreData
33

44
// MARK: - Encapsulates all of the ManagedAccountSettings Core Data properties.
55
//
6-
extension ManagedAccountSettings {
6+
public extension ManagedAccountSettings {
77
@NSManaged var firstName: String
88
@NSManaged var lastName: String
99
@NSManaged var displayName: String

WordPress/Classes/Models/Account Settings/ManagedAccountSettings.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import WordPressKit
44

55
// MARK: - Reflects the user's Account Settings, as stored in Core Data.
66
//
7-
class ManagedAccountSettings: NSManagedObject {
7+
public class ManagedAccountSettings: NSManagedObject {
88

99
// MARK: - NSManagedObject
1010

11-
override class func entityName() -> String {
11+
public override class func entityName() -> String {
1212
return "AccountSettings"
1313
}
1414

15-
func updateWith(_ accountSettings: AccountSettings) {
15+
public func updateWith(_ accountSettings: AccountSettings) {
1616
firstName = accountSettings.firstName
1717
lastName = accountSettings.lastName
1818
displayName = accountSettings.displayName
@@ -38,7 +38,7 @@ class ManagedAccountSettings: NSManagedObject {
3838
///
3939
/// - Returns: the change object needed to revert this change
4040
///
41-
func applyChange(_ change: AccountSettingsChange) -> AccountSettingsChange {
41+
public func applyChange(_ change: AccountSettingsChange) -> AccountSettingsChange {
4242
let reverse = reverseChange(change)
4343

4444
switch change {
@@ -95,7 +95,7 @@ class ManagedAccountSettings: NSManagedObject {
9595
}
9696
}
9797

98-
extension AccountSettings {
98+
public extension AccountSettings {
9999
init(managed: ManagedAccountSettings) {
100100
self.init(firstName: managed.firstName.stringByDecodingXMLCharacters(),
101101
lastName: managed.lastName.stringByDecodingXMLCharacters(),

WordPress/Classes/Models/Blog/Blog+Capabilities.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ extension Blog {
8484
///
8585
/// - Returns: Whether site management is permitted
8686
///
87-
@objc func supportsSiteManagementServices() -> Bool {
87+
@objc public func supportsSiteManagementServices() -> Bool {
8888
return isHostedAtWPcom && isAdmin
8989
}
9090
}

WordPress/Classes/Models/BloggingPrompt+CoreDataClass.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class BloggingPrompt: NSManagedObject {
1717
self.displayAvatarURLs = []
1818
}
1919

20-
var promptAttribution: BloggingPromptsAttribution? {
20+
public var promptAttribution: BloggingPromptsAttribution? {
2121
BloggingPromptsAttribution(rawValue: attribution.lowercased())
2222
}
2323

@@ -26,7 +26,7 @@ public class BloggingPrompt: NSManagedObject {
2626
/// - Parameters:
2727
/// - remotePrompt: The remote prompt model to convert
2828
/// - siteID: The ID of the site that the prompt is intended for
29-
func configure(with remotePrompt: BloggingPromptRemoteObject, for siteID: Int32) {
29+
public func configure(with remotePrompt: BloggingPromptRemoteObject, for siteID: Int32) {
3030
self.promptID = Int32(remotePrompt.promptID)
3131
self.siteID = siteID
3232
self.text = remotePrompt.text
@@ -42,7 +42,7 @@ public class BloggingPrompt: NSManagedObject {
4242
}
4343
}
4444

45-
func textForDisplay() -> String {
45+
public func textForDisplay() -> String {
4646
return text.stringByDecodingXMLCharacters().trim()
4747
}
4848

@@ -54,24 +54,24 @@ public class BloggingPrompt: NSManagedObject {
5454
/// - Parameters:
5555
/// - localDate: The date to compare against in local timezone.
5656
/// - Returns: True if the year, month, and day components of the `localDate` matches the prompt's localized date.
57-
func inSameDay(as dateToCompare: Date) -> Bool {
57+
public func inSameDay(as dateToCompare: Date) -> Bool {
5858
return DateFormatters.utc.string(from: date) == DateFormatters.local.string(from: dateToCompare)
5959
}
6060

6161
/// Used for comparison on upsert – there can't be two `BloggingPrompt` objects with the same date, so we can use it as a unique identifier
6262
@objc
63-
var dateString: String {
63+
public var dateString: String {
6464
DateFormatters.local.string(from: date)
6565
}
6666
}
6767

6868
// MARK: - Notification Payload
6969

70-
extension BloggingPrompt {
70+
public extension BloggingPrompt {
7171

7272
struct NotificationKeys {
73-
static let promptID = "prompt_id"
74-
static let siteID = "site_id"
73+
public static let promptID = "prompt_id"
74+
public static let siteID = "site_id"
7575
}
7676

7777
}

WordPress/Classes/Models/BloggingPromptSettings+CoreDataClass.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import WordPressKit
44

55
public class BloggingPromptSettings: NSManagedObject {
66

7-
static func of(_ blog: Blog) throws -> BloggingPromptSettings? {
7+
public static func of(_ blog: Blog) throws -> BloggingPromptSettings? {
88
guard let context = blog.managedObjectContext else { return nil }
99

1010
// This getting site id logic is copied from the BloggingPromptsService initializer.
@@ -20,14 +20,14 @@ public class BloggingPromptSettings: NSManagedObject {
2020
return try lookup(withSiteID: siteID, in: context)
2121
}
2222

23-
static func lookup(withSiteID siteID: NSNumber, in context: NSManagedObjectContext) throws -> BloggingPromptSettings? {
23+
public static func lookup(withSiteID siteID: NSNumber, in context: NSManagedObjectContext) throws -> BloggingPromptSettings? {
2424
let fetchRequest = BloggingPromptSettings.fetchRequest()
2525
fetchRequest.predicate = NSPredicate(format: "\(#keyPath(BloggingPromptSettings.siteID)) = %@", siteID)
2626
fetchRequest.fetchLimit = 1
2727
return try context.fetch(fetchRequest).first
2828
}
2929

30-
func reminderTimeDate() -> Date? {
30+
public func reminderTimeDate() -> Date? {
3131
guard let reminderTime else {
3232
return nil
3333
}
@@ -37,7 +37,7 @@ public class BloggingPromptSettings: NSManagedObject {
3737
}
3838
}
3939

40-
extension RemoteBloggingPromptsSettings {
40+
public extension RemoteBloggingPromptsSettings {
4141

4242
init(with model: BloggingPromptSettings) {
4343
self.init(promptCardEnabled: model.promptCardEnabled,

WordPress/Classes/Models/BloggingPromptSettingsReminderDays+CoreDataClass.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import WordPressKit
44

55
public class BloggingPromptSettingsReminderDays: NSManagedObject {
66

7-
func configure(with remoteReminderDays: RemoteBloggingPromptsSettings.ReminderDays) {
7+
public func configure(with remoteReminderDays: RemoteBloggingPromptsSettings.ReminderDays) {
88
self.monday = remoteReminderDays.monday
99
self.tuesday = remoteReminderDays.tuesday
1010
self.wednesday = remoteReminderDays.wednesday

WordPress/Classes/Models/Comment/Comment+CoreDataClass.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,19 @@ import CoreData
44
@objc(Comment)
55
public class Comment: NSManagedObject {
66

7-
@objc static func descriptionFor(_ commentStatus: CommentStatusType) -> String {
7+
@objc public static func descriptionFor(_ commentStatus: CommentStatusType) -> String {
88
return commentStatus.description
99
}
1010

11-
@objc func authorUrlForDisplay() -> String {
11+
@objc public func authorUrlForDisplay() -> String {
1212
return authorURL()?.host ?? String()
1313
}
1414

15-
@objc func contentForEdit() -> String {
15+
@objc public func contentForEdit() -> String {
1616
return availableContent()
1717
}
1818

19-
@objc func isApproved() -> Bool {
19+
@objc public func isApproved() -> Bool {
2020
return status == CommentStatusType.approved.description
2121
}
2222

@@ -31,7 +31,7 @@ public class Comment: NSManagedObject {
3131

3232
// This can be removed when `unifiedCommentsAndNotificationsList` is permanently enabled
3333
// as it's replaced by Comment+Interface:relativeDateSectionIdentifier.
34-
@objc func sectionIdentifier() -> String? {
34+
@objc public func sectionIdentifier() -> String? {
3535
guard let dateCreated else {
3636
return nil
3737
}
@@ -42,30 +42,30 @@ public class Comment: NSManagedObject {
4242
return formatter.string(from: dateCreated)
4343
}
4444

45-
@objc func commentURL() -> URL? {
45+
@objc public func commentURL() -> URL? {
4646
guard !link.isEmpty else {
4747
return nil
4848
}
4949

5050
return URL(string: link)
5151
}
5252

53-
@objc func deleteWillBePermanent() -> Bool {
53+
@objc public func deleteWillBePermanent() -> Bool {
5454
return status == Comment.descriptionFor(.spam) || status == Comment.descriptionFor(.unapproved)
5555
}
5656

57-
func canEditAuthorData() -> Bool {
57+
public func canEditAuthorData() -> Bool {
5858
// If the authorID is zero, the user is unregistered. Therefore, the data can be edited.
5959
return authorID == 0
6060
}
6161

62-
func hasParentComment() -> Bool {
62+
public func hasParentComment() -> Bool {
6363
return parentID > 0
6464
}
6565

6666
/// Convenience method to check if the current user can actually moderate.
6767
/// `canModerate` is only applicable when the site is dotcom-related (hosted or atomic). For self-hosted sites, default to true.
68-
@objc func allowsModeration() -> Bool {
68+
@objc public func allowsModeration() -> Bool {
6969
if let _ = post as? ReaderPost {
7070
return canModerate
7171
}
@@ -76,15 +76,15 @@ public class Comment: NSManagedObject {
7676
return canModerate
7777
}
7878

79-
func canReply() -> Bool {
79+
public func canReply() -> Bool {
8080
if let post = post as? ReaderPost {
8181
return post.commentsOpen
8282
}
8383
return !isReadOnly()
8484
}
8585

8686
// NOTE: Comment Likes could be disabled, but the API doesn't have that info yet. Let's update this once it's available.
87-
func canLike() -> Bool {
87+
public func canLike() -> Bool {
8888
if (post as? ReaderPost) != nil {
8989
return true
9090
}
@@ -95,11 +95,11 @@ public class Comment: NSManagedObject {
9595
return !isReadOnly() && blog.supports(.commentLikes)
9696
}
9797

98-
@objc func isTopLevelComment() -> Bool {
98+
@objc public func isTopLevelComment() -> Bool {
9999
return depth == 0
100100
}
101101

102-
func isFromPostAuthor() -> Bool {
102+
public func isFromPostAuthor() -> Bool {
103103
guard let postAuthorID = post?.authorID?.int32Value,
104104
postAuthorID > 0,
105105
authorID > 0 else {
@@ -181,7 +181,7 @@ extension Comment: PostContentProvider {
181181
}
182182

183183
// When CommentViewController and CommentService are converted to Swift, this can be simplified to a String enum.
184-
@objc enum CommentStatusType: Int {
184+
@objc public enum CommentStatusType: Int {
185185
case pending
186186
case approved
187187
case unapproved
@@ -190,7 +190,7 @@ extension Comment: PostContentProvider {
190190
// We can use this status to restore comment replies that the user has written.
191191
case draft
192192

193-
var description: String {
193+
public var description: String {
194194
switch self {
195195
case .pending:
196196
return "hold"
@@ -205,7 +205,7 @@ extension Comment: PostContentProvider {
205205
}
206206
}
207207

208-
static func typeForStatus(_ status: String?) -> CommentStatusType? {
208+
public static func typeForStatus(_ status: String?) -> CommentStatusType? {
209209
switch status {
210210
case "hold":
211211
return .pending

0 commit comments

Comments
 (0)