-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Complete ServerSideRendering implementation
- Loading branch information
1 parent
06a1ba5
commit 3b31720
Showing
7 changed files
with
437 additions
and
29 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
namespace Amp\Optimizer\Error; | ||
|
||
use Amp\Optimizer\Error; | ||
use DOMElement; | ||
|
||
final class CannotPerformServerSideRendering implements Error | ||
{ | ||
|
||
use ErrorProperties; | ||
|
||
/** | ||
* Code to use for the error. | ||
* | ||
* @var string | ||
*/ | ||
const CODE = 'CANNOT_PERFORM_SSR'; | ||
|
||
const INVALID_INPUT_WIDTH = 'Cannot perform serverside rendering, invalid input width: '; | ||
const INVALID_INPUT_HEIGHT = 'Cannot perform serverside rendering, invalid input height: '; | ||
const UNSUPPORTED_LAYOUT = 'Cannot perform serverside rendering, unsupported layout: '; | ||
|
||
/** | ||
* Instantiate a CannotPerformServerSideRendering object for an element with an invalid input width. | ||
* | ||
* @param DOMElement $element Element that has an invalid input width. | ||
* @return self | ||
*/ | ||
public static function fromInvalidInputWidth(DOMElement $element) | ||
{ | ||
return new self(self::INVALID_INPUT_WIDTH . new ElementDump($element)); | ||
} | ||
|
||
/** | ||
* Instantiate a CannotPerformServerSideRendering object for an element with an invalid input height. | ||
* | ||
* @param DOMElement $element Element that has an invalid input height. | ||
* @return self | ||
*/ | ||
public static function fromInvalidInputHeight(DOMElement $element) | ||
{ | ||
return new self(self::INVALID_INPUT_HEIGHT . new ElementDump($element)); | ||
} | ||
|
||
/** | ||
* Instantiate a CannotPerformServerSideRendering object for an element with an invalid input height. | ||
* | ||
* @param DOMElement $element Element that has an invalid input height. | ||
* @param string $layout Resulting layout. | ||
* @return self | ||
*/ | ||
public static function fromUnsupportedLayout(DOMElement $element, $layout) | ||
{ | ||
return new self(self::UNSUPPORTED_LAYOUT . new ElementDump($element) . " => {$layout}"); | ||
} | ||
} |
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,37 @@ | ||
<?php | ||
|
||
namespace Amp\Optimizer; | ||
|
||
interface Layout | ||
{ | ||
|
||
const NODISPLAY = 'nodisplay'; | ||
const FIXED = 'fixed'; | ||
const RESPONSIVE = 'responsive'; | ||
const FIXED_HEIGHT = 'fixed-height'; | ||
const FILL = 'fill'; | ||
const CONTAINER = 'container'; | ||
const FLEX_ITEM = 'flex-item'; | ||
const FLUID = 'fluid'; | ||
const INTRINSIC = 'intrinsic'; | ||
|
||
const VALID_LAYOUTS = [ | ||
self::NODISPLAY, | ||
self::FIXED, | ||
self::RESPONSIVE, | ||
self::FIXED_HEIGHT, | ||
self::FILL, | ||
self::CONTAINER, | ||
self::FLEX_ITEM, | ||
self::FLUID, | ||
self::INTRINSIC, | ||
]; | ||
|
||
const SIZE_DEFINED_LAYOUTS = [ | ||
self::FIXED, | ||
self::FIXED_HEIGHT, | ||
self::RESPONSIVE, | ||
self::FILL, | ||
self::FLEX_ITEM, | ||
]; | ||
} |
Oops, something went wrong.