Skip to content

Commit 9a1b4da

Browse files
committed
AdoRecordSet implements countable
1 parent 7f85c6a commit 9a1b4da

File tree

4 files changed

+35
-31
lines changed

4 files changed

+35
-31
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ temp/sessions/*
2424

2525
config.inc.php
2626
config.yml
27-
tests/_output
27+
tests/_output
28+
debug.*.php

src/classes/ADORecordSet.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
*
1919
* @package PHPPgAdmin
2020
*/
21-
class ADORecordSet extends \ADORecordSet
21+
class ADORecordSet extends \ADORecordSet implements \Countable
2222
{
23+
public function count()
24+
{
25+
return $this->recordCount();
26+
}
2327
}

src/classes/ContainerUtils.php

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22

33
/**
4-
* PHPPgAdmin v6.0.0-RC9
4+
* PHPPgAdmin v6.0.0-RC8
55
*/
66

77
namespace PHPPgAdmin;
@@ -82,24 +82,43 @@ public function __construct()
8282
$this->container = $container;
8383
}
8484

85-
public static function createContainer()
85+
public static function createContainer($conf)
8686
{
8787
if (!self::$instance) {
8888
self::$instance = new self();
8989
}
9090

91-
$display_sizes = $conf['display_sizes'] ?? false;
91+
// Complete missing conf keys
92+
self::$instance->container['conf'] = function ($c) use ($conf) {
93+
$display_sizes = $conf['display_sizes'] ?? false;
9294

93-
$conf['display_sizes'] = [
95+
$conf['display_sizes'] = [
9496
'schemas' => (bool) $display_sizes,
9597
'tables' => (bool) $display_sizes,
9698
];
97-
if (is_array($display_sizes)) {
98-
$conf['display_sizes'] = [
99+
if (is_array($display_sizes)) {
100+
$conf['display_sizes'] = [
99101
'schemas' => $display_sizes['schemas'] ?? in_array('schemas', $display_sizes, true),
100102
'tables' => $display_sizes['tables'] ?? in_array('tables', $display_sizes, true),
101103
];
102-
}
104+
}
105+
106+
// Plugins are removed
107+
$conf['plugins'] = [];
108+
if (!isset($conf['theme'])) {
109+
$conf['theme'] = 'default';
110+
}
111+
foreach ($conf['servers'] as &$server) {
112+
if (!isset($server['port'])) {
113+
$server['port'] = 5432;
114+
}
115+
if (!isset($server['sslmode'])) {
116+
$server['sslmode'] = 'unspecified';
117+
}
118+
}
119+
120+
return $conf;
121+
};
103122

104123
return [self::$instance->container, self::$instance->app];
105124
}

src/lib.inc.php

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
die('Your temp folder must have write permissions (use chmod 777 temp -R on linux)');
1616
}
1717
require_once BASE_PATH . '/vendor/autoload.php';
18+
1819
// Check to see if the configuration file exists, if not, explain
1920
if (file_exists(BASE_PATH . '/config.inc.php')) {
2021
$conf = [];
@@ -54,7 +55,7 @@
5455
}
5556

5657
// Fetch App and DI Container
57-
list($container, $app) = \PHPPgAdmin\ContainerUtils::createContainer();
58+
list($container, $app) = \PHPPgAdmin\ContainerUtils::createContainer($conf);
5859

5960
if ($container instanceof \Psr\Container\ContainerInterface) {
6061
if (PHP_SAPI == 'cli-server') {
@@ -82,27 +83,6 @@
8283
return new \Slim\Flash\Messages();
8384
};
8485

85-
// Complete missing conf keys
86-
$container['conf'] = function ($c) use ($conf) {
87-
88-
//\Kint::dump($conf);
89-
// Plugins are removed
90-
$conf['plugins'] = [];
91-
if (!isset($conf['theme'])) {
92-
$conf['theme'] = 'default';
93-
}
94-
foreach ($conf['servers'] as &$server) {
95-
if (!isset($server['port'])) {
96-
$server['port'] = 5432;
97-
}
98-
if (!isset($server['sslmode'])) {
99-
$server['sslmode'] = 'unspecified';
100-
}
101-
}
102-
103-
return $conf;
104-
};
105-
10686
$container['lang'] = function ($c) {
10787
$translations = new \PHPPgAdmin\Translations($c);
10888

0 commit comments

Comments
 (0)