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);
    }
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);
    }
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 ) ; }
Generates an admin path for the given resource and action.

@param object $resource
@param string $action

@throws \RuntimeException

@return string
Generates an admin path for the given resource and action .