{"id":734,"date":"2009-02-14T00:37:11","date_gmt":"2009-02-13T15:37:11","guid":{"rendered":"http:\/\/www.kazu.tv\/blog\/?p=734"},"modified":"2009-02-14T00:37:11","modified_gmt":"2009-02-13T15:37:11","slug":"sfguardplugin","status":"publish","type":"post","link":"https:\/\/kazu.tv\/blog\/2009\/02\/14\/sfguardplugin\/","title":{"rendered":"sfGuardPlugin"},"content":{"rendered":"<p>symfony\uff081.1\uff09\u3092\u4f7f\u3063\u3066\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u4e2d\u3001\u30e6\u30fc\u30b6\u30fc\u8a8d\u8a3c\u304c\u5fc5\u8981\u306b\u306a\u3063\u305f\u3002\uff08\u3068\u3044\u3046\u304b\u6700\u521d\u304b\u3089\u5fc5\u8981\u3060\u3063\u305f\u3093\u3060\u3051\u3069\u3002\uff09<\/p>\n<p>sf_sandbox\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u4f7f\u308f\u308c\u3066\u3044\u305fsfGuardPlugin\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u305f\u3002\u65e5\u672c\u8a9e\u306b\u8a33\u3055\u308c\u3066\u3044\u308b<a href=\"http:\/\/code.google.com\/p\/symfony-doc-ja\/wiki\/sfGuardPlugin\">\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>\u3082\u3042\u308b\u3002\u57fa\u672c\u7684\u306a\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306e\u65b9\u6cd5\u306f\u305d\u3063\u3061\u3092\u898b\u3066\u6b32\u3057\u3044\u3002<\/p>\n<p>\u3053\u3053\u3067\u66f8\u304f\u306e\u306f\u300csfAuthUser\u30e2\u30c7\u30eb\u3092\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3059\u308b\u300d\u3088\u308a\u5148\u306e\u8a71\u3002\u3055\u3063\u304d\u306e\u30da\u30fc\u30b8\u306b\u66f8\u3044\u3066\u3042\u308b\u901a\u308a\u3001sfGuardPlugin\u3092\u666e\u901a\u306b\u4f7f\u3046\u3068\u30e6\u30fc\u30b6\u30fc\u540d\u3001\u30d1\u30b9\u30ef\u30fc\u30c9\u3001\u6709\u52b9\u30fb\u7121\u52b9\u30d5\u30e9\u30b0\u3001\u6700\u7d42\u30ed\u30b0\u30a4\u30f3\u65e5\u7a0b\u5ea6\u306e\u60c5\u5831\u3057\u304b\u4fdd\u5b58\u3067\u304d\u306a\u3044\u3002\u3057\u304b\u3057\u3001\u666e\u901a\u306b\u30b7\u30b9\u30c6\u30e0\u3092\u4f5c\u308b\u5834\u5408\u3001\u30e6\u30fc\u30b6\u30fc\u30c6\u30fc\u30d6\u30eb\u306b\u540d\u524d\u3001\u4f4f\u6240\u3001\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u7b49\u306e\u60c5\u5831\u3092\u6301\u305f\u305b\u305f\u3044\u306f\u305a\u3002<\/p>\n<p>sfGuardPlugin\u3067\u306fsfGuardUserProfile\u3068\u3044\u3046\u3001\u5916\u90e8\u30c6\u30fc\u30d6\u30eb\u3068\u9023\u4fc2\u3059\u308b\u4ed5\u7d44\u307f\u3092\u6301\u3063\u3066\u308b\u306e\u3067\u305d\u308c\u3092\u4f7f\u7528\u3002<\/p>\n<p>Customer\u3068\u3044\u3046\u30af\u30e9\u30b9\uff08customer\u30c6\u30fc\u30d6\u30eb\uff09\u306b\u4ed8\u52a0\u60c5\u5831\u3092\u6301\u305f\u305b\u3066\u3001sfGuardUser\u30681\u5bfe1\u3067\u30ea\u30ec\u30fc\u30b7\u30e7\u30f3\u3055\u305b\u308b\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u307e\u305a\u306fschema.yml\u304b\u3089\u3002customer\u30c6\u30fc\u30d6\u30eb\u306euser_id\u30d5\u30a3\u30fc\u30eb\u30c9\u3068sf_guard_user\u30c6\u30fc\u30d6\u30eb\u306eid\u30d5\u30a3\u30fc\u30eb\u30c9\u3092join\u3059\u308b\u3002<\/p>\n<pre><code>propel:\ncustomer:\n_attributes: { phpName: Customer }\nid:           ~\nuser_id:\ntype: integer\nforeignTable: sf_guard_user\nforeignReference: id\nrequired: true\nonDelete: cascade\ncustomer_name:      { type: varchar(255), required: true, index: unique }\ncreated_at:   ~<\/code><\/pre>\n<p>onDelete\u3092cascade\u306b\u3057\u3066\u3001customer\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u30ec\u30b3\u30fc\u30c9\u3092\u524a\u9664\u3057\u305f\u6642\u306b\u3001\u95a2\u9023\u3059\u308b\u30ec\u30b3\u30fc\u30c9\u3092sf_guard_user\u304b\u3089\u3082\u524a\u9664\u3055\u308c\u308b\u3088\u3046\u306b\u3059\u308b\u3002<\/p>\n<p>\u6b21\u306fapps\/app_name\/modules\/customer\/config\/generator.yml\u3002<\/p>\n<pre><code>generator:\nclass:              sfPropelAdminGenerator\nparam:\nmodel_class:      Customer\ntheme:            default\nfields:\ncustomer_name:  { type: input_tag, params: size=30, name: \u304a\u5ba2\u69d8\u540d }\n#sfGuardUser\nusername:       { name: \u30e6\u30fc\u30b6\u30fc\u540d }\npassword:       { name: \u30d1\u30b9\u30ef\u30fc\u30c9 }\npassword_bis:   { name: \u30d1\u30b9\u30ef\u30fc\u30c9\uff08\u78ba\u8a8d\uff09 }\nis_active:      { name: \u6709\u52b9\u306a\u30e6\u30fc\u30b6\u30fc }\nlist:\ntitle:          \u304a\u5ba2\u69d8\u4e00\u89a7\nlayout:         tabular\ndisplay:        [=customer_name, username, is_active]\nobject_actions:\n_edit:        ~\n_delete:      ~\nmax_per_page:   20\nedit:\ntitle:          \u304a\u5ba2\u69d8\u60c5\u5831\u306e\u7de8\u96c6\ndisplay:\n\"\u30ed\u30b0\u30a4\u30f3\u60c5\u5831\": [ _username, _password, _password_bis, _is_active ]\n\"\u305d\u306e\u4ed6\u60c5\u5831\": [ customer_name ]\nactions:\n_list:\n_save:\n_delete:\n<\/code><\/pre>\n<p>\u3053\u3053\u3067\u306e\u30dd\u30a4\u30f3\u30c8\u306f\u3001\u3061\u3087\u3063\u3068\u9762\u5012\u304f\u3055\u3044\u3051\u3069\u3001sf_guard_user\u306e\u60c5\u5831\u3092\u7de8\u96c6\u3059\u308b\u90e8\u5206\u306f\u30d1\u30fc\u30b7\u30e3\u30eb\uff08partial\uff09\u3092\u4f7f\u7528\u3059\u308b\u4e8b\u3002\u5177\u4f53\u7684\u306b\u306f_username, _password, _password_bis, _is_active\u306e4\u3064\u3002<\/p>\n<p>_username.php\u306f\u3053\u3093\u306a\u611f\u3058\u3002\u30e6\u30fc\u30b6\u30fc\u540d\u306f\u5909\u66f4\u4e0d\u53ef<\/p>\n<pre><code>&lt;?php\nif ($customer-&gt;isNew()) {\necho object_input_tag($customer, 'getUsername',\narray ('size' =&gt; 64,\n'control_name' =&gt; 'customer[username]'));\n} else {\necho $customer-&gt;getUsername();\n}\n?&gt;<\/code><\/pre>\n<p>_password.php\u306f\u3053\u3093\u306a\u306e\uff08_password_bis.php\u3082\u540c\u69d8\uff09\u3002<\/p>\n<pre><code>&lt;?php\necho input_password_tag('password', '');\n?&gt;<\/code><\/pre>\n<p>\u3067\u3001\u3042\u3068\u306factions.class.php\u306eupdateCustomerFromRequest\u3092\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u305f\u3002<\/p>\n<pre><code>  protected function updateCustomerFromRequest()\n{\n\/\/ \u30ea\u30af\u30a8\u30b9\u30c8\u30d1\u30e9\u30e1\u30fc\u30bf\u306e\u53d6\u5f97\n$customer = $this-&gt;getRequestParameter('customer');\n$password = $this-&gt;getRequestParameter('password');\n$password2 = $this-&gt;getRequestParameter('password_bis');\n\/\/ \u30d1\u30b9\u30ef\u30fc\u30c9\u304c\u30bb\u30c3\u30c8\u3055\u308c\u3066\u3044\u3066\u3001\u78ba\u8a8d\u7528\u306e\u5165\u529b\u3068\u30de\u30c3\u30c1\u3059\u308b\u306a\u3089\nif (isset($password) &amp;&amp; $password === $password2)\n{\n$this-&gt;customer-&gt;setPassword($password);\n}\n\/\/ \u6b8b\u308a\u306f\u89aa\u30af\u30e9\u30b9\u306b\u4efb\u305b\u308b\nparent::updateCustomerFromRequest();\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>symfony\uff081.1\uff09\u3092\u4f7f\u3063\u3066\u30b7\u30b9\u30c6\u30e0\u3092\u69cb\u7bc9\u4e2d\u3001\u30e6\u30fc\u30b6\u30fc\u8a8d\u8a3c\u304c\u5fc5\u8981\u306b\u306a\u3063\u305f\u3002\uff08\u3068\u3044\u3046\u304b\u6700\u521d\u304b\u3089\u5fc5\u8981\u3060\u3063\u305f\u3093\u3060\u3051\u3069\u3002\uff09 sf_sandbox\u306e\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u3067\u4f7f\u308f\u308c\u3066\u3044\u305fsfGuardPlugin\u3092\u4f7f\u3046\u3053\u3068\u306b\u3057\u305f\u3002\u65e5\u672c\u8a9e&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[401],"tags":[453,454,455,442,456],"class_list":["post-734","post","type-post","status-publish","format-standard","hentry","category-php","tag-453","tag-sfguardplugin","tag-sfguarduserprofile","tag-symfony","tag-456"],"_links":{"self":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/posts\/734","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/comments?post=734"}],"version-history":[{"count":0,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/posts\/734\/revisions"}],"wp:attachment":[{"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/media?parent=734"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/categories?post=734"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kazu.tv\/blog\/wp-json\/wp\/v2\/tags?post=734"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}