Feature #26843

Padding Type in ViewHelper

Added by Lars Malach about 4 years ago. Updated almost 4 years ago.

Status:Resolved Start date:2011-05-17
Priority:Should have Due date:
Assigned To:Bastian Waidelich % Done:

100%

Category:ViewHelpers
Target version:-
Has patch:No

Description

Add the padding type as possible parameters to the PaddingViewHelper.

Of Example:

 1class Tx_Fluid_ViewHelpers_Format_PaddingViewHelper extends Tx_Fluid_Core_ViewHelper_AbstractViewHelper {
 2    /**
 3     * Pad a string to a certain length with another string
 4     *
 5     * @param integer $padLength Length of the resulting string. If the value of pad_length is negative or less than the length of the input string, no padding takes place.
 6     * @param string $padString The padding string
 7     * @param string $padType Append the padding at this site (Possible values: right,left,both. Default: right)
 8     * @return string The formatted value
 9     * @author Bastian Waidelich <bastian@typo3.org>
10     * @api
11     */
12    public function render($padLength, $padString = ' ', $padType = 'right') {
13        $string = $this->renderChildren();
14
15        $padTypes = array(
16            'left' => STR_PAD_LEFT,
17            'right' => STR_PAD_RIGHT,
18            'both' => STR_PAD_BOTH,
19        );
20        if (!isset($padTypes[$padType])) {
21            $padType = 'right';
22        }
23
24        return str_pad($string, $padLength, $padString, $padTypes[$padType]);
25    }
26}

Associated revisions

Revision e7ae2aab
Added by Lars Malach about 4 years ago

[+FEATURE] Add padding-type to PaddingViewHelper

Allow passing third parameter for "left", "right" or "both".
Also add a small fix to the php-doc.

Change-Id: I129a20878ee8831807e9add5ac87d388c79a3737
Resolves: #26843
Resolves: #26844

History

#1 Updated by Mr. Hudson about 4 years ago

Patch set 1 of change I129a20878ee8831807e9add5ac87d388c79a3737 has been pushed to the review server.
It is available at http://review.typo3.org/3421

#2 Updated by Mr. Hudson about 4 years ago

Patch set 2 of change I129a20878ee8831807e9add5ac87d388c79a3737 has been pushed to the review server.
It is available at http://review.typo3.org/3421

#3 Updated by Bastian Waidelich almost 4 years ago

  • Status changed from New to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF