helper_plugin_data::_addPrePostFixes PHP Method

_addPrePostFixes() public method

$type may be an column array with pre and postfixes
public _addPrePostFixes ( string | array $type, string $val, string $pre = '', string $post = '' ) : string
$type string | array
$val string
$pre string
$post string
return string
    function _addPrePostFixes($type, $val, $pre = '', $post = '')
    {
        if (is_array($type)) {
            if (isset($type['prefix'])) {
                $pre = $type['prefix'];
            }
            if (isset($type['postfix'])) {
                $post = $type['postfix'];
            }
        }
        $val = $pre . $val . $post;
        $val = $this->replacePlaceholders($val);
        return $val;
    }

Usage Example

 function testAddPrePostFixes()
 {
     global $conf;
     $helper = new helper_plugin_data();
     $this->assertEquals('value', $helper->_addPrePostFixes('', 'value'));
     $this->assertEquals('prevaluepost', $helper->_addPrePostFixes('', 'value', 'pre', 'post'));
     $this->assertEquals('valuepost', $helper->_addPrePostFixes('', 'value', '', 'post'));
     $this->assertEquals('prevalue', $helper->_addPrePostFixes('', 'value', 'pre'));
     $this->assertEquals('prevaluepost', $helper->_addPrePostFixes(array('prefix' => 'pre', 'postfix' => 'post'), 'value'));
     $conf['lang'] = 'en';
     $this->assertEquals('envalue', $helper->_addPrePostFixes(array('prefix' => '%lang%'), 'value'));
     $this->assertEquals('value', $helper->_addPrePostFixes(array('prefix' => '%trans%'), 'value'));
     if (plugin_enable('translation')) {
         global $ID;
         $conf['plugin']['translation']['translations'] = 'de';
         $ID = 'de:somepage';
         $this->assertEquals('de:value', $helper->_addPrePostFixes(array('prefix' => '%trans%:'), 'value'));
     }
 }
All Usage Examples Of helper_plugin_data::_addPrePostFixes