/**
* @param mixed $object
* @param string $routeName #Route
* @param string $separator
* @param array $query
*
* @return string
*/
public function generateObjectUrl($object, $routeName, $separator = '_', array $query = array())
{
$parameters = array();
$accessor = PropertyAccess::createPropertyAccessor();
$pattern = $this->router->getRouteCollection()->get($routeName)->getPath();
if (preg_match_all('/\\{([a-z]+)\\}/', $pattern, $matches)) {
foreach ($matches[1] as $holder) {
$value = $accessor->getValue($object, $holder);
if (!is_numeric($value)) {
$value = $this->slugify->slugify($value, $separator);
}
$parameters[$holder] = $value;
}
}
return $this->router->generate($routeName, $parameters, $query);
}