Skip to content

Commit

Permalink
Merge pull request #42 from creative-commoners/pulls/3.0/fix-images
Browse files Browse the repository at this point in the history
FIX Images now resolve correctly when project is installed in a subfolder
  • Loading branch information
NightJar authored Aug 23, 2019
2 parents 0c7227f + a1053ac commit 4aee2fa
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/Method.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,13 @@ public function getRegisterHandler(): RegisterHandlerInterface

public function getThumbnail(): string
{
$module = $this->getModuleName();
return "/$module/client/dist/images/totp.svg";
return Director::absoluteURL('totp-authenticator/client/dist/images/totp.svg');
}

public function applyRequirements(): void
{
$module = $this->getModuleName();
Requirements::javascript("$module/client/dist/js/bundle.js");
Requirements::css("$module/client/dist/styles/bundle.css");
Requirements::javascript('totp-authenticator/client/dist/js/bundle.js');
Requirements::css('totp-authenticator/client/dist/styles/bundle.css');
}

/**
Expand Down Expand Up @@ -81,16 +79,4 @@ public function getCodeLength(): int
{
return (int) $this->config()->get('code_length');
}

/**
* Get directory name this module is installed into
* SS3 is not specific or caring about what the module is named, only that it exists and is a valid SilverStripe
* mdoule.
*
* @return string
*/
private function getModuleName(): string
{
return basename(realpath(__DIR__ . DIRECTORY_SEPARATOR . '..'));
}
}

0 comments on commit 4aee2fa

Please sign in to comment.