$sf_context->getActionStack()->getLastEntry()->getActionInstance()->isSecure()
2009-04-25
Get is_secure of current action
Ever wondered if a currently running action is secure?
Try
2009-04-21
Calling submit method doesn't trigger onsubmit event
First, this is the proper behavior, as David Flanagan writes in his book.
Second, how to overcome this?
Suppose you have TinyMCE control embedded in a form. It sets his callback on a form's onsubmit to clean himself up and write all the stuff back to parent textarea. If you have a link that triggers submit(), just create a hidden <input type="submit"> and call click() on it.
Click on submit button does trigger the onsubmit event of a form, giving TinyMCE a chance to properly save his contents.
2009-03-03
Dev controllers in the wild
Funny how many people forget to hide their dev controllers after deployment.
2009-03-02
Handy Eclipse shortcut
There is a hotkey in Eclipse which behavior is close to Alt+Tab: press Alt+[left arrow]/[right arrow] to jump between your opened editors.
2009-02-26
Proper Propel behavior registration
Suppose you add a propel behavior using this code:
This happens because of symfony autoloading mechanism:
Registering behaviors in projectConfiguration doesn't work.
The only solution I found is to register them in plugin's config.php.
sfPropelBehavior::add('Article', array(
'positioned'
));
Now, where to put it? The cookbook suggests it should be put "in lib/model/Article.php". But what if your behavior includes hooks for peer classes, and in a certain action you call peer methods before using model classes (which is rather common)? In this case you might end up without any behavior attached before the first call of any peer method.
This happens because of symfony autoloading mechanism:
- Peer class method is called
- It is not found, so autoloading steps in
- Peer class is loaded
- Peer class method is executed
- Model class is loaded
- Propel behavior is added
- Result set is hyrdated
- ...
Registering behaviors in projectConfiguration doesn't work.
The only solution I found is to register them in plugin's config.php.
Propel Behaviors: registering hooks for doSelectRS
If you read the chapter of symfony cookbook which talks about Propel behaviors, and tried to register a hook for doSelectRS, you'd find out it doesn't work.
In fact, doSelectRS was removed as of symfony 1.2. doSelectStmt took its place, so if you want to add a hook to selecting records, you should write something like this:
In fact, doSelectRS was removed as of symfony 1.2. doSelectStmt took its place, so if you want to add a hook to selecting records, you should write something like this:
sfPropelBehavior::registerHooks('positioned', array(
'Peer:doSelectStmt:doSelectStmt' => array('wgPropelPositionedBehavior', 'addAscendingOrderByPosition'),
));
2009-02-25
How to get all action variables
For my programming work, I use symfony framework. It has a funny system of passing variables from actions to templates: you just set the variable as a property of your action object and it automatically becomes available in template that is used to render results. So, there is a bunch of variables you can use, but no way of getting the whole array of them. This line will do the trick:
$vars = $sf_context->getActionStack()->getLastEntry()->getActionInstance()->getVarHolder()->getAll();
Подписаться на:
Сообщения (Atom)