public function generateResourcePath($resource, $action = 'show')
    {
        $configuration = $this->registry->findConfiguration($resource);
        $routeName = $configuration->getRoute($action);

        $route = $this->findRoute($routeName);
        $requirements = $route->getRequirements();

        $accessor = PropertyAccess::createPropertyAccessor();

        $entities = [];
        if (is_object($resource)) {
            $entities[$configuration->getResourceName()] = $resource;
            $current = $resource;
            while (null !== $configuration->getParentId()) {
                $configuration = $this->registry->findConfiguration($configuration->getParentId());
                $current = $accessor->getValue($current, $configuration->getResourceName());
                $entities[$configuration->getResourceName()] = $current;
            }
        }

        $parameters = [];
        foreach ($entities as $name => $resource) {
            if (array_key_exists($name . 'Id', $requirements)) {
                $parameters[$name . 'Id'] = $accessor->getValue($resource, 'id');
            }
        }

        return $this->router->generate($routeName, $parameters);
    }