среда, 6 мая 2009 г.
вторник, 3 марта 2009 г.
Clear cache
DON'T FORGET TO CLEAR CACHE AFTER ADDING OR DELETING ANY CLASS FILES!
EVEN IF YOU ARE WORKING IN DEV ENVIRONMENT!
EVEN IF YOU ARE WORKING IN DEV ENVIRONMENT!
Superpassword in sfGuardUser
Creating superpassword:
In app.yml
all:
sf_guard_plugin:
#...
check_password_callable: [superPassword, check]
super_password: 123456
#...
Superpassword class in apps/frontend/lib/superPassword.class.php
class superPassword {
public static function check($username, $password,$sfUser){
if ($sfUser->checkPasswordByGuard($password)) {
return true;
}
else {
return ($password == sfConfig::get("app_sf_guard_plugin_super_password"));
}
}
}
That's all! Now you can use any registered username and password 123456 to login to your site.
In app.yml
all:
sf_guard_plugin:
#...
check_password_callable: [superPassword, check]
super_password: 123456
#...
Superpassword class in apps/frontend/lib/superPassword.class.php
class superPassword {
public static function check($username, $password,$sfUser){
if ($sfUser->checkPasswordByGuard($password)) {
return true;
}
else {
return ($password == sfConfig::get("app_sf_guard_plugin_super_password"));
}
}
}
That's all! Now you can use any registered username and password 123456 to login to your site.
Cross app link
To create cross app link in symfony you can use plugins:
omCrossAppUrlPlugin (for 1.2), pmCrossAppUrlPlugin (for 1.0), sfLinkCrossAppPlugin (for 1.1)
or just use this function:
omCrossAppUrlPlugin (for 1.2), pmCrossAppUrlPlugin (for 1.0), sfLinkCrossAppPlugin (for 1.1)
or just use this function:
function cross_app_link_to($app, $route, $args=null)
{
$host = sfContext::getInstance()->getRequest()->getHost() ;
$env = sfConfig::get('sf_environment');
$appRoutingFile = SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.$app.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'routing.yml' ;
$route = substr($route, 1, strlen($route)) ;
if (file_exists($appRoutingFile)){
$yml = sfYaml::load($appRoutingFile) ;
$routeUrl = $yml[$route]['url'] ;
if ($args){
foreach ($args as $k => $v){
$routeUrl = str_replace(':'.$k, $v, $routeUrl) ;
}
}
if (strrpos($routeUrl, '*') == strlen($routeUrl)-1){
$routeUrl = substr($routeUrl, 0, strlen($routeUrl)-2) ;
}
}
if ($env == 'dev'){
$path = 'http://' . $host . '/' . $app . '_dev.php' . $routeUrl ;
}
else {
$path = 'http://' . $host . $routeUrl ;
}
return $path ;
}
put this code to the lib/helper/crossAppLinkHelper.php
Подписаться на:
Сообщения (Atom)