private function checkResource($resource, $need = TRUE)
{
if (!is_string($resource) || $resource === '') {
throw new Nette\InvalidArgumentException('Resource must be a non-empty string.');
} elseif ($need && !isset($this->resources[$resource])) {
throw new Nette\InvalidStateException("Resource '{$resource}' does not exist.");
}
}