protected function injectContentTemplate(MvcEvent $event)
    {
        $model = $event->getResult();

        if (! $model instanceof ViewModel) {
            return $this;
        }
        if ($model->getTemplate()) {
            return $this;
        }

        $routeMatch   = $event->getRouteMatch();
        $themeName    = $this->getThemeName();
        $themeOptions = $this->getThemeOptions();

        $options = [];
        if (isset($themeOptions[static::$side])) {
            $options = $themeOptions[static::$side];
        }

        if (isset($options['templates'])) {
            $templatesPath = rtrim($options['templates'], '/') . '/';
        } else {
            $templatesPath = str_replace(
                ['{theme}', '{side}'],
                [$themeName, static::$side],
                self::DefaultTemplatesPath
            );
        }

        $controller = $event->getTarget();
        if ($controller) {
            $controller = get_class($controller);
        } else {
            $controller = $routeMatch->getParam('controller', '');
        }
        $controller = $this->deriveControllerClass($controller);
        $template = $templatesPath . $this->inflectName($controller);

        $action  = $routeMatch->getParam('action');
        if (null !== $action) {
            $template .= '/' . $this->inflectName($action);
        }

        $model->setTemplate($template);

        return $this;
    }