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

Playing with Aura.View reduced and my views on the kernel working #9

Closed
harikt opened this issue May 3, 2014 · 2 comments
Closed

Comments

@harikt
Copy link
Member

harikt commented May 3, 2014

Hey Paul,

So invested some time to play with the new reduced branch and the way I am thinking of making use of stuffs.

You can see the commit on the aura/web-kernel https://github.com/auraphp/Aura.Web_Kernel/pull/10/files?w=1

The controller

<?php
class HelloController
{
    protected $view;

    public function setView($view)
    {
        $this->view = $view;
    }

    public function stringAction()
    {
        return "Hello as a string";
    }

    public function objAction()
    {
        $view_registry = $this->view->getViewRegistry();
        $view_registry->set('hello', function () {
            echo "Hello from view object!";
        });
        $this->view->setView('hello');
        return $this->view;
    }

    public function typesAction()
    {
        $view_registry = $this->view->getViewRegistry();
        $view_registry->set('hello', function () {
                echo "Hello {$this->name}!";
        });
        $this->view->setData(array('name' => 'World'));
        $this->view->setView('hello');
        return $this->view;
    }
}

Features are

returning $this->view the dispatcher is not dispatching. I thought the dispatcher can dispatch it. Seems a bug. Need to look into this. Fixed in https://github.com/auraphp/Aura.Dispatcher/pull/11/files?w=1

I would like to set xml, json, html view and let the view can detect the rendering needed. Seems reduced don't have the functionality as earlier.

Routes in config.

$router->add('string', '/string')
    ->setValues(
        array('controller' => 'feature', 'action' => 'stringAction')
    );
$router->add('obj', '/obj')
    ->setValues(
        array('controller' => 'feature', 'action' => 'objAction')
    );
$router->add('types', '/types')
    ->setValues(
        array('controller' => 'feature', 'action' => 'typesAction')
    );
$dispatcher->setObject('feature', function () use ($di) {
    return $di->newInstance('HelloController');
});
@harikt harikt mentioned this issue May 3, 2014
@harikt
Copy link
Member Author

harikt commented May 3, 2014

1, 2 works great.

3 rd criteria is

When Accept: application/json in the request for example.com/types then it should give the appropriate content-type response. The response header can be set, but the view is something need to look.

@pmjones
Copy link
Member

pmjones commented May 15, 2014

This seems like something that should be handled at the controller or action level (or at the responder level, if we use the ADR pattern).

@pmjones pmjones closed this as completed May 15, 2014
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

No branches or pull requests

2 participants