本文整理汇总了PHP中WebserviceRequest::setFieldsToDisplay方法的典型用法代码示例。如果您正苦于以下问题:PHP WebserviceRequest::setFieldsToDisplay方法的具体用法?PHP WebserviceRequest::setFieldsToDisplay怎么用?PHP WebserviceRequest::setFieldsToDisplay使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebserviceRequest
的用法示例。
在下文中一共展示了WebserviceRequest::setFieldsToDisplay方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: manage
/**
* Management of search
*
*/
public function manage()
{
if (!isset($this->wsObject->urlFragments['query']) || !isset($this->wsObject->urlFragments['language'])) {
throw new WebserviceException('You have to set both the \'language\' and \'query\' parameters to get a result', array(100, 400));
}
$objects_products = array();
$objects_categories = array();
$objects_products['empty'] = new Product();
$objects_categories['empty'] = new Category();
$this->_resourceConfiguration = $objects_products['empty']->getWebserviceParameters();
if (!$this->wsObject->setFieldsToDisplay()) {
return false;
}
$results = Search::find($this->wsObject->urlFragments['language'], $this->wsObject->urlFragments['query'], 1, 1, 'position', 'desc', true, false);
$categories = array();
foreach ($results as $result) {
$current = new Product($result['id_product']);
$objects_products[] = $current;
$categories_result = $current->getWsCategories();
foreach ($categories_result as $category_result) {
foreach ($category_result as $id) {
$categories[] = $id;
}
}
}
$categories = array_unique($categories);
foreach ($categories as $id) {
$objects_categories[] = new Category($id);
}
$this->output .= $this->objOutput->getContent($objects_products, null, $this->wsObject->fieldsToDisplay, $this->wsObject->depth, WebserviceOutputBuilder::VIEW_LIST, false);
// @todo allow fields of type category and product
// $this->_resourceConfiguration = $objects_categories['empty']->getWebserviceParameters();
// if (!$this->setFieldsToDisplay())
// return false;
$this->output .= $this->objOutput->getContent($objects_categories, null, $this->wsObject->fieldsToDisplay, $this->wsObject->depth, WebserviceOutputBuilder::VIEW_LIST, false);
}