helper_plugin_data::_resolveData PHP Method

_resolveData() public method

This function is registered as a SQL function named DATARESOLVE
public _resolveData ( string $value, string $colname ) : string
$value string
$colname string
return string
    function _resolveData($value, $colname)
    {
        // resolve pre and postfixes
        $column = $this->_column($colname);
        $value = $this->_addPrePostFixes($column['type'], $value);
        // for pages, resolve title
        $type = $column['type'];
        if (is_array($type)) {
            $type = $type['type'];
        }
        if ($type == 'title' || $type == 'page' && useHeading('content')) {
            $id = $value;
            if ($type == 'title') {
                list($id, ) = explode('|', $value, 2);
            }
            //DATARESOLVE is only used with the 'LIKE' comparator, so concatenate the different strings is fine.
            $value .= ' ' . p_get_first_heading($id);
        }
        return $value;
    }

Usage Example

 function testResolveData()
 {
     $helper = new helper_plugin_data();
     $this->assertEquals('tom', $helper->_resolveData('tom', 'name'));
     $this->assertEquals('jerry', $helper->_resolveData('jerry', 'name'));
     $this->assertEquals('wiki:syntax Formatting Syntax', $helper->_resolveData('wiki:syntax', 'name_title'));
     $this->assertEquals('none:existing ', $helper->_resolveData('none:existing', 'name_title'));
 }