Skip to content

Commit

Permalink
Merge pull request #6 from Zuluru/master
Browse files Browse the repository at this point in the history
Improve Cake 4.3 compatibility
  • Loading branch information
anuj9196 authored Jun 1, 2024
2 parents 33ccc5b + c121ca4 commit 523e49f
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 11 deletions.
4 changes: 3 additions & 1 deletion config/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
/**
* Path constants
*/
define('PLUGIN_CONFIG', dirname(__DIR__) . DS . 'config' .DS);
if (!defined('PLUGIN_CONFIG')) {
define('PLUGIN_CONFIG', dirname(__DIR__) . DS . 'config' .DS);
}
/**
* Database installation variable
* if set to TRUE, the database is installed
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/AppController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@

class AppController extends BaseController
{
public function beforeRender(EventInterface $event)
public function beforeRender(EventInterface $event): void
{
try {
return parent::beforeRender($event);
parent::beforeRender($event);
} finally {
$this->viewBuilder()->setTheme(null);
}
Expand Down
11 changes: 6 additions & 5 deletions src/Controller/InstallController.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class InstallController extends AppController
* @return void
* @throws \Exception
*/
public function beforeFilter(EventInterface $event)
public function beforeFilter(EventInterface $event): void
{
parent::beforeFilter($event);
$this->loadComponent('Auth');
Expand Down Expand Up @@ -56,7 +56,7 @@ protected function _check()
if (Configure::read('Database.installed')) {
$this->Flash->success(__('Website already configured'));
// Removing redirect to allow user to re-configure application manually
// $this->redirect('/');
// return $this->redirect('/');
}
}

Expand All @@ -75,6 +75,7 @@ public function connection()
if ($this->request->is('post')) {
// Loads post form data
$data = $this->request->getData();
unset($data['_Token']);

// Check if import_database is checked
$import_database = $this->request->getData('import_database') || Configure::read('Installer.Import.migrations');
Expand Down Expand Up @@ -179,9 +180,9 @@ public function connection()

// Import database if import_database is checked
if ($import_database) {
$this->redirect(['action' => 'data']);
return $this->redirect(['action' => 'data']);
} else {
$this->redirect(['action' => 'finish']);
return $this->redirect(['action' => 'finish']);
}
} else {
// Remove any config files that were written successfully, so that we try them again next time.
Expand Down Expand Up @@ -218,7 +219,7 @@ public function data()

if ($this->request->is('post') && $this->_importSchema($db) && $this->_handleMigrations()) {
$this->Flash->success(__('Database imported'));
$this->redirect(['action' => 'finish']);
return $this->redirect(['action' => 'finish']);
}
} catch (Exception $connectionError) {
$this->set(['database_connect' => false]);
Expand Down
13 changes: 13 additions & 0 deletions src/Plugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
declare(strict_types=1);

namespace CakePHPAppInstaller;

use Cake\Core\BasePlugin;

/**
* Plugin class for CakePHP.
*/
class Plugin extends BasePlugin
{
}
6 changes: 3 additions & 3 deletions templates/Install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,15 @@
?>

<?php
if (version_compare(PHP_VERSION, '5.6.0') < 0) {
if (version_compare(PHP_VERSION, '7.4.0') < 0) {
$check = false;
$class = 'danger';
$glyphicon = 'remove';
$message = __('Your PHP version must be equal or higher than 5.6.0 to use CakePHP (' . PHP_VERSION . ')');
$message = __('Your PHP version must be equal or higher than 7.4.0 to use CakePHP (' . PHP_VERSION . ')');
} else {
$class = 'success';
$glyphicon = 'ok';
$message = __('Your PHP version is equal or higher than 5.6.0 to use CakePHP (' . PHP_VERSION . ')');
$message = __('Your PHP version is equal or higher than 7.4.0 to use CakePHP (' . PHP_VERSION . ')');
}

echo '<div class="alert alert-' . $class . '"><span class="glyphicon glyphicon-' . $glyphicon . '"></span> ' . $message . '</div>';
Expand Down

0 comments on commit 523e49f

Please sign in to comment.