-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- added possibility to render custom attributes on a banner tag - added rendering of data attribute `data-amp-banner-external` - fixed fingerprint resolving (now compatible with JS client) - added and fixed tests
- Loading branch information
Showing
60 changed files
with
382 additions
and
112 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
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,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace SixtyEightPublishers\AmpClient\Renderer; | ||
|
||
use JsonException; | ||
use SixtyEightPublishers\AmpClient\Exception\RendererException; | ||
use SixtyEightPublishers\AmpClient\Response\ValueObject\Position; | ||
|
||
final class AmpBannerExternalAttribute | ||
{ | ||
private Position $position; | ||
|
||
private string $state; | ||
|
||
private string $stateInfo; | ||
|
||
private function __construct(Position $position, string $state, string $stateInfo) | ||
{ | ||
$this->position = $position; | ||
$this->state = $state; | ||
$this->stateInfo = $stateInfo; | ||
} | ||
|
||
public static function rendered(Position $position): self | ||
{ | ||
return new self($position, 'RENDERED', 'Banner was successfully rendered server-side.'); | ||
} | ||
|
||
public static function notFound(Position $position): self | ||
{ | ||
return new self($position, 'NOT_FOUND', 'Banner not found in fetched response on the server.'); | ||
} | ||
|
||
public function __toString(): string | ||
{ | ||
$components = [ | ||
'positionData' => [ | ||
'id' => $this->position->getId(), | ||
'code' => $this->position->getCode(), | ||
'name' => $this->position->getName(), | ||
'rotationSeconds' => $this->position->getRotationSeconds(), | ||
'displayType' => $this->position->getDisplayType(), | ||
'breakpointType' => $this->position->getBreakpointType(), | ||
], | ||
'state' => [ | ||
'value' => $this->state, | ||
'info' => $this->stateInfo, | ||
], | ||
]; | ||
|
||
try { | ||
$json = json_encode($components, JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); | ||
} catch (JsonException $e) { | ||
throw RendererException::unableToRenderAmpBannerExternalAttribute($this->position->getCode(), $e); | ||
} | ||
|
||
return base64_encode( | ||
rawurlencode($json), | ||
); | ||
} | ||
} |
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
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 |
---|---|---|
@@ -1,3 +1,6 @@ | ||
{templateType SixtyEightPublishers\AmpClient\Renderer\Latte\Templates\NotFoundTemplate} | ||
|
||
<div data-amp-banner="{$position->getCode()}" data-amp-attached></div> | ||
<div data-amp-banner="{$position->getCode()}" | ||
data-amp-banner-external="{=SixtyEightPublishers\AmpClient\Renderer\AmpBannerExternalAttribute::notFound($position)}" | ||
n:attr="$elementAttributes"> | ||
</div> |
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
Oops, something went wrong.