Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature(embed): adds serve-icon page handler
Adds a handler to serve embedded icons. Adds elgg_get_embed_url() to generate embed URLs. Adds a trait to inject the time in components for testing. Fixes Elgg#9582
- Loading branch information
1 parent
958b8b7
commit f8459bc
Showing
9 changed files
with
349 additions
and
35 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
namespace Elgg; | ||
|
||
use DateTime; | ||
|
||
/** | ||
* Adds methods for fixing the current time (for testing) | ||
* | ||
* @access private | ||
*/ | ||
trait TimeUsing { | ||
|
||
/** | ||
* @var DateTime | ||
*/ | ||
private $time; | ||
|
||
/** | ||
* Get a (cloned) time or the preset time if set | ||
* | ||
* @see DateTime::modify | ||
* | ||
* @param string $modifier Time modifier | ||
* @return DateTime | ||
*/ | ||
public function getCurrentTime($modifier = '') { | ||
$time = $this->time ? $this->time : new DateTime(); | ||
$time = clone $time; | ||
if ($modifier) { | ||
$time->modify($modifier); | ||
} | ||
return $time; | ||
} | ||
|
||
/** | ||
* Fix the current time (and return it) | ||
* | ||
* @param DateTime $time Current time (empty for now) | ||
* @return void | ||
*/ | ||
public function presetCurrentTime(DateTime $time = null) { | ||
if (!$time) { | ||
$time = new DateTime(); | ||
} | ||
$this->time = clone $time; | ||
} | ||
} |
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.