Created
May 4, 2017 08:47
-
-
Save slax0rr/8bb8b0111e42cbf2d98a781746045e35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
public function bar($output, $model) | |
{ | |
// magic ... | |
$output->addData(["foo" => $model->getFoo()]); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class RouteCollection { | |
public function define() | |
{ | |
$this->route = [ | |
"url" => "foo", | |
"method" => "GET", | |
"action" => function($app) { | |
$app["outputHandler"] = "view"; | |
$app["output.service"]->add($app["fooView"]); | |
// this can be wrapped up into a service in need be | |
$app["foo.controller"]->bar($app["output.service"], $app["fooModel"]); | |
} | |
]; | |
$this->route = [ | |
"url" => "api/foo", | |
"method" => "GET", | |
"action" => function($app) { | |
$app["outputHandler"] = "json"; | |
// this can be wrapped up into a service in need be | |
$app["foo.controller"]->bar($app["output.service"], $app["fooModel"]); | |
} | |
]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment