Revert namespace checking and implement Injector aliases instead. Update readme.
This commit is contained in:
parent
431584f999
commit
3b0f54dc03
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
Name: environmentcheckinjector
|
||||
---
|
||||
SilverStripe\Core\Injector\Injector:
|
||||
DatabaseCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\DatabaseCheck
|
||||
ExternalURLCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\ExternalURLCheck
|
||||
FileAccessibilityAndValidationCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\FileAccessibilityAndValidationCheck
|
||||
FileAgeCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\FileAgeCheck
|
||||
FileWriteableCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\FileWriteableCheck
|
||||
HasClassCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\HasClassCheck
|
||||
HasFunctionCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\HasFunctionCheck
|
||||
SMTPConnectCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\SMTPConnectCheck
|
||||
SolrIndexCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\SolrIndexCheck
|
||||
URLCheck:
|
||||
class: SilverStripe\EnvironmentCheck\Checks\URLCheck
|
16
readme.md
16
readme.md
|
@ -40,17 +40,9 @@ Register checks in your own `_config.php` - see the `_config.php` in this module
|
|||
either use a fully-qualified (namespaced) class name for `EnvironmentCheckSuite`, or `use` (import) the namespaced class
|
||||
first.
|
||||
|
||||
You can omit the namespace for the actual check class name so long as the check is one that ships with this module. If
|
||||
you are referencing a check from a module other than this, you must ensure you add a namespace (even a `\` root namespace).
|
||||
|
||||
```php
|
||||
EnvironmentCheckSuite::register('health', 'DatabaseCheck', 'Can we connect to the database?');
|
||||
EnvironmentCheckSuite::register('check', 'URLCheck(')', 'Is the homepage accessible?');
|
||||
|
||||
// Add your own check (with no namespace)
|
||||
EnvironmentCheckSuite::register('check', '\\MyCustomCheck', 'No namespace in this check.');
|
||||
// Add your own check (with a specific namespace)
|
||||
EnvironmentCheckSuite::register('check', 'Your\\Module\\MyCustomCheck', 'Fully qualified to check things.');
|
||||
EnvironmentCheckSuite::register('check', 'URLCheck("")', 'Is the homepage accessible?');
|
||||
```
|
||||
|
||||
### Activating Via Config
|
||||
|
@ -180,9 +172,8 @@ class MyGatewayCheck implements EnvironmentCheck
|
|||
return array(EnvironmentCheck::ERROR, "MyGateway didn't return a response");
|
||||
} else if($response != $expectedResponse) {
|
||||
return array(EnvironmentCheck::WARNING, "MyGateway returned unexpected response $response");
|
||||
} else {
|
||||
return array(EnvironmentCheck::OK, '');
|
||||
}
|
||||
return array(EnvironmentCheck::OK, '');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
@ -195,7 +186,7 @@ EnvironmentCheckSuite::register('check', 'MyGatewayCheck', 'Can I connect to the
|
|||
|
||||
### Using other environment check suites
|
||||
|
||||
If you want to use the same UI as `health/check` and dev/check, you can create an `EnvironmentChecker` object. This class is a `RequestHandler` and so can be returned from an action handler. The first argument to the `EnvironmentChecker` constructor is the suite name. For example:
|
||||
If you want to use the same UI as `health/check` and `dev/check`, you can create an `EnvironmentChecker` object. This class is a `RequestHandler` and so can be returned from an action handler. The first argument to the `EnvironmentChecker` constructor is the suite name. For example:
|
||||
|
||||
```php
|
||||
use SilverStripe\Control\Controller;
|
||||
|
@ -208,6 +199,7 @@ class DevHealth extends Controller
|
|||
return $e;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
If you wish to embed an environment check suite in another, you can use the following call:
|
||||
|
||||
|
|
|
@ -200,14 +200,6 @@ class EnvironmentCheckSuite extends Object
|
|||
$names = array($names);
|
||||
}
|
||||
|
||||
/**
|
||||
* Support for omitted namespaces - this will fall back to adding the SilverStripe\EnvironmentCheck\Checks
|
||||
* namespace if one isn't provided. If you are using custom checks, make sure you include a namespace (or "\")
|
||||
*/
|
||||
if (is_string($check) && strpos($check, '\\') === false) {
|
||||
$check = __NAMESPACE__ . '\\Checks\\' . $check;
|
||||
}
|
||||
|
||||
foreach ($names as $name) {
|
||||
self::inst($name)->push($check, $title);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue