Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Implementing support checks for databases and cache adapters on defau…

…lt home page.
  • Loading branch information...
commit 800d67cfcb7d2c72b4fa226081c48b10d3cb382f 1 parent b229031
@nateabele nateabele authored
Showing with 50 additions and 0 deletions.
  1. +43 −0 app/views/pages/home.html.php
  2. +7 −0 app/webroot/css/debug.css
View
43 app/views/pages/home.html.php
@@ -19,6 +19,22 @@
return $html;
};
+$support = function($classes) {
+ $result = '';
+
+ foreach ($classes as $class => $enabled) {
+ $name = substr($class, strrpos($class, '\\') + 1);
+ $url = 'http://lithify.me/docs/' . str_replace('\\', '/', $class);
+ $status = $enabled ? '✔' : '✘';
+ $enabled = $enabled ? ' enabled' : '';
+
+ $item = "<div class=\"indicator{$enabled}\">{$status}</div>";
+ $item .= "<a href=\"{$url}\">{$name}</a>";
+ $result .= "<p>{$item}</p>";
+ }
+ return $result;
+};
+
$checks = array(
'resourcesWritable' => function() use ($notify) {
if (is_writable($path = Libraries::get(true, 'resources'))) {
@@ -110,6 +126,33 @@
"Check the builtin {$dashboard} or {$tests} now to ensure Lithium
is working as expected. Do not hesitate to {$ticket} in case a test fails."
);
+ },
+ 'dbSupport' => function() use ($notify, $support) {
+ $paths = array('data.source', 'adapter.data.source.database', 'adapter.data.source.http');
+ $list = array();
+
+ foreach ($paths as $path) {
+ $list = array_merge($list, Libraries::locate($path, null, array('recursive' => false)));
+ }
+ $list = array_filter($list, function($class) { return method_exists($class, 'enabled'); });
+ $map = array_combine($list, array_map(function($c) { return $c::enabled(); }, $list));
+
+ return $notify(
+ 'notice',
+ 'Database support',
+ '<div class="test-result solution">' . $support($map) . '</div>'
+ );
+ },
+ 'cacheSupport' => function() use ($notify, $support) {
+ $list = Libraries::locate('adapter.storage.cache', null, array('recursive' => false));
+ $list = array_filter($list, function($class) { return method_exists($class, 'enabled'); });
+ $map = array_combine($list, array_map(function($c) { return $c::enabled(); }, $list));
+
+ return $notify(
+ 'notice',
+ 'Cache support',
+ '<div class="test-result solution">' . $support($map) . '</div>'
+ );
}
);
View
7 app/webroot/css/debug.css
@@ -601,3 +601,10 @@ div.code-coverage-results span.result-good {
list-style: none;
margin: 0;
}
+.app .indicator {
+ float: right;
+ color: #a00;
+}
+.app .indicator.enabled {
+ color: #0a0;
+}
Please sign in to comment.
Something went wrong with that request. Please try again.