HOWTO: install add-apt-repository on Ubuntu 12.04

Many sources say that installing the ‘python-software-properties’ package would fix it, but I had to install ‘software-properties-common’

apt-get install software-properties-common

Done!

HOWTO: Symfony 1.4 – Only load an plugin for a given application

Sometimes you’ll want to include a plugin, such as an admin generator, that will load stylesheets or javascript files that you may not want loaded in all applications.

You could add the following to your template file: (apps/frontend/templates/layout.php)

$sf_response->removeStylesheet('/m14tAdminGeneratorPlugin/css/admin.css');

But that just feels wrong. So instead, lets only load the plugin for the application that we want (config/ProjectConfiguration.class.php):

class ProjectConfiguration extends sfProjectConfiguration {
  public function setup() {
    $this->enablePlugins('sfDoctrinePlugin');
    ...
    if ( "admin" == sfConfig::get('sf_app') ) {
      $this->enablePlugins('m14tAdminGeneratorPlugin');
    }
  }
}

Sending emails from a task in Symfony 1.4

Sending emails from a task seems like it would be a pretty common, and therefore straightforward task (automated from a cron job for example), but in Symfony its not exactly trivial.

The main reason is that you don’t have a context set from the task, and if you create one it doesn’t know the domain to use when you generate absolute url’s. If you follow Symfony’s Documentation and add a host to the context of your routes, sfDoctrineRoute’s stopped working for me.

While I don’t like tying routing to my models, the solution at http://snippets.symfony-project.org/snippet/378 worked for me. Just watch out for the following erroneous line:
'is_secure' => sfConfig::get('app_host', false),

Tagged with: , ,
Top