Skip to content

Commit

Permalink
Replace usage of $this->get etc with $this>params->get
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Aug 2, 2020
1 parent 23b89c2 commit b34aa01
Show file tree
Hide file tree
Showing 24 changed files with 72 additions and 72 deletions.
2 changes: 1 addition & 1 deletion src/Tags/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ public function __call($method, $arguments)
*/
public function index()
{
return AssetAPI::find($this->get(['url', 'src']));
return AssetAPI::find($this->params->get(['url', 'src']));
}
}
12 changes: 6 additions & 6 deletions src/Tags/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ public function __call($method, $arguments)
*/
public function index()
{
$id = $this->get(['container', 'handle', 'id']);
$path = $this->get('path');
$id = $this->params->get(['container', 'handle', 'id']);
$path = $this->params->get('path');

if (! $id && ! $path) {
\Log::debug('No asset container ID or path was specified.');
Expand All @@ -73,7 +73,7 @@ public function index()
return $this->parseNoResults();
}

$this->assets = $container->assets($this->get('folder'), $this->getBool('recursive', false));
$this->assets = $container->assets($this->params->get('folder'), $this->params->get('recursive', false));

return $this->output();
}
Expand Down Expand Up @@ -120,7 +120,7 @@ private function output()

private function sort()
{
if ($sort = $this->get('sort')) {
if ($sort = $this->params->get('sort')) {
$this->assets = $this->assets->multisort($sort);
}
}
Expand All @@ -132,9 +132,9 @@ private function sort()
*/
private function limit()
{
$limit = $this->getInt('limit');
$limit = $this->params->get('limit');
$limit = ($limit == 0) ? $this->assets->count() : $limit;
$offset = $this->getInt('offset');
$offset = $this->params->get('offset');

$this->assets = $this->assets->splice($offset, $limit);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Tags/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private function getCacheKey()
'params' => $this->params->all(),
];

if ($this->get('scope', 'site') === 'page') {
if ($this->params->get('scope', 'site') === 'page') {
$hash['url'] = URL::makeAbsolute(URL::getCurrent());
}

Expand All @@ -46,7 +46,7 @@ private function getCacheKey()

private function getCacheLength()
{
if (! $length = $this->get('for')) {
if (! $length = $this->params->get('for')) {
return null;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tags/Collection/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ protected function entries()

protected function currentEntry()
{
return Entry::find($this->get('current', $this->context->get('id')));
return Entry::find($this->params->get('current', $this->context->get('id')));
}
}
8 changes: 4 additions & 4 deletions src/Tags/Concerns/GetsRedirects.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ trait GetsRedirects
*/
protected function getRedirectUrl()
{
$return = $this->get('redirect');
$return = $this->params->get('redirect');

if ($this->getBool('allow_request_redirect')) {
if ($this->params->get('allow_request_redirect')) {
$return = request()->input('redirect', $return);
}

Expand All @@ -29,9 +29,9 @@ protected function getRedirectUrl()
*/
protected function getErrorRedirectUrl()
{
$return = $this->get('error_redirect');
$return = $this->params->get('error_redirect');

if ($this->getBool('allow_request_redirect')) {
if ($this->params->get('allow_request_redirect')) {
$return = request()->input('error_redirect', $return);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Tags/Concerns/OutputsItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected function output($items)
return $this->paginatedOutput($items);
}

if ($as = $this->get('as')) {
if ($as = $this->params->get('as')) {
return array_merge([$as => $items], $this->extraOutput($items));
}

Expand All @@ -34,7 +34,7 @@ protected function extraOutput($items)

protected function paginatedOutput($paginator)
{
$as = $this->get('as', $this->defaultAsKey ?? 'results');
$as = $this->params->get('as', $this->defaultAsKey ?? 'results');
$items = $paginator->getCollection()->supplement('total_results', $paginator->total());

return array_merge([
Expand Down
2 changes: 1 addition & 1 deletion src/Tags/Concerns/RendersForms.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function formOpen($action, $method = 'POST', $knownTagParams = [])
'action' => $action,
];

if ($this->getBool('files')) {
if ($this->params->get('files')) {
$defaultAttrs['enctype'] = 'multipart/form-data';
}

Expand Down
2 changes: 1 addition & 1 deletion src/Tags/GetContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function index()
$from = $this->getList(['from', 'id']);

if (Str::startsWith($from[0], '/')) {
$site = $this->get(['site', 'locale'], Site::current()->handle());
$site = $this->params->get(['site', 'locale'], Site::current()->handle());

$entries = EntryCollection::make($from)->map(function ($item) use ($site) {
return Entry::findByUri($item, $site);
Expand Down
22 changes: 11 additions & 11 deletions src/Tags/GetFiles.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public function index()
*/
private function getFiles()
{
$folders = $this->get(['in', 'from']);
$depth = $this->getInt('depth', 1);
$folders = $this->params->get(['in', 'from']);
$depth = $this->params->get('depth', 1);

$this->files = new FileCollection;

Expand Down Expand Up @@ -88,7 +88,7 @@ private function filter()
*/
private function filterNotIn()
{
if ($not_in = $this->get('not_in')) {
if ($not_in = $this->params->get('not_in')) {
$regex = '#^('.$not_in.')#';

$this->files = $this->files->reject(function ($path) use ($regex) {
Expand All @@ -102,7 +102,7 @@ private function filterNotIn()
*/
private function filterSize()
{
if ($size = $this->get('file_size')) {
if ($size = $this->params->get('file_size')) {
$this->files = $this->files->filterBySize($size);
}
}
Expand All @@ -112,7 +112,7 @@ private function filterSize()
*/
private function filterExtension()
{
if ($extensions = $this->get(['extension', 'ext'])) {
if ($extensions = $this->params->get(['extension', 'ext'])) {
$extensions = Arr::explodeOptions($extensions);

$this->files = $this->files->filterByExtension($extensions);
Expand All @@ -121,34 +121,34 @@ private function filterExtension()

private function filterRegex()
{
if ($include = $this->get(['include', 'match'])) {
if ($include = $this->params->get(['include', 'match'])) {
$this->files = $this->files->filterByRegex($include);
}

if ($exclude = $this->get('exclude')) {
if ($exclude = $this->params->get('exclude')) {
$this->files = $this->files->rejectByRegex($exclude);
}
}

private function filterDate()
{
if ($date = $this->get('file_date')) {
if ($date = $this->params->get('file_date')) {
$this->files = $this->files->filterByDate($date);
}
}

private function limit()
{
$limit = $this->getInt('limit');
$limit = $this->params->get('limit');
$limit = ($limit == 0) ? $this->files->count() : $limit;
$offset = $this->getInt('offset');
$offset = $this->params->get('offset');

$this->files = $this->files->splice($offset, $limit);
}

private function sort()
{
if ($sort = $this->get('sort')) {
if ($sort = $this->params->get('sort')) {
$this->files = $this->files->multisort($sort);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/Tags/Glide.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public function index()
return $this->generate();
}

$item = $this->get(['src', 'id', 'path']);
$item = $this->params->get(['src', 'id', 'path']);

return $this->output($this->generateGlideUrl($item));
}
Expand Down Expand Up @@ -91,7 +91,7 @@ public function batch()
*/
public function generate($items = null)
{
$items = $items ?? $this->get(['src', 'id', 'path']);
$items = $items ?? $this->params->get(['src', 'id', 'path']);

$items = is_iterable($items) ? collect($items) : collect([$items]);

Expand Down Expand Up @@ -140,8 +140,8 @@ private function output($url)
compact('url', 'width', 'height')
);
}
if ($this->getBool('tag')) {
return "<img src=\"$url\" alt=\"{$this->get('alt')}\" />";
if ($this->params->get('tag')) {
return "<img src=\"$url\" alt=\"{$this->params->get('alt')}\" />";
}

return $url;
Expand All @@ -163,7 +163,7 @@ private function generateGlideUrl($item)
return;
}

$url = ($this->getBool('absolute')) ? URL::makeAbsolute($url) : URL::makeRelative($url);
$url = ($this->params->get('absolute')) ? URL::makeAbsolute($url) : URL::makeRelative($url);

return $url;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Tags/Increment.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ class Increment extends Tags
public function wildcard($tag)
{
if (! isset(self::$arr[$tag])) {
return self::$arr[$tag] = $this->get('from', 0);
return self::$arr[$tag] = $this->params->get('from', 0);
}

return self::$arr[$tag] = self::$arr[$tag] + $this->get('by', 1);
return self::$arr[$tag] = self::$arr[$tag] + $this->params->get('by', 1);
}
}
4 changes: 2 additions & 2 deletions src/Tags/Locales.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,12 @@ private function getData()
*/
private function sort($locales)
{
if ($sort = $this->get('sort')) {
if ($sort = $this->params->get('sort')) {
[$sort, $dir] = $this->getSort($sort);
$locales = ($dir === 'asc') ? $locales->sortBy($sort) : $locales->sortByDesc($sort);
}

if ($this->getBool('current_first', true)) {
if ($this->params->get('current_first', true)) {
$locales = $this->moveCurrentLocaleToFront($locales);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Tags/Mix.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class Mix extends Tags
public function index()
{
return mix(
$this->get(['src', 'path']),
$this->get(['from', 'in'], '')
$this->params->get(['src', 'path']),
$this->params->get(['from', 'in'], '')
);
}
}
2 changes: 1 addition & 1 deletion src/Tags/Nav.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Nav extends Structure
{
public function index()
{
return $this->structure($this->get('handle', 'collection::pages'));
return $this->structure($this->params->get('handle', 'collection::pages'));
}

public function breadcrumbs()
Expand Down
2 changes: 1 addition & 1 deletion src/Tags/Partial.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public function wildcard($tag)
{
// We pass the original non-studly case value in as
// an argument, but fall back to the studly version just in case.
$partial = $this->get('src', $tag);
$partial = $this->params->get('src', $tag);

$variables = array_merge($this->context->all(), $this->parameters->all(), [
'__frontmatter' => $this->parameters->all(),
Expand Down
4 changes: 2 additions & 2 deletions src/Tags/Path.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ class Path extends Tags
public function index()
{
// If no src param was used, we will treat this as a regular `path` variable.
if (! $src = $this->get(['src', 'to'])) {
if (! $src = $this->params->get(['src', 'to'])) {
return array_get($this->context, 'path');
}

$url = PathAPI::tidy(Config::getSiteUrl().$src);

if ($this->getBool('absolute', false)) {
if ($this->params->get('absolute', false)) {
$url = URL::makeAbsolute($url);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Tags/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function wildcard($tag)
public function index()
{
return $this->redirect(
$this->get(['to', 'url'])
$this->params->get(['to', 'url'])
);
}

Expand All @@ -35,6 +35,6 @@ protected function redirect($location)
return;
}

abort(redirect($location, $this->get('response', 302)));
abort(redirect($location, $this->params->get('response', 302)));
}
}
2 changes: 1 addition & 1 deletion src/Tags/Rotate.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class Rotate extends Tags
*/
public function index()
{
if (! $between = $this->get('between')) {
if (! $between = $this->params->get('between')) {
// No 'between' parameter? Why are you using this tag?
return null;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Tags/Structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function wildcard($tag)

public function index()
{
return $this->structure($this->get('for'));
return $this->structure($this->params->get('for'));
}

protected function structure($handle)
Expand All @@ -34,9 +34,9 @@ protected function structure($handle)

$tree = (new TreeBuilder)->build([
'structure' => $handle,
'include_home' => $this->get('include_home'),
'site' => $this->get('site', Site::current()->handle()),
'from' => $this->get('from'),
'include_home' => $this->params->get('include_home'),
'site' => $this->params->get('site', Site::current()->handle()),
'from' => $this->params->get('from'),
]);

return $this->toArray($tree);
Expand Down
4 changes: 2 additions & 2 deletions src/Tags/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function __call($method, $args)
*/
public function parse($data = [])
{
if ($scope = $this->get('scope')) {
if ($scope = $this->params->get('scope')) {
$data = Arr::addScope($data, $scope);
}

Expand All @@ -169,7 +169,7 @@ public function parseLoop($data, $supplement = true)
return $this->parse([$as => $data]);
}

if ($scope = $this->get('scope')) {
if ($scope = $this->params->get('scope')) {
$data = Arr::addScope($data, $scope);
}

Expand Down
Loading

0 comments on commit b34aa01

Please sign in to comment.