{"id":9931,"date":"2019-06-22T09:43:31","date_gmt":"2019-06-22T00:43:31","guid":{"rendered":"https:\/\/www.itblog.jp\/?p=9931"},"modified":"2019-06-22T09:43:31","modified_gmt":"2019-06-22T00:43:31","slug":"cakephp%e3%81%aeflashcomponent%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/www.itblog.jp\/?p=9931","title":{"rendered":"CakePHP\u306eFlashComponent\u306b\u3064\u3044\u3066"},"content":{"rendered":"\n<p>CakePHP\u306eFlashComponent\u306b\u3064\u3044\u3066\u306e\u89e3\u8aac\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u3067\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u306b\u89e3\u8aac\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/book.cakephp.org\/3.0\/ja\/controllers\/components\/flash.html\">\u30d5\u30e9\u30c3\u30b7\u30e5<\/a><\/p>\n\n\n\n<p>\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u89e3\u8aac\u304c\u5206\u304b\u308a\u306b\u304f\u3044\u306e\u3067\u3001\u81ea\u5206\u6d41\u306e\u89e3\u91c8\u3067\u3059\u304c\u3001FlashComponent\u306f\u3001\u7279\u5b9a\u306e\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30b5\u30a4\u30c8\u3067\u8868\u793a\u3059\u308b\u306e\u306b\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>Session\u306b\u8868\u793a\u3059\u308b\u30c7\u30fc\u30bf\u3092\u4fdd\u5b58\u3057\u3066\u3001\u753b\u9762\u9077\u79fb\u5f8c\u306b\u8868\u793a\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u666e\u901a\u306b\u30a8\u30e9\u30fc\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u8868\u793a\u3059\u308b\u5834\u5408\u3068\u6bd4\u8f03\u3059\u308b\u3068\u3001\u8868\u793a\u3059\u308b\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u4fdd\u5b58\u3057\u3066\u3001\u753b\u9762\u9077\u79fb\u5f8c\u306e\u8868\u793a\u306b\u4f7f\u3046\u4e8b\u304c\u3067\u304d\u308b\u7279\u5fb4\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u4f7f\u3044\u65b9<\/h2>\n\n\n\n<p>Controller\u3067\u4ee5\u4e0b\u306e\u5b9a\u7fa9<\/p>\n\n\n\n<p>public function initialize()    {   <\/p>\n\n\n\n<p>        parent::initialize();<br>        $this->loadComponent(&#8216;Flash&#8217;); \/\/ Include the FlashComponent <\/p>\n\n\n\n<p>}<\/p>\n\n\n\n<p>\u8868\u793a\u3057\u305f\u3044\u30c7\u30fc\u30bf\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u4f7f\u3046\u3002<\/p>\n\n\n\n<p>\/\/\u6210\u529f\u3057\u305f\u5834\u5408\u51fa\u529b\u3002\u30ea\u30c0\u30a4\u30ec\u30af\u30c8\u5f8c\u306e\u30da\u30fc\u30b8\u3067\u8868\u793a\u3055\u308c\u308b<\/p>\n\n\n\n<p>success\u3084error\u306a\u3069\u306e\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306f\u3001\/sec\/Template\/Element\/Flash\u4ee5\u4e0b\u306b\u3042\u308b\u306e\u3067\u8ffd\u52a0\u3084\u7de8\u96c6\u3082\u53ef\u80fd\u3002<\/p>\n\n\n\n<p>$this->Flash->success(__(&#8216;Your article has been saved.&#8217;));<\/p>\n\n\n\n<p>$this->Flash->error(__(&#8216;Unable to add your article.&#8217;));<\/p>\n\n\n\n<p>\u30c6\u30f3\u30d7\u30ec\u30fc\u30c8\u306e\u4ee5\u4e0b\u306e\u8a18\u8ff0\u306e\u5834\u6240\u306bFlash\u30e1\u30c3\u30bb\u30fc\u30b8\u304c\u8868\u793a\u3055\u308c\u308b<\/p>\n\n\n\n<p>&lt;?= $this-&gt;Flash-&gt;render() ?&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CakePHP\u306eFlashComponent\u306b\u3064\u3044\u3066\u306e\u89e3\u8aac\u3067\u3059\u3002 \u516c\u5f0f\u30b5\u30a4\u30c8\u3067\u306f\u4ee5\u4e0b\u306e\u30da\u30fc\u30b8\u306b\u89e3\u8aac\u304c\u3042\u308a\u307e\u3059\u3002 \u30d5\u30e9\u30c3\u30b7\u30e5 \u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u89e3\u8aac\u304c\u5206\u304b\u308a\u306b\u304f\u3044\u306e\u3067\u3001\u81ea\u5206\u6d41\u306e\u89e3\u91c8\u3067\u3059\u304c\u3001FlashComponent\u306f\u3001\u7279\u5b9a\u306e\u30e1 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[165,131],"tags":[],"class_list":["post-9931","post","type-post","status-publish","format-standard","hentry","category-cakephp","category-131"],"_links":{"self":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9931","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=9931"}],"version-history":[{"count":0,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=\/wp\/v2\/posts\/9931\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=9931"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=9931"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itblog.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=9931"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}