本文整理汇总了PHP中Magento\Backend\Helper\Data::prepareFilterString方法的典型用法代码示例。如果您正苦于以下问题:PHP Data::prepareFilterString方法的具体用法?PHP Data::prepareFilterString怎么用?PHP Data::prepareFilterString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Backend\Helper\Data
的用法示例。
在下文中一共展示了Data::prepareFilterString方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testPrepareFilterString
/**
* @covers \Magento\Backend\Helper\Data::prepareFilterString
*/
public function testPrepareFilterString()
{
$expected = ['key1' => 'val1', 'key2' => 'val2', 'key3' => 'val3'];
$filterString = base64_encode('key1=' . rawurlencode('val1') . '&key2=' . rawurlencode('val2') . '&key3=val3');
$actual = $this->_helper->prepareFilterString($filterString);
$this->assertEquals($expected, $actual);
}
示例2: _prepareCollection
/**
* Apply sorting and filtering to collection
*
* @return $this
* @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
protected function _prepareCollection()
{
if ($this->getCollection()) {
$this->_preparePage();
$columnId = $this->getParam($this->getVarNameSort(), $this->_defaultSort);
$dir = $this->getParam($this->getVarNameDir(), $this->_defaultDir);
$filter = $this->getParam($this->getVarNameFilter(), null);
if (is_null($filter)) {
$filter = $this->_defaultFilter;
}
if (is_string($filter)) {
$data = $this->_backendHelper->prepareFilterString($filter);
$data = array_merge($data, (array) $this->getRequest()->getPost($this->getVarNameFilter()));
$this->_setFilterValues($data);
} elseif ($filter && is_array($filter)) {
$this->_setFilterValues($filter);
} elseif (0 !== sizeof($this->_defaultFilter)) {
$this->_setFilterValues($this->_defaultFilter);
}
if ($this->getColumn($columnId) && $this->getColumn($columnId)->getIndex()) {
$dir = strtolower($dir) == 'desc' ? 'desc' : 'asc';
$this->getColumn($columnId)->setDir($dir);
$this->_setCollectionOrder($this->getColumn($columnId));
}
}
return $this;
}
示例3: testPrepareFilterStringValues
/**
* @param array $inputString
* @param array $expected
*
* @dataProvider getPrepareFilterStringValuesDataProvider
*/
public function testPrepareFilterStringValues(array $inputString, array $expected)
{
$inputString = base64_encode(http_build_query($inputString));
$actual = $this->_helper->prepareFilterString($inputString);
$this->assertEquals($expected, $actual);
}