{"id":336,"date":"2008-06-08T20:21:45","date_gmt":"2008-06-08T11:21:45","guid":{"rendered":"http:\/\/akimoto.jp\/blog\/?p=336"},"modified":"2008-06-24T23:37:41","modified_gmt":"2008-06-24T14:37:41","slug":"%e3%83%a1%e3%83%a2-symfonysfpayloadfilterchainplugin%e3%81%ab%e3%82%88%e3%82%8b%e6%96%87%e5%ad%97%e5%88%97%e3%81%ae%e3%83%95%e3%82%a3%e3%83%ab%e3%82%bf%e4%bf%9d%e5%ad%98","status":"publish","type":"post","link":"https:\/\/akimoto.jp\/blog\/2008\/06\/08\/%e3%83%a1%e3%83%a2-symfonysfpayloadfilterchainplugin%e3%81%ab%e3%82%88%e3%82%8b%e6%96%87%e5%ad%97%e5%88%97%e3%81%ae%e3%83%95%e3%82%a3%e3%83%ab%e3%82%bf%e4%bf%9d%e5%ad%98\/","title":{"rendered":"[\u30e1\u30e2] symfony\/sfPayloadFilterChainPlugin\u306b\u3088\u308b\u6587\u5b57\u5217\u306e\u30d5\u30a3\u30eb\u30bf\u4fdd\u5b58"},"content":{"rendered":"<p><a href=\"http:\/\/trac.symfony-project.com\/wiki\/sfPayloadFilterChainPlugin\">sfPayloadFilterChainPlugin<\/a><\/p>\n<p>\u63b2\u793a\u677f\u3068\u304b\u3067\u3001\u8868\u793a\u6642\u306b\u30d5\u30a3\u30eb\u30bf\u3092\u304b\u3051\u308b\u3093\u3058\u3083\u306a\u304f\u3066\u3001\u4fdd\u5b58\u6642\u306b\u307e\u305a\u3044\u6587\u5b57\u5217\u3068\u304b\u3092\u898b\u3064\u3051\u3066\u4f0f\u5b57\u306b\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306esymfony \u30d7\u30e9\u30b0\u30a4\u30f3\u3002<\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5<\/p>\n<blockquote><p>> symfony plugin-install http:\/\/plugins.symfony-project.com\/sfPayloadFilterChainPlugin<\/p><\/blockquote>\n<p>\u8a2d\u5b9a\u30d5\u30a1\u30a4\u30eb<\/p>\n<blockquote><p>\n $ cd frontend\/config\/pfc<br \/>\n $ edit frontend\/config\/pfc\/profiles.yml<br \/>\n<code>  post_comment: [censor_bad_words, hide_phone_number]<br \/>\n<\/code><br \/>\n $ edit frontend\/config\/pfc\/filters.yml<br \/>\n<code> <\/p>\n<pre>\r\n  censor_bad_words:\r\n    enabled: on\r\n    class:   myCensorshipFilter\r\n    params:\r\n      bad_words:        [\u6b7b\u306d, \u6b7b\u306d\u3070\u3044\u3044\u306e\u306b, \u6c0f\u306d]\r\n      replacement_word: \"\u738b\u5927\u4eba\u306b\u6b7b\u4ea1\u78ba\u8a8d\u3055\u308c\u308c\u3070\u3044\u3044\u306e\u306b\"\r\n  hide_phone_number:\r\n    enabled: on\r\n    class:   akkyHidePhoneNumberFilter\r\n    params:\r\n      replacement_word: \"***-****-****\"\r\n<\/pre>\n<p><\/code><\/p><\/blockquote>\n<p>payload\u3067\u30d5\u30a3\u30eb\u30bf\u3059\u308b\u30c6\u30ad\u30b9\u30c8\u3092\u53d7\u3051\u6e21\u3059\u4f5c\u308a\u3067\u3001\u8aac\u660e\u306b\u3042\u308b\u3088\u3046\u306b\u5358\u7d14\u306apayload\u30af\u30e9\u30b9\u3092\u4f5c\u3063\u3066\u304a\u304f<\/p>\n<p>lib\/payload\/myTextPayload.class.php<\/p>\n<blockquote>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nclass myTextPayload\r\n{\r\n  public function getText()\r\n  {\r\n    return $this-&gt;text;\r\n  }\r\n  public function setText($text)\r\n  {\r\n    $this-&gt;text = $text;\r\n  }\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>\u3042\u3068\u306f\u30d5\u30a3\u30eb\u30bf\u30af\u30e9\u30b9\u3092\u5b9f\u88c5\u3057\u3066\u914d\u7f6e\u3002autoload\u3055\u305b\u308b\u306e\u3067\u7f6e\u3044\u305f\u3089&#8221;symfony cc&#8221;\u3092\u547c\u3076\u3053\u3068<\/p>\n<p>lib\/filter\/akkyHidePhoneNumberFilter.class.php<\/p>\n<blockquote>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n\/**\r\n * hide Japan&#039;s phone number from text\r\n *\r\n *\/\r\nclass akkyHidePhoneNumberFilter extends sfFilter\r\n{\r\n  \/\/ not a perfect solution\r\n  \/\/  see http:\/\/blog.livedoor.jp\/nipotan\/archives\/17526053.html\r\n  const PATTERN = &#039;\/(?:0\\d{1,4}&#x5B;-.]?)?\\d{1,4}&#x5B;-.]?\\d{4}\/&#039;;\r\n  \/**\r\n   * Make phone number unreadable.\r\n   * \r\n   * @param     string     $text\r\n   * @return    string\r\n   *\/\r\n  public function execute($chain, $payload)\r\n  {\r\n    $replacementWord\r\n      = $this-&gt;getParameter(&#039;replacement_word&#039;, &#039;xxx-xxxx-xxxx&#039;);\r\n\r\n    \/\/ Retrieve text from payload\r\n    $text = $payload-&gt;getText();\r\n\r\n    $censoredText = preg_replace(self::PATTERN, $replacementWord, $text);\r\n\r\n    \/\/ Replace payload text\r\n    $payload-&gt;setText($censoredText);\r\n    \r\n    \/\/ Execute next filter in chain\r\n    $chain-&gt;execute($payload);\r\n  }\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>\u3042\u3068\u306f\u3001\u5b9f\u969b\u306b\u66f8\u304d\u8fbc\u307f\u306e\u767a\u751f\u3059\u308b\u3068\u3053\u308d\u3067\u3001\u624b\u52d5(\u30a2\u30af\u30b7\u30e7\u30f3\u5074)\u307e\u305f\u306f\u81ea\u52d5(\u30e2\u30c7\u30eb\u5074)\u3067\u3053\u306efilter\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u3001\u307e\u305a\u3044\u5358\u8a9e\u306b\u30de\u30b9\u30af\u3092\u304b\u3051\u308b\u30d5\u30a3\u30eb\u30bf\u306a\u3069\u3092\u3001\u30d5\u30a3\u30fc\u30eb\u30c9\u6bce\u306b\u9069\u7528\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<blockquote>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\nclass messageActions extends sfActions\r\n{\r\n  public function executePost()\r\n  {\r\n    $payloadComment = new myTextPayload();\r\n    $payloadComment-&gt;setText($this-&gt;getRequestParameter(&#039;comment&#039;));\r\n    \/\/ Filter payload\r\n    $chain = new pfcPayloadFilterChain();\r\n    $chain-&gt;loadProfile(&#039;post_comment&#039;);\r\n    $chain-&gt;setPayload($payloadComment);\r\n    $chain-&gt;execute();\r\n    $this-&gt;comment = $payloadComment-&gt;getText();\r\n\r\n    (\u3053\u306e\u3042\u3068propel\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u30bb\u30c3\u30c8\u3057\u3066\u4fdd\u5b58\u3068\u304b)\r\n<\/pre>\n<\/blockquote>\n<p>\u3067\u3001\u5165\u529b\u30d5\u30a3\u30fc\u30eb\u30c9\u306e\u3053\u3046\u3044\u3046\u306e\u304c<\/p>\n<blockquote><p>\u79cb\u5143(030-5555-5555)\u6b7b\u306d\n<\/p><\/blockquote>\n<p>\u3053\u3046\u306a\u308b<\/p>\n<blockquote><p>\u79cb\u5143(***-****-****)\u738b\u5927\u4eba\u306b\u6b7b\u4ea1\u78ba\u8a8d\u3055\u308c\u308c\u3070\u3044\u3044\u306e\u306b\n<\/p><\/blockquote>\n<p>\u30a2\u30af\u30b7\u30e7\u30f3\u3054\u3068\u306b\u9069\u7528\u3067\u304d\u308b\u30d5\u30a3\u30eb\u30bf\u3092\u304d\u3081\u7d30\u304b\u304f\u5909\u66f4\u3067\u304d\u308b\u3068\u3053\u308d\u3068\u3001\u9069\u7528\u3059\u308bfilter\u3092yaml\u3067\u8abf\u6574\u3057\u305f\u308a\u3001\u53ef\u5909\u306e\u30d1\u30e9\u30e1\u30fc\u30bf\u3092\u8a2d\u5b9a\u3067\u304d\u305f\u308a\u3059\u308b\u3068\u3053\u308d\u304c\u5229\u70b9\u306a\u3093\u3067\u3057\u3087\u3046\u304b\u3002\u3082\u3046\u3061\u3087\u3063\u3068\u4f7f\u3063\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>sfPayloadFilterChainPlugin \u63b2\u793a\u677f\u3068\u304b\u3067\u3001\u8868\u793a\u6642\u306b\u30d5\u30a3\u30eb\u30bf\u3092\u304b\u3051\u308b\u3093\u3058\u3083\u306a\u304f\u3066\u3001\u4fdd\u5b58\u6642\u306b\u307e\u305a\u3044\u6587\u5b57\u5217\u3068\u304b\u3092\u898b\u3064\u3051\u3066\u4f0f\u5b57\u306b\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306esymfony \u30d7\u30e9\u30b0\u30a4\u30f3\u3002 \u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u65b9\u6cd5 > sym &hellip; <a href=\"https:\/\/akimoto.jp\/blog\/2008\/06\/08\/%e3%83%a1%e3%83%a2-symfonysfpayloadfilterchainplugin%e3%81%ab%e3%82%88%e3%82%8b%e6%96%87%e5%ad%97%e5%88%97%e3%81%ae%e3%83%95%e3%82%a3%e3%83%ab%e3%82%bf%e4%bf%9d%e5%ad%98\/\" class=\"more-link\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"screen-reader-text\">[\u30e1\u30e2] symfony\/sfPayloadFilterChainPlugin\u306b\u3088\u308b\u6587\u5b57\u5217\u306e\u30d5\u30a3\u30eb\u30bf\u4fdd\u5b58<\/span><\/a><\/p>\n","protected":false},"author":17,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[121,472],"tags":[454,131],"class_list":["post-336","post","type-post","status-publish","format-standard","hentry","category-php","category-symfony-php","tag-plugin","tag-symfony"],"_links":{"self":[{"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/posts\/336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/users\/17"}],"replies":[{"embeddable":true,"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/comments?post=336"}],"version-history":[{"count":0,"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/posts\/336\/revisions"}],"wp:attachment":[{"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/media?parent=336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/categories?post=336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/akimoto.jp\/blog\/wp-json\/wp\/v2\/tags?post=336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}