diff --git a/code/Forms/AssetFormFactory.php b/code/Forms/AssetFormFactory.php index 7b3c68e77..1b0a7f267 100644 --- a/code/Forms/AssetFormFactory.php +++ b/code/Forms/AssetFormFactory.php @@ -92,7 +92,7 @@ public function getForm(RequestHandler $controller = null, $name = FormFactory:: $form->loadDataFrom($record); // Mark as readonly for some types - if ($this->getFormType($context) === self::TYPE_ADMIN && !$record->canEdit()) { + if ($this->getFormType($context) === AssetFormFactory::TYPE_ADMIN && !$record->canEdit()) { $form->makeReadonly(); } } @@ -242,7 +242,7 @@ protected function getFormFields(RequestHandler $controller = null, $formName, $ ->setRecordID($record->ID) ->addExtraClass('editor__file-preview'); - if ($this->getFormType($context) !== self::TYPE_ADMIN) { + if ($this->getFormType($context) !== AssetFormFactory::TYPE_ADMIN) { $previewField->performReadonlyTransformation(); } diff --git a/code/Forms/MoveFormFactory.php b/code/Forms/MoveFormFactory.php index 8488ca13d..42bdb3b0a 100644 --- a/code/Forms/MoveFormFactory.php +++ b/code/Forms/MoveFormFactory.php @@ -15,7 +15,7 @@ class MoveFormFactory implements FormFactory { use Extensible; - public function getForm(RequestHandler $controller = null, $name = self::DEFAULT_NAME, $context = []) + public function getForm(RequestHandler $controller = null, $name = MoveFormFactory::DEFAULT_NAME, $context = []) { $form = Form::create( $controller, diff --git a/code/Forms/RemoteFileFormFactory.php b/code/Forms/RemoteFileFormFactory.php index 1020149c2..8cc3070ce 100644 --- a/code/Forms/RemoteFileFormFactory.php +++ b/code/Forms/RemoteFileFormFactory.php @@ -92,7 +92,7 @@ class RemoteFileFormFactory implements FormFactory * @param array $context * @return Form */ - public function getForm(RequestHandler $controller = null, $name = self::DEFAULT_NAME, $context = []) + public function getForm(RequestHandler $controller = null, $name = RemoteFileFormFactory::DEFAULT_NAME, $context = []) { // Allow form to be disabled if (!static::config()->get('enabled')) { @@ -316,8 +316,8 @@ protected function getEditFormFields($context) protected function validateURLScheme($url) { $scheme = strtolower(parse_url($url ?? '', PHP_URL_SCHEME) ?? ''); - $allowedSchemes = self::config()->get('fileurl_scheme_whitelist'); - $disallowedSchemes = self::config()->get('fileurl_scheme_blacklist'); + $allowedSchemes = static::config()->get('fileurl_scheme_whitelist'); + $disallowedSchemes = static::config()->get('fileurl_scheme_blacklist'); if (!$scheme || ($allowedSchemes && !in_array($scheme, $allowedSchemes ?? [])) || ($disallowedSchemes && in_array($scheme, $disallowedSchemes ?? [])) @@ -336,8 +336,8 @@ protected function validateURLScheme($url) protected function validateURLHost($url) { $domain = strtolower(parse_url($url ?? '', PHP_URL_HOST) ?? ''); - $allowedDomains = self::config()->get('fileurl_domain_whitelist'); - $disallowedDomains = self::config()->get('fileurl_domain_blacklist'); + $allowedDomains = static::config()->get('fileurl_domain_whitelist'); + $disallowedDomains = static::config()->get('fileurl_domain_blacklist'); if (!$domain || ($allowedDomains && !in_array($domain, $allowedDomains ?? [])) || ($disallowedDomains && in_array($domain, $disallowedDomains ?? [])) @@ -359,8 +359,8 @@ protected function validateURLPort($url) if (!$port) { return; } - $allowedPorts = self::config()->get('fileurl_port_whitelist'); - $disallowedPorts = self::config()->get('fileurl_port_blacklist'); + $allowedPorts = static::config()->get('fileurl_port_whitelist'); + $disallowedPorts = static::config()->get('fileurl_port_blacklist'); if (($allowedPorts && !in_array($port, $allowedPorts ?? [])) || ($disallowedPorts && in_array($port, $disallowedPorts ?? [])) ) { diff --git a/code/GraphQL/Resolvers/PublicationResolver.php b/code/GraphQL/Resolvers/PublicationResolver.php index 5454a894d..e7aa2f25a 100644 --- a/code/GraphQL/Resolvers/PublicationResolver.php +++ b/code/GraphQL/Resolvers/PublicationResolver.php @@ -19,12 +19,12 @@ class PublicationResolver public static function resolvePublishFiles(...$params) { - return self::resolvePublicationOperation(self::ACTION_PUBLISH, ...$params); + return PublicationResolver::resolvePublicationOperation(PublicationResolver::ACTION_PUBLISH, ...$params); } public static function resolveUnpublishFiles(...$params) { - return self::resolvePublicationOperation(self::ACTION_UNPUBLISH, ...$params); + return PublicationResolver::resolvePublicationOperation(PublicationResolver::ACTION_UNPUBLISH, ...$params); } /** @@ -45,7 +45,7 @@ private static function resolvePublicationOperation( if (!isset($args['ids']) || !is_array($args['ids'])) { throw new InvalidArgumentException('IDs must be an array'); } - $isPublish = $action === self::ACTION_PUBLISH; + $isPublish = $action === PublicationResolver::ACTION_PUBLISH; $sourceStage = $isPublish ? Versioned::DRAFT : Versioned::LIVE; $force = $args['force'] ?? false; $quiet = $args['quiet'] ?? false; @@ -87,8 +87,8 @@ private static function resolvePublicationOperation( foreach ($allowedFiles as $file) { $result[] = $isPublish - ? self::publishFile($file, $force) - : self::unpublishFile($file, $force); + ? PublicationResolver::publishFile($file, $force) + : PublicationResolver::unpublishFile($file, $force); } return $result; @@ -116,7 +116,7 @@ private static function unpublishFile(File $file, $force = false) { // If not forcing, make sure we aren't interfering with any owners if (!$force) { - $ownersCount = self::countLiveOwners($file); + $ownersCount = PublicationResolver::countLiveOwners($file); if ($ownersCount) { return new Notice( _t( diff --git a/code/Model/ThumbnailGenerator.php b/code/Model/ThumbnailGenerator.php index 66225b5b1..29dc6b2e9 100644 --- a/code/Model/ThumbnailGenerator.php +++ b/code/Model/ThumbnailGenerator.php @@ -55,8 +55,8 @@ class ThumbnailGenerator * @var array */ private static $thumbnail_links = [ - AssetStore::VISIBILITY_PROTECTED => self::INLINE, - AssetStore::VISIBILITY_PUBLIC => self::URL, + AssetStore::VISIBILITY_PROTECTED => ThumbnailGenerator::INLINE, + AssetStore::VISIBILITY_PUBLIC => ThumbnailGenerator::URL, ]; /** @@ -141,9 +141,9 @@ public function generateLink(AssetContainer $thumbnail = null) // Build thumbnail switch ($urlRule) { - case self::URL: + case ThumbnailGenerator::URL: return $thumbnail->getURL(); - case self::INLINE: + case ThumbnailGenerator::INLINE: // Generate inline content $base64 = base64_encode($thumbnail->getString() ?? ''); return sprintf( diff --git a/tests/php/Forms/FileFormBuilderTest/FileExtension.php b/tests/php/Forms/FileFormBuilderTest/FileExtension.php index 0b6633d02..89dbde036 100644 --- a/tests/php/Forms/FileFormBuilderTest/FileExtension.php +++ b/tests/php/Forms/FileFormBuilderTest/FileExtension.php @@ -19,21 +19,21 @@ class FileExtension extends DataExtension implements TestOnly public function canDelete($member) { - return self::$canDelete; + return FileExtension::$canDelete; } public function canPublish($member = null) { - return self::$canPublish; + return FileExtension::$canPublish; } public function canUnpublish($member = null) { - return self::$canUnpublish; + return FileExtension::$canUnpublish; } public function canEdit($member = null) { - return self::$canEdit; + return FileExtension::$canEdit; } } diff --git a/tests/php/Forms/RemoteFileFormFactoryTest/MockEmbed.php b/tests/php/Forms/RemoteFileFormFactoryTest/MockEmbed.php index ffaa3f1a8..663a2320b 100644 --- a/tests/php/Forms/RemoteFileFormFactoryTest/MockEmbed.php +++ b/tests/php/Forms/RemoteFileFormFactoryTest/MockEmbed.php @@ -69,7 +69,7 @@ public function getOptions() /** * @param array $options - * @return self + * @return MockEmbed */ public function setOptions(array $options) {