Giter Club home page Giter Club logo

application's Introduction

Nette Framework is a popular tool for PHP web development. It is designed to be as usable and as friendly as possible. It focuses on security and performance and is definitely one of the safest PHP frameworks.

Nette Framework speaks your language and helps you to easily build better websites.

The Quick Start tutorial gives you a first introduction to the framework by creating a simple database driven application.

Over 10 Yrs of Development

We have been developing Nette for over 10 years- and counting! Libraries we provide are therefore highly mature, stable and widely used. They are trusted by a number of global corporations and many significant websites rely on us.

Catching Bronze

We aim to create Nette as a fun and easy to use framework, that programmers can fall in love with. And we seem to be doing it well! We were rated as the 3rd most popular framework in a survey Best PHP Framework for 2015 by a well-know magazine SitePoint.

Security Is a Priority

There is nothing we care about more than security. That is why we had built Nette as the safest PHP framework. It had passed many audits with flying colours, it eliminates safety traps like XSS, CSRF and brings out ground-breaking methods.

Libraries & Framework

Nette consists of a number of handy standalone libraries, which can be used in any codebase, for example combined with WordPress or another framework. Careful, some of them are highly addictive! These are the components that Nette Framework is built on:

  • Application – The kernel of web application
  • Bootstrap – Bootstrap of your application
  • Caching – Cache layer with set of storages
  • Component Model – Foundation for component systems
  • DI – Dependency Injection Container
  • Finder – Find files and directories with an intuitive API
  • Database – Database layer
  • Forms – Greatly facilitates secure web forms
  • Http – Layer for the HTTP request & response
  • Latte – Amazing template engine
  • Mail – Sending E-mails
  • Neon – Loads and dumps NEON format
  • Php Generator – PHP code generator
  • Robot Loader – The most comfortable autoloading
  • Routing – Routing
  • Safe Stream – Safe atomic operations with files
  • Security – Provides access control system
  • Schema – User data validation
  • Tester – Enjoyable unit testing in PHP
  • Tracy – Debugging tool you will love β™₯
  • Tokenizer – Source code tokenizer
  • Utils – Utilities and Core Classes

application's People

Contributors

davidkrmela avatar dg avatar enumag avatar f3l1x avatar fabik avatar foxycode avatar fprochazka avatar hrach avatar janbarasek avatar janmarek avatar jantvrdik avatar juzna avatar kravco avatar lulco avatar mabar avatar majkl578 avatar matej21 avatar milo avatar milous avatar mrtnzlml avatar ondrejmirtes avatar patrickkusebauch avatar paveljurasek avatar tomaswindsor avatar vasekpurchart avatar vlastavesely avatar voda avatar vrana avatar vrtak-cz avatar xificurk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

application's Issues

ApplicationExtension - Missing cache storage

  • bug report? yes
  • feature request? no
  • version: 2.4.5

Description

Hi,
I use whole Nette package in version 2.4 and I think have just discovered bug. Tracy shows me following message, when I load homepage of my app (on localhost).

User Warning
Missing cache storage.

I run composer update commnand today and I think the cause of warning I mentioned above is missing

$robot->setCacheStorage(new Nette\Caching\Storages\DevNullStorage);

call in ApplicationExtension::findPresenters. This setter is called in version 2.4.3, but there is no such call since version 2.4.4.

RoutingExtension: unable to cache routes with dependencies

Any route of which generated method in SystemContainer contains $this is not cacheable because it leads to exception inside eval, e.g.: Call to undefined method RoutingExtension::getService(). Therefore any route with dependencies in constructor is not cacheable.

I don't know if this limitation can be eliminated, but at least, It would be nice to have some better error message. Or can it be eliminated?

For example this and this route cannot be cached.

param2path failed when given integer

  • bug report? yes
  • feature request? no
  • version: dev-master f0b30ff

Description

I tried to generate link:

{plink News:detail category => $news->getCategory()->getName(), id => $news->getId(), name => $news->getSubject()}

and it's failed in class Route in method param2path: https://github.com/nette/application/blob/master/src/Application/Routers/Route.php#L330

TypeError: Argument 1 passed to Nette\Application\Routers\Route::param2path() must be of the type string, integer given

Dump of params:
category => "xxx"
id => 3614
name => "xxx"
action => "xxx"

It's ok:

{plink News:detail category => $news->getCategory()->getName(), id => (string) $news->getId(), name => $news->getSubject()}

Set template variables using ArrayAccess

I'm thinking why Nette\Bridges\ApplicationLatte\Template is using object access to set template attributes? Wouldn't ArrayAccess be more natural?

When using $template->foo = 'bar';, i.e. PhpStorm warns about accessing field via magic method.

I think $template['foo'] = 'bar'; would:

  1. be more expressive - there is actually a hashmap of template variables, they are not "template object properties"
  2. not generate warnings about usage of magic in IDEs

What do you others think?

ApplicationLatte/Template - changed behaviour of setParameters()

In Bridges.ApplicationLatte.Template.php

/**
 * Sets all parameters.
 * @param  array
 * @return self
 */
public function setParameters(array $params)
{
    $this->params = $params;
    return $this;
}

vs

In deprecated.Templating.Template.php

/**
 * Sets all parameters.
 * @param  array
 * @return self
 */
public function setParameters(array $params)
{
    $this->params = $params + $this->params;
    return $this;
}

In newest version of setParameters, it's override old parameters. It's purpose? Cause, I'd like old way..

BC Break: Nette\Bridges\ApplicationLatte\Template has no "filters"

We just started migrating from Nette 2.1-something and this was one of the issues we bumped into.

I know it's not a best practise, but often I would use the template object helpers in presenter or control.

For example let's have a price helper registered, you need to format a money object into flashMessage and you can either inject the helpers class and use that to format it, or just simply call $template->price($money) and use that in the flashMessage.

Now that the Nette\Bridges\ApplicationLatte\Template has no __call method, this stopped working.

This is not a critical issue, and you may decide to mark it as a wontfix, but I think it would be better to add the __call with deprecated trigger to the ApplicationLatte\Template class.

Support for global parameters in latte template in snippets

I tried to define β€žglobal variableβ€œ in one snippet for usage in another snippet (example) but there is a little block in Application/Bridges/ApplicationLatte/UiMacros.php.

There is calling

return Nette\Bridges\ApplicationLatte\UIMacros::renderSnippets($_control, $_b, get_defined_vars());

But if there will be

return Nette\Bridges\ApplicationLatte\UIMacros::renderSnippets($_control, $_b, $template);

and in the implementation of renderSnippets() method will be $template->getParameters() instead of current usage, it will be possible to define β€žglobalβ€œ variable in one snippet by {?$template->variable = 'value'} or by new simple latte macro {varGlobal $variable = 'value'} and it will be accessible like when it will be defined before render.

Can I prepare pull-request?

storeRequest and restoreRequest after login

Hi,

I have a classic situation. User is not logged in and he click on an url, which needs a logged in user.

So in the startup() I have:

$this->next = $this->storeRequest();

This will store in the session an array of

[ $this->user->getId(), $this->request ]

Here, the first parameter of the array is NULL, because user was not logged in, so he has no ID.

Later in the login form, I'm trying to restore the previous request:

...
$user->login(...);
...
$this->restoreRequest($this->next);

This will fail on line https://github.com/nette/application/blob/master/src/Application/UI/Presenter.php#L1099 because, in the session I have user id as NULL, but now user is logged in and he have an ID which is different.

Why there is this control of the user ID?

non-string route params dumped as invisible collapsible structure

My router captures ids in url and passes loaded entities to presenters instead. I noticed that RoutingPanel doesn't show the entities although it dumps them with Dumper::toHtml().

dumped variable invisible

If I comment out the following style at the top of RoutingPanel.panel.phtml:

#tracy-debug .nette-RoutingPanel code .tracy-collapsed {
  display: none;
}

the variable shows in its typical collapsed coating:
and now you see it

I didn't notice any side effects, tested in Firefox.

The commit comment that added display: none; is rather barren: "values are dumped collapsed"

I don't understand how the clickable dump was supposed to unfold when completely invisible. To me this is a bug but maybe I'm just using the panel in some unexpected way :-)

Test failures with PHP 7.2.0-dev

  • bug report? yes
  • feature request? no
  • version: 2.4.6
+ php72 /usr/bin/nette-tester --colors 0 -p php72 -C tests -s
 _____ ___  ___ _____ ___  ___
|_   _/ __)( __/_   _/ __)| _ )
  |_| \___ /___) |_| \___ |_|_\  v2.0.x

PHP 7.2.0-dev (cli) | php72 | 8 threads

..............F............s.....s......................................................................FFF...

-- FAILED: TemplateFactory custom template | tests/Bridges.Latte/TemplateFactory.customTemplate.phpt
   Exited with error code 255 (expected 0)
   
   Fatal error: Declaration of TemplateMock::render() must be compatible with Nette\Bridges\ApplicationLatte\Template::render($file = NULL, array $params = Array) in /dev/shm/BUILD/application-057f5bd271ee0969570c49fc4ff1e3cb4e3fd113/tests/Bridges.Latte/TemplateFactory.customTemplate.phpt on line 17

-- Skipped: Nette\Application\Responses\FileResponse. | tests/Responses/FileResponse.contentDisposition.phpt
   Requires CGI SAPI to work with HTTP headers.

-- Skipped: Nette\Application\Responses\JsonResponse. | tests/Responses/JsonResponse.contentType.phpt
   Requires CGI SAPI to work with HTTP headers.

-- FAILED: Nette\Application\UI\Presenter::link() | tests/UI/Presenter.link().php7.phpt
   Exited with error code 255 (expected 0)
   
   Fatal error: Declaration of TestControl::saveState(array &$params) must be compatible with Nette\Application\UI\Component::saveState(array &$params, $reflection = NULL) in /dev/shm/BUILD/application-057f5bd271ee0969570c49fc4ff1e3cb4e3fd113/tests/UI/Presenter.link().php7.phpt on line 16

-- FAILED: Nette\Application\UI\Presenter::link() | tests/UI/Presenter.link().php71.phpt
   Exited with error code 255 (expected 0)
   
   Fatal error: Declaration of TestControl::saveState(array &$params) must be compatible with Nette\Application\UI\Component::saveState(array &$params, $reflection = NULL) in /dev/shm/BUILD/application-057f5bd271ee0969570c49fc4ff1e3cb4e3fd113/tests/UI/Presenter.link().php71.phpt on line 16

-- FAILED: Nette\Application\UI\Presenter::link() | tests/UI/Presenter.link().phpt
   Exited with error code 255 (expected 0)
   
   Fatal error: Declaration of TestControl::saveState(array &$params) must be compatible with Nette\Application\UI\Component::saveState(array &$params, $reflection = NULL) in /dev/shm/BUILD/application-057f5bd271ee0969570c49fc4ff1e3cb4e3fd113/tests/UI/Presenter.link().phpt on line 15


FAILURES! (110 tests, 4 failures, 2 skipped, 3.0 seconds)

Leading colon in the destination breaks link generation using LinkGenerator

We use modules in our application and sometimes we need to specify the destination absolutely using the leading colon. Something like :Module:Presenter:action. This works for normal link generation using $presenter->link() (or in templates) but the brand new LinkGenerator throws an InvalidLinkException with the message Presenter name must be alphanumeric string, ':Module:Presenter' is invalid.

If I remove the leading colon, the LinkGenerator starts working, but now it's $presenter->link() that fails with an exception.

I might be doing something wrong but I'm pretty sure that the behavior should be consistent.

n:nonce isn't replaced if <script> is placed inside HTML comment

  • bug report? yes
  • feature request? no
  • version: 2.4.4

Description

Attribute n:nonce isn't replaced if <script> is placed inside HTML comment.

Steps To Reproduce

<!--[if lt IE 9]>
  <script n:nonce src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  <script n:nonce src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->

Broken co-operation with Kdyby/Console

Hello,

this commit (f06a689) / pull (#56) broke co-operation with Kdyby/Console, because of autoloading classes with "Presenter" in their class name from Composer.

In Kdyby DI extension
is Kdyby\Console\Application not registred, if request is not from cli mode.

And therefore error come:
"Service of type Kdyby\Console\Application needed by KdybyModule\CliPresenter::injectConsole() not found. Did you register it in configuration file?"

So quick fix is putting this into 'application:' di config:

  • scanComposer: FALSE

Maybe there would be nice some kind of ignore list?

ping @fprochazka

Method getGlobalState() should not be private

I have implemented my own link signing sevice. Last thing I need to do is override method canonicalize() to generate signed redirect. However in current state, I cannot do this because method getGlobalState() is private and therefore this metod cannot be used in my overriden method canonicalize(). Is there any reason why is getGlobalState() private and should not be at least protected ? Thanks

redirect() in component does not respect server port

I am running Nette 2.4 in docker with nginx and PHP 7.0.12. Docker is internally listening on port 666, port 80 is exposed (works fine when both are 666)

Specific scenario: processing form inside a component that's created using a factory injected to a presenter.

$form->onSuccess[] = function(Form $form) {
    $this->presenter->redirect('Listing:default', ['filter' => $form->getValues(true)]);
};

This will try to re-direct to :666/listing?filter= ...
And while I could resolve this simply by using same ports (80:80), I am a bit afraid what it would do when using https and also once it's set up behind a load balancer or a proxy.

Also might be worth investigating whether sessions will be stored properly in regard to the domain the user actually accessed (rather than domain where the instance is physically running) - this might potentially be a big issue..

Thank you for checking this out!

Snippets: Limited functionality when using partial rendering & AJAX

When partial rendering is used and you want to redraw one part of the control when signal using AJAX is invoked, no payload is sent over the network.

As @paveljanda mentioned in contributte/datagrid#63 the problem is in UIRuntime:50 (only the main render method is called).

Is it prossible to add functionality to render rest of the render methods when redrawing? You can check the demo code (mainly the signal methods with comments).

Ambiguous storing Flash Message in Templates

  • bug report? not sure
  • feature request? no
  • version: 2.4

Description

When storing flash message in component, it is in session but not in template - because there are 2 possible templates.

Located in flashMessage() method:

$this->getTemplate()->flashes = $messages;
$this->getPresenter()->getFlashSession()->$id = $messages;

and sessions are set to template only in Presenter in TemplateFactory:

if ($presenter instanceof UI\Presenter && $presenter->hasFlashSession()) {
	$id = $control->getParameterId('flash');
	$template->flashes = (array) $presenter->getFlashSession()->$id;
}

How to Simulate

// Control

final class MyControl extends Control
{
    public function process()
    {
        // case A          
        $this->flashMessage('Log in, bro!');
        $this->presenter->redirect('SomePresenter:default');
        // vs.    
        // case B
        $this->presenter->flashMessage('Log in, bro!'); 
        $this->presenter->redirect('SomePresenter:default');
    }
}

Case A

  • stores in global session
  • stores in control template

Case B

  • stores in global session
  • stores in presenter template

This is difficult to debug, because it is in Session in both cases.

Not sure how to solve this. Any ideas?

TemplateFactory - variable template class (RFC)

Hi! I have and idea about TemplateFactory.

If you need to use your own Template class, you have to extend original TemplateFactory now.

What about this implementation?

protected $templateClass = 'Nette\Bridges\ApplicationLatte\Template';

public function createTemplate(UI\Control $control = NULL)
{
    $latte = $this->latteFactory->create();
    $template = new $this->templateClass($latte);
    $presenter = $control ? $control->getPresenter(FALSE) : NULL;
    //...
}

public function setTemplateClass($class) 
{
    $this->templateClass = $class;
}

What do you think? It makes TemplateFactory more flexible. You can setup your template implementation over NEON config.

services:
    latte.templateFactory:
        setup:
            - setTemplateClass(My\Custom\Template)

Thanks for feedback.

TemplateFactory::onCreate

  • bug report? no
  • feature request? yes
  • version: >=2.4

Description

I would like to add TemplateFactory::onCreate event. It would be the same as in Latte::onCompile, Presenter::onStartup, Application::onRequest, Form::onSuccess.

With this new event we can define any callback in NEON and don't need to override TemplateFactory. At this moment, we would like to have Symfony Event for that in contributte/event-dispatcher-extra (https://github.com/contributte/event-dispatcher-extra).

Can I prepare PR?

case sensitivity in templates' path

why is nette suddenly case sensitive?
if I had templates stored in this manner templates/Homepage/default.latte and router and links defined with small first letter like this

    new Route('<presenter>/<action>[/<id>]', 'homepage:default');

it worked both on windows and linux

after I updated nette, it is looking for templates/homepage/default.latte which throws 404s on linux server

@layout.latte can't be in presenters/templates

Nette 2.3 introduced new folder structure for templates. But @layout.latte still have to be placed in old location.

Not working:

+-- presenters
|   +-- HomepagePresenter.php
|   +-- templates
|   |   +-- Homepage.default.latte
|   |   +-- @layout.latte

Working:

+-- presenters
|   +-- HomepagePresenter.php
|   +-- templates
|   |   +-- Homepage.default.latte
+-- templates
|   +-- @layout.latte

Allow array as presenter mapping

The PresenterFactory splits the mapping mask to 3 parts - a prefix, a part which is reapeated for each module and a part for presenter. The problem is that there is no way to actually configure the 3 parts separately. In my case I need the mapping to look like this:

'*' => array('App\', 'Module\*Module\', 'Presenter\*Presenter')

This is currently not possible to achieve. I tried the following:

nette.application:
    mapping:
        *: App\Module\*Module\Presenter\*Presenter
# result:
# '*' => array('App\Module\', '*Module\', 'Presenter\*Presenter')
nette.application:
    mapping:
        *: App\*Module\Module\Presenter\*Presenter
# result:
# '*' => array('App\', '*Module\', 'Module\Presenter\*Presenter')

To achieve the mapping I want I'd have to create my own PresenterFactory. And I can't even extend the default one because the mapping property is private (don't want to hack it using reflection).

Instead I'd like the PresenterFactory to accept an array as well so that this would work:

nette.application:
    mapping:
        *: [ App\, Module\*Module\, Presenter\*Presenter ]

RountingPanel: Commit #55 - Uncaught exception

After commit #55 it start throws exception 'ReflectionException' with message 'Method renderdefault does not exist'.

It render complete stack trace to the routing panel.
When it was using Nette\Reflection\ClassType, before commit #55, it was OK.

I now what exception means but sometimes I am lazy to create method.

Persistent parameter doesn't work with traits

  • bug report? yes
  • version: 2.4.6

Description

When i have persistent parameter in trait, routes with this parameter don't work. Probably problem is here: \Nette\Application\UI\Presenter::argsToParams because reflection cannot load parameters from trait.

Steps To Reproduce

trait PresenterTrait
{
	/** @persistent */
	public $locale;
}

class DefaultPresenter extends  \Nette\Application\UI\Presenter
{
	use PresenterTrait;
}

class SecondPresenter extends  \Nette\Application\UI\Presenter
{
	use PresenterTrait;
}

2.3.11 breaks isLinkCurrent and {ifCurrent} macro

Following-up on my bug report about typehinted scalar parameters. The fix that resolved this bug also introduced a rather inconvenient BC break.

With non-typehinted scalar parameters, it's not necessary to pass all parameters to isLinkCurrent method:

$presenter->isLinkCurrent(':Homepage:default', []);

In this example, calling the method works even if the requested action has required arguments. By calling it without the arguments, I simply mean to ask "Is the current page at Homepage:default?" without checking exact parameters.

If the action has PHP-7-scalar typehints, I cannot longer call isLinkCurrent without its arguments:

public function renderDefault(int $id)
{
}
...
$presenter->isLinkCurrent(':Homepage:default', []); // fails on PHP-7

BC break aside, I think it also reduces the scope where isLinkCurrent is usable. Before PHP 7, I could use it for checking whether am I in a concrete Presenter:action pair without caring about exact arguments.

For example if I want to always render a template block when I am at Article:default, in the past I could have used {ifCurrent Article:default}. Now, I have to pass the arguments to the macro.

Ideally, the isLinkCurrent/ifCurrent functionality should not depend on generating links because it should behave independently of each other because of different requirements for these functionalities.

If this issue is a logical conclusion of the suggested behaviour in #112 and the current behaviour is fine for everyone, feel free to close this issue.

Thanks!

Disappearing parameter

I've this route:

$router = new Route('search[/<text>]', 'Search:default');

Then I have a form with get method and action set to Search:default. Obviously submitting the form will open url /search?text=query instead of /search/query. That's fine - I'd expect canonicalization to take care of that and redirect me to the correct url. Problem is that canonicalization will redirect me to just /search - the text parameter disappeared. The thing is, the parameter value never made it to Application\Request (it's NULL).

Using array_merge here instead of += fixed the problem for me but it breaks several tests so this fix is not correct.

I've also tried adding && $meta['fixity'] !== self::PATH_OPTIONAL here but that also breaks some tests.

SnippetBridge, IRenderable & TemplateFactory

Current bridge layer & framework itself is not easily extensible via implementing interface. Nette Application itself defines few interfaces, but their design, naming and usage inside the framework is not good.

  1. SnippetBrige contains non-trivial logic, which shouln't be probably in "bridge". Morover, it somehow works with component tree model & IRenderable, but accepts only Control.

  2. IRenderable - somehow it says from its name, that it decides if something will be renderer. However, in the code, isControlInvalid() is used only in AJAX mode, moreover, the second methods is used only with snippets, which makes maily (but not exlusively) sence with snippets names, which are in fact not defined in interface!!! and are marked as optional arguments in control.

  3. Bridge - TemplateFactory also sctrictly accept only Control or null, though, almost no functionality in the factory depends (directly) on it.


Possible solution:

  1. Decouple UI control & link creation. (eg. macro {link} won't be call on object of UIControl.) This should be handled in a different way. I can imagine that some tree structure should be injected into template, and link macro will reuse it, but it should be done in different time and place.

  2. Possible rename IRenderable to IControl, add proper methods for snippets functionality and proper method naming (isInvalidControl vs redrawControl). Eg.

interface IControl
{
public function shouldRedraw(?string $snippet = null);
public function redrawControl(?string $snippet = null, bool $redraw = true);
}
  1. Store snippetMode in snippetBridge, or just outside the Control. If the whole logic is in SnippetBridge::renderChildren(), there is no need to have it in Control.

  2. Rename SnippetBridge::renderChildren() to SnippetBrige::render(). There is no need that SnippetBrige should now about some tree structure, it has nothing to do with snippets.

  3. Move the tree traversal logic of isInvalidControl outside the Control. The logic is currently copy-pasted in SnippetBridge::renderChildren() and could be probably somehow unified in this bridge, or better, extracted to some helper hlass which will do the traversion for IComponent & IContainer.

  4. Basically, let all parts of SnippetBrige, TemplateFactory etc. work with IControl.


It's just a quick bugreport (which took several about hour to write and some others to go through the code), maybe there are some better solutions, the general, or just for some mentioned poits.

I believe it's possible to do it with minimum BC breaks.

Empty flash messages when template is created before Presenter::startup()

  • bug report? yes

I found an another issue but I am not really sure what solution would be the best.

When it happens that method Presenter::createTemplate() is called before Presenter::initGlobalParameters(), a template cannot load flash messages from a previous request properly for parameter _fid has not been set yet. It can happen when you create function Presenter::injectSomething() that touches template by setting some parameter into it. In my case, I was trying to inject a translator and set a param $lang to the template in the same function. After redirect I was not able to load presenter's flash messages.

Question is how to solve it. First logical solution might be to force reload the flash messages from session right before template is sent to a browser.

Another way to go would be just to trigger a warning and consider template creation before Presenter::run() has been called as bad practice. This is because I am wondering how good practice it can be to use other dependencies from a inject*() and rely on that they were really already set...? Wouldn't be inject*() functions ideally only for setting dependencies and nothing more?

Any other suggestions?

HHVM causes malfunction of redirect(...) method of PresenterComponent since func_get_args returns arguments by references instead values

Since PresenterComponent::redirect function has optional parameter $code, following code:

if (!is_numeric($code)) { // first parameter is optional
    $args = $destination;
    $destination = $code;
    $code = NULL;
}


if (!is_array($args)) {
    $args = array_slice(func_get_args(), is_numeric($code) ? 2 : 1);
}

will cause difference between HHVM interpreter and PHP interpreter. Because func_get_args returns arguments by references instead values in HHVM.

Example in HHVM

calling:

$this->redirect('Question:detail', 50);

will transfer parameters into:

code        = NULL 
destination = string(15) "Question:detail" 
args        = array(1) { [0]=> string(15) "Question:detail" }

while call:

$this->redirect('301', 'Question:detail', 50);

results in this:

code        = string(3) "301" 
destination = string(15) "Question:detail" 
args        = array(1) { [0]=> int(61) }

Difference between generated urls with route:

new Route('admin/<presenter>/<action>/<id>',...)

is:

admin/question/detail/Question%3Adetail - WRONG

vs:

admin/question/detail/65 - CORRECT!

Set charset for JsonResponse

When sending a JsonResponse, you cannot set the JSON charset right now. There is a work around right now with
$this->sendResponse(new \Nette\Application\Responses\JsonResponse($data, 'application/json; charset=utf-8')); , but it ?should not? work.

There is a discussion of this behavior on Nette Framework Forum (in Czech).

I am willing to write a PR, of somebody decides the solution (you should not be able to set charset under any circumstances vs add ability to set charset transparently).

after $form->setAction(), destination presenter throws exception

In version 2.2:

I have PageWithFormPresenter::actionDefault with this code

$form = $this["orderForm"];
$form->setAction($this->link(":Result:", "paramValue"));

/**
* @return UI\Form
*/
public function createComponentOrderForm() {
}

When form is submitted to destination url, presenter which serves this url (ResultPresenter) throws the BadSignalException with "The signal receiver component 'orderForm' is not found".

This worked without any error in 2.1. It's related to change in form submit url and "do" parameter in POST data, which was introduced in 2.2

New interface for Route display in debugbar

If I want create new Route and display values in debug bar, i must extend Route class. What do you think about new interface with two methods?

interface IRouteMeta {
public funciton getDefaults();
public function getMask();
}

Class route must edit.

class Route implements IRoute, IRouteMeta {}

And I will use like this

class MyRoute implements IRoute, IRouteMeta {}

instance of

class MyRoute extends Route {}

RoutingPanel will change condition to new interface.

Or append both methods to IRoute interface?

Edit
Renamed IRouteBar -> IRouteMeta

ApplicationExtension: option for autofinding of presenters

I have problem with these lines

        $presenters = [];
        foreach (array_unique($classes) as $class) {
            if (strpos($class, $config['scanFilter']) !== FALSE && class_exists($class)
                && ($rc = new \ReflectionClass($class)) && $rc->implementsInterface(Nette\Application\IPresenter::class)
                && !$rc->isAbstract()
            ) {
                $presenters[] = $rc->getName();
            }
        }
        return $presenters;

My use-case:

I have CLI application with Kdyby/Doctrine (it depends on Kdyby/Console) and there's a presenter CliPresenter.

It requires Kdyby\Application\Console, but I have different configs on CLI deploy (without Kdyby\Console).
It occured an Exception (Service 'application.1': Service of type Kdyby\Console\Application needed by KdybyModule\CliPresenter::injectConsole() not found. Did you register it in configuration file).

That's because presenters are registered by automatic.


It would be great have option for example scanPresenter for autofinding presenters.

Does it make sence?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.