Variables

Variables are fields on a group entry that can be used to store information to use throughout your website or application.

Variable Repository

This class will go over the \Anomaly\VariablesModule\Variable\Contract\VariableRepositoryInterface

VariableRepositoryInterface::get()

The get method returns the raw data for the variable specified in a given group.

Returns: mixed
Arguments
Key Required Type Default Description

$group

true

string

none

The slug of the group you want to access.

$field

true

string

none

The slug of the variable field in the group you want to access.

Example
$variables->get('social', 'facebook_url'); // https://facebook.com/pyrocms
VariableRepositoryInterface::presenter()

The presenter method returns the field type presenter for the variable specified in a given group.

Returns: \Anomaly\Streams\Platform\Addon\FieldType\FieldTypePresenter or null
Arguments
Key Required Type Default Description

$group

true

string

none

The slug of the group you want to access.

$field

true

string

none

The slug of the variable field in the group you want to access.

Example
$variables->presenter('social', 'facebook_url')->link('Facebook'); // <a href="https://facebook.com/pyrocms">Facebook</a>
VariableRepositoryInterface::group()

The group method returns the entire group entry model so you can then easily access any variable on said model.

Returns: \Anomaly\Streams\Platform\Entry\Contract\EntryInterface or null
Arguments
Key Required Type Default Description

$group

true

string

none

The slug of the group you want to access.

Example
$group = $variables->group('social');

echo $group->facebook_url; // https://facebook.com/pyrocms
echo $group->twitter_url; // https://twitter.com/pyrocms

echo $group->getFieldTypePresenter('facebook_url')->link('Facebook'); // <a href="https://facebook.com/pyrocms">Facebook</a>