Skip to content

Commit

Permalink
add support to closures & static url strings
Browse files Browse the repository at this point in the history
  • Loading branch information
RodrigoDornelles authored Sep 8, 2021
1 parent 337b539 commit 1d14c4a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/SeoBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,18 @@ public function __get($name)
$metatags = [];

foreach($this->metatags as $tag => $attribute) {
if ($this->owner && $this->owner->canGetProperty($attribute)) {
// closure
if (is_callable($attribute)){
$metatags[$tag] = call_user_func($attribute, $this->owner);
}
// method
else if (is_string($attribute) && $this->owner->canGetProperty($attribute)) {
$metatags[$tag] = $this->owner->{$attribute};
}
// url
else if (is_string($attribute)) {
$metatags[$tag] = $attribute;
}
}

return $metatags;
Expand Down

0 comments on commit 1d14c4a

Please sign in to comment.