开发者

Is it possible to refactor executing tests with include_partial?

开发者 https://www.devze.com 2023-04-02 02:28 出处:网络
For example I have: public function executeTestOne(sfWebRequest $request) { $this->value = Doctrine::getTable(\'Test\')->createQuery(\'a\')->where(\'id = ?\', $request->getParameter(\'id\

For example I have:

public function executeTestOne(sfWebRequest $request)
{
  $this->value = Doctrine::getTable('Test')->createQuery('a')->where('id = ?', $request->getParameter('id') ) ->execute(); 
}

public function executeTestTwo(sfWebRequest $request)
{
  $this->value = Doctrine::getTable('Test')->createQuery('a')->wh开发者_如何转开发ere('id = ?', $request->getParameter('id') ) ->execute(); 
}

I would like to use include_partial or render_partial etc in action:

public function executePartial ???? 
{
  $this->value = Doctrine::getTable('Test')->createQuery('a')->where('id = ?', $request->getParameter('id') ) ->execute(); 
}


public function executeTestOne(sfWebRequest $request)
{
  include_partial($this->value ??);
}

public function executeTestTwo(sfWebRequest $request)
{
  include_partial($this->value ??);
}

Is this possible?


I don't really get what you're trying to do, but what about this?

public function executeTestQuery($id) {
    $this->value = Doctrine::getTable('Test')->createQuery('a')->where('id = ?', $id ) ->execute(); 
}


public function executeTestOne(sfWebRequest $request)
{
   executeTestQuery($request->getParameter('id'));
} 

public function executeTestTwo(sfWebRequest $request)
{
   executeTestQuery($request->getParameter('id'));
}


Technically yes if you load the PartialHelper. But if you're doing this then you're doing something very wrong in your application, so please never under any circumstances do this... ever.

If you really can't think of a better way to do this, then what you really need is a component not a partial. See here.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号