Skip to content

Commit

Permalink
Squashed 'src/Pingpong/Widget/' changes from 895f0d6..3ad3e6a
Browse files Browse the repository at this point in the history
3ad3e6a add new createMatcher method to the Widget class
de25f0e upgrade to laravel 5.1
01e8d2f merge branch 2.0 into 2.1
03bb1c1 Update header
3b73fae Merge branch 2.0
64c61c2 set minimum stability to dev
640f364 Added support for Laravel 5.1 (develop version). Ref: pingpong-labs/modules#151

git-subtree-dir: src/Pingpong/Widget
git-subtree-split: 3ad3e6a33f413ab091ea3cf7022e1e44ad084fba
  • Loading branch information
Gravitano committed Jun 22, 2015
1 parent 3320471 commit 3bf567a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
21 changes: 15 additions & 6 deletions Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,25 @@ public function subscribe($subscriber)
protected function registerBlade($name)
{
$this->blade->extend(function ($view, $compiler) use ($name) {
$pattern = $compiler->createMatcher($name);
$pattern = $this->createMatcher($name);

$replace = '$1<?php echo Widget::'.$name.'$2; ?>';

return preg_replace($pattern, $replace, $view);
});
}

/**
* Get the regular expression for a generic Blade function.
*
* @param string $function
* @return string
*/
protected function createMatcher($function)
{
return '/(?<!\w)(\s*)@'.$function.'(\s*\(.*\))/';
}

/**
* Determine whether a widget there or not.
*
Expand Down Expand Up @@ -129,7 +140,7 @@ public function get($name, array $parameters = array())
return $this->getCallback($callback, $parameters);
}

return;
return null;
}

/**
Expand Down Expand Up @@ -241,10 +252,8 @@ public function callGroup($name, $parameters = array())

$result = '';

$widgets = $this->reorderWidgets($this->groups[$name]);

foreach ($widgets as $key => $widget) {
$result .= $this->get($widget['name'], array_get($parameters, $key, array()));
foreach ($this->groups[$name] as $key => $widget) {
$result .= $this->get($widget, array_get($parameters, $key, array()));
}

return $result;
Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
],
"require": {
"php": ">=5.3.0",
"illuminate/support": "5.0.*",
"illuminate/container": "5.0.*",
"illuminate/view": "5.0.*",
"illuminate/html": "5.0.*",
"illuminate/routing": "5.0.*"
"illuminate/support": "5.1.*",
"illuminate/container": "5.1.*",
"illuminate/view": "5.1.*",
"illuminate/html": "5.1.*",
"illuminate/routing": "5.1.*"
},
"require-dev": {
"mockery/mockery": "~0.9",
Expand All @@ -30,5 +30,5 @@
"Pingpong\\Widget\\": ""
}
},
"minimum-stability": "stable"
"minimum-stability": "dev"
}

0 comments on commit 3bf567a

Please sign in to comment.