-
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.
- Loading branch information
Showing
12 changed files
with
131 additions
and
54 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
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,52 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
/** | ||
* Flextype (https://flextype.org) | ||
* Founded by Sergey Romanenko and maintained by Flextype Community. | ||
*/ | ||
|
||
namespace Flextype\Plugin\Twig\Twig; | ||
|
||
use Atomastic\Strings\Strings; | ||
use Twig\Extension\AbstractExtension; | ||
|
||
class StringsTwigExtension extends AbstractExtension | ||
{ | ||
/** | ||
* Constructor | ||
*/ | ||
public function __construct() | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* Callback for twig. | ||
* | ||
* @return array | ||
*/ | ||
public function getFunctions() : array | ||
{ | ||
return [ | ||
new \Twig\TwigFunction('strings', [$this, 'strings']), | ||
]; | ||
} | ||
|
||
/** | ||
* Create a new stringable object from the given string. | ||
* | ||
* Initializes a Strings object and assigns both $string and $encoding properties | ||
* the supplied values. $string is cast to a string prior to assignment. Throws | ||
* an InvalidArgumentException if the first argument is an array or object | ||
* without a __toString method. | ||
* | ||
* @param mixed $string Value to modify, after being cast to string. Default: '' | ||
* @param mixed $encoding The character encoding. Default: UTF-8 | ||
*/ | ||
function strings($string = '', $encoding = 'UTF-8'): Strings | ||
{ | ||
return new Strings($string, $encoding); | ||
} | ||
} |
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