Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

PR for #6866 - Allow console specific view manager configuration #6951

Closed
wants to merge 8 commits into from
Closed

PR for #6866 - Allow console specific view manager configuration #6951

wants to merge 8 commits into from

Conversation

dkemper
Copy link
Contributor

@dkemper dkemper commented Dec 2, 2014

Allow to override "display_exceptions" and "display_not_found_reason" for Console ViewManager #6866

@dkemper dkemper changed the title Allow console specific view manager configuration 6866 Allow console specific view manager configuration #6866 Dec 2, 2014
@dkemper dkemper changed the title Allow console specific view manager configuration #6866 PR for #6866 - Allow console specific view manager configuration Dec 2, 2014
$this->services = new ServiceManager();
$this->view_manager = new ViewManager();
$this->factory = new ConsoleViewManagerFactory();
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just enhancement, I think setUp() function should be placed in first place

$config['view_manager'] = array();
}

$this->config = array_merge($config['view_manager'], $config['console']['view_manager']);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console view manager config takes priority?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes in the ConsoleViewManager, better suggestions? Should be covered in the "with-console" testcase.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just that merging it means that console will always win over http. A bit problematic, IMO. I would try solving this problem in the ViewManagerFactory instead, no?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To clarify: we could inject multiple configs and decide (at runtime) which one to use (depending on whether we are in console context or not)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure if i got it right. I just put it in the ConsoleViewManager, because i thought its the right place for it. The ViewManagerFactory returns the ConsoleViewManager in console context. For the ConsoleViewManager the "console view manager configuration" is priority. The new configuration should not affect the HttpViewManager.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am also not sure if runtime-merging (and thus destroying the possibility of accessing original config) is a good idea.

Another point: We should definitly use Stdlib\ArrayUtils::merge() instead of plain old array_merge() to keep full power of configuration merge (see #6899, #6903)!

@Ocramius Ocramius added this to the 2.4.0 milestone Dec 2, 2014
@Ocramius Ocramius self-assigned this Dec 2, 2014
$this->config = isset($config['view_manager']) && (is_array($config['view_manager']) || $config['view_manager'] instanceof ArrayAccess)
? $config['view_manager']
: array();
if (isset($config['console']['view_manager']) && (is_array($config['console']['view_manager']) || $config['console']['view_manager'] instanceof ArrayAccess)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably check Console::isConsole() instead of checking what config was passed in, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any use case for using ConsoleViewManager in the http context? I can´t imagine one. https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/Service/ViewManagerFactory.php#L28 is checking for the console context right now.

I thought supporting the current configuration key, will not cause a breaking change, because
The default configuration for displayNotFoundReason and displayExceptions is set to true: https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/View/Console/ExceptionStrategy.php#L25 and https://github.com/zendframework/zf2/blob/master/library/Zend/Mvc/View/Console/RouteNotFoundStrategy.php#L38. Otherwise we could just remove the $config['view_manager] check or solve it within the factory. I am not familiar how use usally handle backwardcompatibility.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed the fact that the view manager factory selects the correct view manager upfront: my bad. This fix is valid.

@ojhaujjwal
Copy link
Contributor

+1

Ocramius added a commit that referenced this pull request Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
Ocramius added a commit that referenced this pull request Dec 16, 2014
@Ocramius
Copy link
Member

@dkemper merged into develop at 1df2e72, thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants