Ejemplo n.º 1
0
 public static function get_for_model($model, $app_label = false, $name = false)
 {
     $q = Doctrine_Query::create()->from('ContentType o')->where('o.model = ?', array($model));
     if ($app_label) {
         $q->addWhere('o.app_label = ?', array($app_label));
     }
     $contentType = $q->fetchOne();
     if (!$contentType) {
         $contentType = new ContentType();
         $contentType->app_label = $app_label;
         $contentType->model = $model;
         $contentType->name = $app_label . ' ' . $model;
         $contentType->save();
     }
     return $contentType;
 }