\Dewdrop\View\HelperBootstrapTable

Render a table using classes and markup consistent with Boostrap's documentation. Note that this helper will wrap your table in a

.table-responsive div so that it is still reasonably usable on a small screen.

Summary

Methods
Properties
Constants
direct()
directWithArgs()
open()
close()
renderHead()
renderBody()
renderFoot()
__construct()
partial()
getTableWrapperId()
setTableWrapperId()
No public properties found
No constants found
renderSection()
renderSortLink()
renderHeadCells()
toggleDirection()
getActiveSortDirection()
assembleSortUrl()
delegateIfArgsProvided()
delegateByArgs()
checkRequired()
getHelperName()
ensurePresent()
ensureArray()
$view
$tableWrapperId
N/A
No private methods found
No private properties found
N/A

Properties

$view

$view : \Dewdrop\View\View

The view that instantiated this helper.

Type

\Dewdrop\View\View

$tableWrapperId

$tableWrapperId : string

Table wrapper's id HTML attribute.

Type

string

Methods

direct()

direct() : $this|string

If no arguments are provided, return this helper instance to allow the user to call other methods individually. Otherwise, use directWithArgs() to validate the user's arguments and render the table.

Returns

$this|string

directWithArgs()

directWithArgs(\Dewdrop\Fields  $fields, array  $data, null|\Dewdrop\Fields\Helper\TableCell  $renderer = null, null|\Dewdrop\Fields\Helper\SelectSort  $sorter = null) : string

Render the full table using the supplied arguments.

Parameters

\Dewdrop\Fields $fields
array $data
null|\Dewdrop\Fields\Helper\TableCell $renderer
null|\Dewdrop\Fields\Helper\SelectSort $sorter

Returns

string

open()

open() : string

Open the table for rendering. Notice the .table-responsive wrapper.

Returns

string

close()

close() : string

Close the table itself and its .table-responsive wrapper.

Returns

string

renderHead()

renderHead(\Dewdrop\Fields  $fields, \Dewdrop\Fields\Helper\TableCell  $renderer, \Dewdrop\Fields\Helper\SelectSort  $sorter = null) : string

Render the <thead> tag, using the TableCell.Header helper to allow fields to modify their header content.

Parameters

\Dewdrop\Fields $fields
\Dewdrop\Fields\Helper\TableCell $renderer
\Dewdrop\Fields\Helper\SelectSort $sorter

Returns

string

renderBody()

renderBody(\Dewdrop\Fields  $fields, array  $data, \Dewdrop\Fields\Helper\TableCell  $renderer) : string

Render the <tbody> with the TableCell.Content helper to allow each field's cell content to be modified.

Parameters

\Dewdrop\Fields $fields
array $data
\Dewdrop\Fields\Helper\TableCell $renderer

Returns

string

renderFoot()

renderFoot(\Dewdrop\Fields  $fields, array  $data, \Dewdrop\Fields\Helper\TableCell  $renderer) : string

Render a <tfoot> section in the table. Not included in the default render methods, but can be called directly when needed.

Parameters

\Dewdrop\Fields $fields
array $data
\Dewdrop\Fields\Helper\TableCell $renderer

Returns

string

__construct()

__construct(\Dewdrop\View\View  $view) 

Create helper, accepting a reference to the related view object

Parameters

\Dewdrop\View\View $view

partial()

partial(string  $name, array  $data) : string

Render a partial view script.

Generally, your helper should render HTML with partial view scripts rather than generating the markup in the helper class directly. This makes it easier for frontend developers to make modifications to the HTML.

The $data parameter should contain key-value pairs for each variable you'd like available in your partial view.

Parameters

string $name
array $data

Returns

string —

The rendered output

getTableWrapperId()

getTableWrapperId() : string|null

Return the table wrapper's id HTML attribute.

Returns

string|null

setTableWrapperId()

setTableWrapperId(string  $tableWrapperId) : \Dewdrop\View\Helper\BootstrapTable

Set the table wrapper's id HTML attribute

Parameters

string $tableWrapperId

Returns

\Dewdrop\View\Helper\BootstrapTable

renderSection()

renderSection(string  $sectionName, \Dewdrop\Fields  $fields, array  $data, \Dewdrop\Fields\Helper\TableCell  $renderer) : string

Render a table section wrapped in tags specified in $sectionName.

Parameters

string $sectionName
\Dewdrop\Fields $fields
array $data
\Dewdrop\Fields\Helper\TableCell $renderer

Returns

string

renderSortLink()

renderSortLink(string  $content, string  $fieldId, string  $direction, \Dewdrop\Fields\Helper\SelectSort  $sorter = null) : string

Render a sorting link for a particular column. If the collumn is currently selected, which we can detect using a SelectSort helper, we use the carets provided in Bootstrap to indicate in which direction it is sorted.

Parameters

string $content
string $fieldId
string $direction
\Dewdrop\Fields\Helper\SelectSort $sorter

Returns

string

toggleDirection()

toggleDirection(  $direction) 

Parameters

$direction

getActiveSortDirection()

getActiveSortDirection(  $fieldId, \Dewdrop\Fields\Helper\SelectSort  $sorter = null) 

Parameters

$fieldId
\Dewdrop\Fields\Helper\SelectSort $sorter

assembleSortUrl()

assembleSortUrl(string  $id, string  $direction) : string

Generate a URL for sorting.

Parameters

string $id
string $direction

Returns

string

delegateIfArgsProvided()

delegateIfArgsProvided(array  $args, string  $method = 'directWithArgs') : $this|string

Useful in cases where you want to just return the helper if the user didn't provide any args to direct(), but want to call a short-cut method if they did.

Parameters

array $args
string $method

Returns

$this|string

delegateByArgs()

delegateByArgs(array  $args, string  $methodPrefix) : mixed

Delegate to one of three methods depending upon the contents of the $args array:

  • If $args[0] is an instance of \Dewdrop\Db\Field, call "{$methodPrefix}Field".
  • If $args[0] is an array, call "{$methodPrefix}Array".
  • Otherwise, call "{$methodPrefix}Explicit".

Parameters

array $args

The arguments to pass the delegated method.

string $methodPrefix

Returns

mixed

checkRequired()

checkRequired(array  $options, array  $required) : \Dewdrop\View\Helper\AbstractHelper

Check that the values in $required are present as keys in $options.

Use this in methods accepting parameters as an array of key-value pairs to ensure that required parameters are present. If one of the required parameters is absent, an exception is thrown.

Parameters

array $options
array $required

Throws

\Dewdrop\Exception

Returns

\Dewdrop\View\Helper\AbstractHelper

getHelperName()

getHelperName() : string

Get the helper name, which is the suffix at the end of the fully qualified class name after the final namespace separator ("\").

Returns

string

ensurePresent()

ensurePresent(array  $options, array  $present) : \Dewdrop\View\Helper\AbstractHelper

Ensure that the values in $present are keys in $options.

If the key is absent from $options, it will be added with a null value. Therefore, this method differs from checkRequired() in that the user must supply a value (even if that value is null) before checkRequired(), but for ensurePresent() the key will simply be added if the user hadn't already specified a value.

Note: Notice that the $options parameter is handled by-reference to allow creation of the missing keys while still allowing chaining to other methods.

Parameters

array $options
array $present

Returns

\Dewdrop\View\Helper\AbstractHelper

ensureArray()

ensureArray(array  $options, array  $isArray) : \Dewdrop\View\Helper\AbstractHelper

Ensure that the values in the $isArray parameter are present in $options as an array.

If the option's current value is null, it will be converted to an array. If the option's current value is not null but also not an array, it will be wrapped in an array. For example, if you had a "classes" option that let the user specify one or more CSS classes, they could use a string to define a single class and this method would wrap that single value in array array to make the handling of the various options simpler and more consistent for the view helper developer.

Note: Notice that the $options parameter is handled by-reference to allow creation of the missing keys while still allowing chaining to other methods.

Parameters

array $options
array $isArray

Returns

\Dewdrop\View\Helper\AbstractHelper