Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added presenter mapper #16

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Added presenter mapper #16

wants to merge 1 commit into from

Conversation

Budry
Copy link

@Budry Budry commented Jun 23, 2014

Discusion: http://forum.nette.org/en/19620-better-mapping-configuration#p135799

For easier use custom mapping implementation

with nette/bootstrap#8

@dg
Copy link
Member

dg commented Jun 23, 2014

I am not sure that own mapper is really needed. I agree that mapping can be enhanced for <module> and <presenter> placeholders, but in this case there is no need to use own mapper.

@mishak87
Copy link

I for one would use such mapper. It really enables modularity across packages and default implementation can be reused as a fallback for custom implementation.

Now I can have multiple packages sharing same <module> by convention ie. namespace:

<?php $mapping = [ 'shop' => [
    'packageA/src/Shop/Presenters',
    'packageB/src/Shop/Presenters',
// ...
] ]

For now I have to prefix each package, because using multiple directories for same <module> is not possible. From my experience using paths with multiple modules is not really scalable across packages ie. <AModule>/<AdminModule>. Sharing <module> makes things simpler.

@matej21
Copy link
Contributor

matej21 commented Jun 23, 2014

👍
But I would remove the setMapping method in IPresenterMapper interface

@Budry
Copy link
Author

Budry commented Jun 23, 2014

I think that use <module> and <presenter> placeholders would be good, but mapper could be usefully.
Mapper has no disadvantage, has only benefits in my opinion

@Budry
Copy link
Author

Budry commented Jun 24, 2014

@matej21 you are rigth. I removed setMapping from interface

* @return string
*/
function unformatPresenterClass($class);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

missing newline

@enumag
Copy link
Contributor

enumag commented Jul 6, 2014

👍 for this

/** @var array */
private $cache = array();

/** @var Nette\DI\Container */
private $container;

/** @var \Nette\Application\IPresenterMapper */
Copy link
Contributor

Choose a reason for hiding this comment

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

No need for FQCN.

@Majkl578
Copy link
Contributor

Majkl578 commented Jul 6, 2014

👍 I like it.
It would be possible to create MapperChain, chaining multiple mappers for different modules of application (and even better, it would work greatly addons which use presenters). Maybe it would be the best to add it into Nette as well (it could be done in separate PR later).

* @param string
* @return string
*/
public function formatPresenterClass($presenter)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should keep this method for BC purposes and just alias it to $this->presenterMapper->formatPresenterClass(...).

@dg
Copy link
Member

dg commented Jul 7, 2014

What is purpose of this PR? To add <module> and <presenter> placeholders? It will not help, because everybody will have to write own mapper. Implementations will be fragmented.

What is the advantage of "split" 2-methods IPresenterFactory into 2-methods IPresenterFactory plus 2-methods IPresenterMapper? Is there really such big need to create your own mappers?

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

Successfully merging this pull request may close these issues.

None yet

8 participants