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

Render different format from the same action #10

Closed
harikt opened this issue Jul 17, 2012 · 6 comments
Closed

Render different format from the same action #10

harikt opened this issue Jul 17, 2012 · 6 comments
Assignees
Milestone

Comments

@harikt
Copy link
Member

harikt commented Jul 17, 2012

Currently Aura.Framework 's view ends with name <action-name>.php Eg : https://github.com/auraphp/Aura.Framework/blob/develop/src/Aura/Framework/Web/Hello/views/world.php .
I was wondering what will happen if we want to render a json value.

I think its implemented ( https://github.com/auraphp/Aura.View/blob/develop/src/Aura/View/TwoStep.php#L512 ) , but I am still trying to figure out how to make use of it.

May I know how this is going to happen for I can also check on Mustache, Twig etc .

@ghost ghost assigned pmjones Jul 17, 2012
@harikt
Copy link
Member Author

harikt commented Jul 24, 2012

@pmjones I am also waiting for your answer on
https://github.com/harikt/Aura.Framework/commit/7be93249df429d015de0796ceb2a5819c402982c
Probably this has some relationship ?

@harikt
Copy link
Member Author

harikt commented Jul 25, 2012

I think we should have a Json rendering strategy in core. Can we make it happen for Beta3 ?

@harikt harikt mentioned this issue Jul 25, 2012
@harikt
Copy link
Member Author

harikt commented Aug 15, 2012

So I did something like

public function actionLogin()
{
    $this->view = [
        '.json' => 'login.json.php',
        '.html' => 'login.html.php',
        '.xml' => 'login.xml.php'
    ];
    echo "login";
}

Now the problem is $this->controller->getFormat() the method exec() of AuraViewTwoStep is not getting the right format.

Thus the TwoStep method getView($view, $format) of Aura\View returns an array . Thus we are getting an error Array to string conversion in package/Aura.View/src/Aura/View/TwoStep.php on line 449 View name : format : Array Warning: substr() expects parameter 1 to be string, array given in package/Aura.View/src/Aura/View/AbstractTemplate.php on line 265

I will also look what is wrong . But if you know how we can fix easily let me know.

Thanks

@harikt
Copy link
Member Author

harikt commented Aug 15, 2012

So I added a default format as .html . But according to me I feel even if the user has not provided the format we should render in html . Thoughts ?

$di->get('router_map')->add('fb_login', '/fb/login', [
    'values' => [
        'controller' => 'facebook',
        'action' => 'login',
        'format' => '.html'
    ],
]);

Also curl -i http://localhost:8000/fb/login -H "Accept: application/json" also giving html. So I feel the format is not getting correctly ?

@harikt harikt mentioned this issue Aug 15, 2012
@pmjones
Copy link
Member

pmjones commented Sep 24, 2012

@harikt Did the bugfix in pull 17 remedy this?

@harikt
Copy link
Member Author

harikt commented Sep 24, 2012

@pmjones Yes. Fixed by #17 . If any other issues I will open another one.

@harikt harikt closed this as completed Sep 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants