Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
fixes #44
Browse files Browse the repository at this point in the history
  • Loading branch information
cdowdy committed Sep 14, 2017
1 parent 8dd5a85 commit 20837d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 25 deletions.
2 changes: 1 addition & 1 deletion src/BetterThumbsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ protected function registerBackendControllers()
{
$config = $this->getConfig();

if ( Version::compare('3.3.0', '>=')) {
if ( version_compare( Version::VERSION , '3.3.0', '>=' ) ) {
return [
'/extensions/betterthumbs' => new BetterThumbsBackendController( $config ),
];
Expand Down
12 changes: 1 addition & 11 deletions src/Controller/BetterThumbsBackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ public function buildProperExtensionPath(Application $app )
$urlGenerator = $app['url_generator'];
$dashboardRoute = $urlGenerator->generate( 'dashboard' );

if (Version::compare('3.3.0', '>=')) {
if ( version_compare( Version::VERSION , '3.3.0', '>=' ) ) {
$extensionsRoute = 'extensions';
} else {
$extensionsRoute = 'extend';
Expand Down Expand Up @@ -492,17 +492,7 @@ protected function listFileSystemPaths( $paths )
*/
private function fsSetup( Application $app )
{
// for bolt's new filesystem since $app['resources'] and getPath() are deprecated in 3.3+
// and will be removed in 4.0

// if (Version::compare( '3.3.0', '>=')) {
// $boltFilesPath = $app['path_resolver']->resolve('files');
// } else {
// $boltFilesPath = $app['resources']->getPath( 'filespath' );
//
// }

// $boltFilesPath = $this->boltFilesPath($app);
$boltFilesPath = (new FilePathHelper( $app ) )->boltFilesPath() ;

$adapter = new Local( $boltFilesPath );
Expand Down
20 changes: 7 additions & 13 deletions src/Helpers/FilePathHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FilePathHelper
* FilePathHelper constructor.
* @param Application $app
*/
public function __construct(Application $app )
public function __construct(Application $app)
{
$this->app = $app;
}
Expand All @@ -31,20 +31,14 @@ public function __construct(Application $app )
* Get Bolt's Files path
* @return mixed
*
* The version is "reversed" from what you would logically use..
* instead of 'this version is greater than or equal too 3.3.0'
* we have to think ok the current bolt version is less than the one we are comparing
*
* example: bolt version 3.2.14 is less than 3.3.0 so
* Version::compare( '3.3.0', '>=') would need to use resources not path_resolver
* Use PHP's version_compare instead of bolts Version::compare since it's "broken"
*/
public function boltFilesPath()
{
if (Version::compare( '3.3.0', '>=')) {
return $this->app['resources']->getPath( 'filespath' );
} else {
if (version_compare(Version::VERSION, '3.3.0', '>=')) {
return $this->app['path_resolver']->resolve('files');

} else {
return $this->app['resources']->getPath('filespath');
}
}

Expand All @@ -54,10 +48,10 @@ public function boltFilesPath()
*/
public function boltExtensionsPath()
{
if (Version::compare( '3.3.0', '>=')) {
if (version_compare(Version::VERSION, '3.3.0', '>=')) {
return $this->app['path_resolver']->resolve('extensions');
} else {
return $this->app['resources']->getPath( 'extensions' );
return $this->app['resources']->getPath('extensions');

}
}
Expand Down

0 comments on commit 20837d6

Please sign in to comment.