Skip to content

Commit

Permalink
Fix helper functions from clashing with blade-svg.
Browse files Browse the repository at this point in the history
  • Loading branch information
Log1x committed Nov 28, 2018
1 parent a50cab5 commit 4dd76ad
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 36 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,5 @@ add_filter('bladesvg', function () {
## Usage

Please refer to the original [Blade SVG documentation](https://github.com/adamwathan/blade-svg#basic-usage) for usage examples.

Note: When calling helper functions directly, you must use the `App` namespace.
60 changes: 30 additions & 30 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/BladeSvgSage.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BladeSvgSage
*/
public function __construct()
{
if (! function_exists('\App\\sage') || ! class_exists('\BladeSvg\\SvgFactory') || ! $this->config()) {
if (! function_exists('App\\sage') || ! class_exists('BladeSvg\\SvgFactory') || ! $this->config()) {
return;
}

Expand Down Expand Up @@ -56,17 +56,17 @@ public function directives()
{
/** Create @icon() Blade directive */
sage('blade')->compiler()->directive('icon', function ($expression) {
return "<?php echo e(svg_image({$expression})) ?>";
return "<?php echo e(App\svg_image({$expression})) ?>";
});

/** Create @svg() Blade directive */
sage('blade')->compiler()->directive('svg', function ($expression) {
return "<?php echo e(svg_image({$expression})) ?>";
return "<?php echo e(App\svg_image({$expression})) ?>";
});

/** Create @spritesheet Blade directive */
sage('blade')->compiler()->directive('spritesheet', function () {
return "<?php echo e(svg_spritesheet()) ?>";
return "<?php echo e(App\svg_spritesheet()) ?>";
});
}

Expand Down
4 changes: 2 additions & 2 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
* @return string
*/
if (! function_exists('svg_spritesheet')) {
if (! function_exists('App\\svg_spritesheet')) {
function svg_spritesheet()
{
return sage(BladeSvgSage::class)->spritesheet();
Expand All @@ -24,7 +24,7 @@ function svg_spritesheet()
* @param array $attrs
* @return string
*/
if (! function_exists('svg_image')) {
if (! function_exists('App\\svg_image')) {
function svg_image($name = '', $class = '', $attrs = [])
{
if (empty($name)) {
Expand Down

0 comments on commit 4dd76ad

Please sign in to comment.