protected function loadResource($resource, $required)
    {
        foreach ($this->loaders as $loader) {
            if (!$loader->supports($resource)) {
                continue;
            }

            try {
                return $loader->load($resource);
            } catch (ResourceNotFoundException $e) {
                if ($required) {
                    throw $e;
                }

                return [];
            }
        }

        throw new ResourceException(sprintf('There is no configuration loader available to load the resource "%s"', $resource));
    }