如何将请求对象传递给在generator.yml中配置的doJoin方法?
generator.yml:
generator:
param:
config:
list:
table_method: doJoin
ItemTable.class.php:
public static function doJoin(Doctrine_Query $q)
{
$rootAlias = $q->getRootAlias($q);
return $q->select($rootAlias.'.*, p.currency_code, p.customer_price')
->innerJoin($rootAlias.'.Price p')
->where('p.currency_code = \'USD\'');
}
答案 0 :(得分:1)
您可以覆盖actions.class.php中的方法buildQuery()
以接受请求参数...->$table_method($query, $this->getRequest()
:
protected function buildQuery()
{
$tableMethod = $this->configuration->getTableMethod();
$query = Doctrine::getTable('CLASS_NAME')
->createQuery('a');
if ($tableMethod)
{
$query = Doctrine::getTable('CLASS_NAME')->$table_method($query, $this->getRequest());
}
$this->addSortQuery($query);
$event = $this->dispatcher->filter(new sfEvent($this, 'admin.build_query'), $query);
$query = $event->getReturnValue();
return $query;
}
然后您更改ItemTable.class.php
:
public static function doJoin(Doctrine_Query $q, sfWebRequest $request)
答案 1 :(得分:0)
您可以使用:
sfContext::getInstance()->getRequest()->getParameter('whatever_you_want');