Skip to content

Instantly share code, notes, and snippets.

@slax0rr
Created May 4, 2017 08:47
Show Gist options
  • Save slax0rr/8bb8b0111e42cbf2d98a781746045e35 to your computer and use it in GitHub Desktop.
Save slax0rr/8bb8b0111e42cbf2d98a781746045e35 to your computer and use it in GitHub Desktop.
<?php
class Foo
{
public function bar($output, $model)
{
// magic ...
$output->addData(["foo" => $model->getFoo()]);
}
}
<?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