sfDoctrineApplyPluginその2

| コメント(6) | トラックバック(0)

sfDoctrineApplyPluginを動かすまでに結構苦労した。参考にした情報は、主に以下の2つ。

  1. 公式のREADME
  2. このページ(英語)。

以下、自分がやった方法を書くが、バージョン依存の点も結構ありそうなので要注意。

■まずは環境

  • symfony 1.4.3
  • sfDoctrineApplyPlugin 1.1.1

 

■テーブルレイアウト

 2.のページにはREADME通りだと上手く行かないと書かれているが、結論からするとそのままで問題なかった。念のため、以下にschema.ymlを抜粋して記載。

sfGuardUserProfile:
  columns:
    id:        { type: integer(4), primary: true, autoincrement: true }
    user_id:   { type: integer(4), notnull: true }
    fullname:  { type: string(80) }
    email:     { type: string(80) }
    validate:  { type: string(17)  }
  relations:
    User:
      class: sfGuardUser
      local: user_id
      foreign: id
      type: one
      foreignType: one
      foreignAlias: Profile
      onDelete: CASCADE

fullnameで一つのフィールドって言うのはセンスなさ過ぎってつっこみは2.のページにも沢山入ってるが、とりあえずは今後の課題に残しておいて次に進む。

■Zend Frameworkを使わないようにソースを修正

 基本は2のページの「3. Getting rid of Zend_Mailer」の手順+そこよりもう少し下にある「createGuid()」をコピペするだけ。

英語が全くダメな人向けに一応書くと、apps/frontend/modules/sfApply/actions/action.class.phpでsfApplyActionsを定義(BasesfApplyActionsを継承)する。で、その中に以下の3つのメソッドがある形になる。

  • executeApply
  • mail
  • createGuid

■メールの設定(必要に応じて)

factories.ymlより抜粋。設定の仕方はこのページが参考になった。

  mailer:
    class: sfMailer
    param:
      logging:           %SF_LOGGING_ENABLED%
      charset:           %SF_CHARSET%
      delivery_strategy: realtime
      transport:
        class: Swift_SmtpTransport
        param:
          host:       192.168.1.2
          port:       25

■モジュールの有効化、routing.ymlへの追記

この辺はREADME通り。

settings.ymlに以下の記述。

    enabled_modules:    [default, sfGuardAuth, sfApply]

routing.ymlもREADME通り。

■権限の設定

今までので大体動きそうな気がするんだけど、sfApply/applyにアクセスするとログイン画面に戻されてしまう。ユーザーアカウントを作るための画面にアクセスしようとしてログイン画面に飛ばされるなんておかしい。ログを確認すると以下のようなのが。

5 03 18:27:33 symfony [info] {sfBasicSecurityFilter} Action "sfApply/apply" requires authentication, forwarding to "sfGuardAuth/signin"

うーん、これに関しては参考にした2つのページでは一言も触れられていなかったので、もしかしたら自分のインストールがどっかおかしいのかもしれないけど、とりあえずsecurity.ymlに以下のような記述を追加した。

apply:
  is_secure: false

confirm:
  is_secure: false

all:
  is_secure: true

以上でとりあえず動作するようになった。

トラックバック(0)

トラックバックURL: http://www.kazu.tv/blog-mgr/mt-tb.cgi/927

コメント(6)

ハロー!

私はGoogleの翻訳を使用しています。私は自分のプロジェクトを使用して記事を読んだ後ていた問題を修正ために私はあなたに感謝したい。

ありがとうございました!

Hi Ricardo,

I'm not sure about what you meant cuz it's a machine translation... It seems like this entry helped you a bit or something like that? If you have any other questions, feel free to ask me here.

sfDoctrineGuardPlugin 1.0.4 ですと
sfGuardUser.id が integer なので
sfGuardUserProfile の外部キー user_id がうまくはれません。

なので下記のようにしました。

01.sfGuardUserProfile:
02. columns:
03. id: { type: integer, primary: true, autoincrement: true }
04. user_id: { type: integer, notnull: true }

say4nockさん、コメントありがとうございます。

言われてみると、1.1.1でもその辺を何かいじった記憶があります。うろ覚えですが。

プラグインのバージョンによって仕様などが結構変わっていて、本文中で紹介したページの内容がそのまま使えなかったりして、まだまだ一般の人が使うには厳しいプラグインかなって気がしますね。

Hi kazu,

I came through google searching regarding specific symfony sfdoctrineguard plugin configuration issue (excerpt about security.yml) which i'm able to get it fixed after reading your post.

As i'm not japanese reader and do not know the language google translated the page for me and i was able to read it and get my issue fixed.

A big thanks to you. keep up the great work.

cheers

Shirish
(from australia)

Hi Shirish,

Glad to hear that this entry helped you solve your issue. I haven't used symfony in a long time, but I hope 2.0 will be better.

Cheers,
Kazu

コメントする

このブログの作者

名前:kazu
仕事:IT関係の何でも屋
メール:kazu 後幕 kazu どと tv
詳しくはこの辺

このブログ記事について

このページは、kazuが2010年5月 4日 00:36に書いたブログ記事です。

ひとつ前のブログ記事は「無料オンライン英会話、もうすぐ開始」です。

次のブログ記事は「自宅サーバーからOCN経由でメール送信」です。

最近のコンテンツはインデックスページで見られます。過去に書かれたものはアーカイブのページで見られます。

ウェブページ