Created
July 20, 2012 09:51
-
-
Save k-holy/3149937 to your computer and use it in GitHub Desktop.
BEAR.Sundayはじめてのページリソース
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 | |
namespace sandbox\Resource\App\First; | |
use BEAR\Resource\AbstractObject; | |
/** | |
* Greeting resource | |
*/ | |
class Greeting extends AbstractObject | |
{ | |
/** | |
* Get | |
* | |
* @param string $name | |
* | |
* @return string | |
* | |
*/ | |
public function onGet($name) | |
{ | |
return sprintf('Hello, %s', $name); | |
} | |
} |
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 | |
namespace sandbox\Resource\Page\First; | |
use BEAR\Framework\Resource\AbstractPage; | |
/** | |
* Greeting page | |
*/ | |
class Greeting extends AbstractPage | |
{ | |
/** | |
* Contents | |
* | |
* @var array | |
*/ | |
public $body = [ | |
'greeting' => '' | |
]; | |
/** | |
* Get | |
* | |
* @param string $name | |
*/ | |
public function onGet($name = 'World') | |
{ | |
$this->body['greeting'] = sprintf('Hello, %s', $name); | |
return $this; | |
} | |
} |
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 | |
namespace sandbox\Resource\Page\First; | |
use BEAR\Framework\Resource\AbstractPage; | |
use BEAR\Framework\Inject\ResourceInject; | |
/** | |
* Greeting page | |
*/ | |
class Greeting extends AbstractPage | |
{ | |
use ResourceInject; | |
/** | |
* Contents | |
* | |
* @var array | |
*/ | |
public $body = [ | |
'greeting' => '' | |
]; | |
/** | |
* Get | |
* | |
* @param string $name | |
*/ | |
public function onGet($name = 'World') | |
{ | |
$this->body['greeting'] = $this->resource | |
->get | |
->uri('app://self/first/greeting') | |
->withQuery(['name' => $name]) | |
->request(); | |
return $this; | |
} | |
} |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<body> | |
<h1>{$greeting|escape}</h1> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment