-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #367 from hydephp/store-metadata-in-page-object
Refactor metadata system
- Loading branch information
Showing
20 changed files
with
1,078 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Contracts; | ||
|
||
interface MetadataItemContract | ||
{ | ||
public function __toString(): string; | ||
|
||
public function uniqueKey(): string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Hyde\Framework\Models\Metadata; | ||
|
||
use Hyde\Framework\Contracts\MetadataItemContract; | ||
|
||
class LinkItem implements MetadataItemContract, \Stringable | ||
{ | ||
public function __construct(protected string $rel, protected string $href, protected array $attr = []) | ||
{ | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
if (! $this->attr) { | ||
return '<link rel="'.e($this->rel).'" href="'.e($this->href).'">'; | ||
} | ||
|
||
$attributes = collect($this->attr)->map(function ($value, $key) { | ||
return e($key).'="'.e($value).'"'; | ||
})->implode(' '); | ||
|
||
return '<link rel="'.e($this->rel).'" href="'.e($this->href).'" '.$attributes.'>'; | ||
} | ||
|
||
public function uniqueKey(): string | ||
{ | ||
return $this->rel; | ||
} | ||
} |
Oops, something went wrong.