@@ -350,7 +350,7 @@ |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | /** |
| 353 | - * @param $element |
|
| 353 | + * @param string $element |
|
| 354 | 354 | * @return ElementFactory |
| 355 | 355 | */ |
| 356 | 356 | protected function getFactory($element) |
@@ -12,7 +12,6 @@ |
||
| 12 | 12 | use Malezha\Menu\Contracts\MenuRender; |
| 13 | 13 | use Malezha\Menu\Traits\HasActiveAttributes as TraitHasActiveAttributes; |
| 14 | 14 | use Malezha\Menu\Traits\HasAttributes; |
| 15 | -use Opis\Closure\SerializableClosure; |
|
| 16 | 15 | |
| 17 | 16 | /** |
| 18 | 17 | * Class Builder |
@@ -95,7 +95,7 @@ |
||
| 95 | 95 | $result = call_user_func($callback, $factory); |
| 96 | 96 | $result = is_null($result) ? $factory : $result; |
| 97 | 97 | |
| 98 | - if (! $result instanceof ElementFactory && ! $result instanceof Element) { |
|
| 98 | + if (!$result instanceof ElementFactory && !$result instanceof Element) { |
|
| 99 | 99 | throw new \RuntimeException("Result of callback must be [" . |
| 100 | 100 | Element::class . "] or [" . ElementFactory::class . "]"); |
| 101 | 101 | } |
@@ -67,7 +67,7 @@ |
||
| 67 | 67 | $factory = $this->factory(); |
| 68 | 68 | $factory->text = 'Serialize'; |
| 69 | 69 | $factory->attributes->put('class', 'serialized'); |
| 70 | - $factory->displayRule = function () use ($tmp) { |
|
| 70 | + $factory->displayRule = function() use ($tmp) { |
|
| 71 | 71 | return $tmp === 0; |
| 72 | 72 | }; |
| 73 | 73 | $element = $factory->build(); |
@@ -1,9 +1,9 @@ |
||
| 1 | 1 | <div class="div-menu"> |
| 2 | 2 | <?php if ($menu) :?> |
| 3 | - <<?php echo $menu->getType() . $menu->buildAttributes();?>> |
|
| 3 | + <<?php echo $menu->getType() . $menu->buildAttributes(); ?>> |
|
| 4 | 4 | <?php foreach ($menu->all() as $element) :?> |
| 5 | - <?php echo $element->render($renderView);?> |
|
| 6 | - <?php endforeach;?> |
|
| 7 | - </<?php echo $menu->getType();?>> |
|
| 8 | - <?php endif;?> |
|
| 5 | + <?php echo $element->render($renderView); ?> |
|
| 6 | + <?php endforeach; ?> |
|
| 7 | + </<?php echo $menu->getType(); ?>> |
|
| 8 | + <?php endif; ?> |
|
| 9 | 9 | </div> |
| 10 | 10 | \ No newline at end of file |
@@ -2,7 +2,10 @@ |
||
| 2 | 2 | <?php if ($menu) :?> |
| 3 | 3 | <<?php echo $menu->getType() . $menu->buildAttributes();?>> |
| 4 | 4 | <?php foreach ($menu->all() as $element) :?> |
| 5 | - <?php if ($element instanceof \Malezha\Menu\Contracts\ElementFactory) $element = $element->build(); ?> |
|
| 5 | + <?php if ($element instanceof \Malezha\Menu\Contracts\ElementFactory) { |
|
| 6 | + $element = $element->build(); |
|
| 7 | +} |
|
| 8 | +?> |
|
| 6 | 9 | <?php echo $element->render($renderView);?> |
| 7 | 10 | <?php endforeach;?> |
| 8 | 11 | </<?php echo $menu->getType();?>> |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | * @internal param string $name |
| 24 | 24 | */ |
| 25 | 25 | function __construct(Container $container, Attributes $attributes, Attributes $activeAttributes, |
| 26 | - $type = self::UL, $view = null); |
|
| 26 | + $type = self::UL, $view = null); |
|
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * @param string $name |
@@ -35,6 +35,7 @@ |
||
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * @inheritdoc |
| 38 | + * @param string $view |
|
| 38 | 39 | */ |
| 39 | 40 | public function setView($view) |
| 40 | 41 | { |
@@ -1,1 +1,1 @@ |
||
| 1 | -Hello, <?php echo $menu;?> builder! |
|
| 2 | 1 | \ No newline at end of file |
| 2 | +Hello, <?php echo $menu; ?> builder! |
|
| 3 | 3 | \ No newline at end of file |
@@ -1,1 +1,1 @@ |
||
| 1 | -<div<?php echo $attributes;?>><?php echo $text;?></div> |
|
| 2 | 1 | \ No newline at end of file |
| 2 | +<div<?php echo $attributes; ?>><?php echo $text; ?></div> |
|
| 3 | 3 | \ No newline at end of file |
@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | protected function registerRenderSystem() |
| 81 | 81 | { |
| 82 | - $this->app->bind('menu.render', function (Container $app) { |
|
| 82 | + $this->app->bind('menu.render', function(Container $app) { |
|
| 83 | 83 | $config = $app->make(Repository::class)->get('menu'); |
| 84 | 84 | $key = $config['default']; |
| 85 | 85 | $available = $config['renders']; |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | |
| 96 | 96 | protected function registerComparativeUrl() |
| 97 | 97 | { |
| 98 | - $this->app->singleton('menu.compare-url', function (Container $app) { |
|
| 98 | + $this->app->singleton('menu.compare-url', function(Container $app) { |
|
| 99 | 99 | return $app->make(ComparativeUrl::class, [ |
| 100 | 100 | 'skippedPaths' => $app->make(Repository::class)->get('menu.skippedPaths'), |
| 101 | 101 | ]); |
@@ -148,9 +148,9 @@ discard block |
||
| 148 | 148 | $builder = $this->builderFactory(); |
| 149 | 149 | |
| 150 | 150 | $builder->create('index', Link::class, |
| 151 | - function (LinkFactory $factory) {}); |
|
| 151 | + function(LinkFactory $factory) {}); |
|
| 152 | 152 | $builder->create('index', SubMenu::class, |
| 153 | - function (SubMenuFactory $factory) {}); // Duplicate |
|
| 153 | + function(SubMenuFactory $factory) {}); // Duplicate |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | public function testGet() |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | $builder = $this->builderFactory(); |
| 159 | 159 | |
| 160 | 160 | $item = $builder->create('test', Link::class, |
| 161 | - function (LinkFactory $factory) {}); |
|
| 161 | + function(LinkFactory $factory) {}); |
|
| 162 | 162 | |
| 163 | 163 | $this->assertEquals($item, $builder->get('test')); |
| 164 | 164 | $this->assertEquals(null, $builder->get('notFound')); |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | $builder = $this->builderFactory(); |
| 172 | 172 | |
| 173 | 173 | $item = $builder->create('test', Link::class, |
| 174 | - function (LinkFactory $factory) {}); |
|
| 174 | + function(LinkFactory $factory) {}); |
|
| 175 | 175 | |
| 176 | 176 | $this->assertEquals($item, $builder->getByIndex(0)); |
| 177 | 177 | $this->assertEquals(null, $builder->getByIndex(1)); |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | $this->assertEquals([], $builder->all()); |
| 204 | 204 | $item = $builder->create('test', Link::class, |
| 205 | - function (LinkFactory $factory) {}); |
|
| 205 | + function(LinkFactory $factory) {}); |
|
| 206 | 206 | $this->assertEquals(['test' => $item], $builder->all()); |
| 207 | 207 | } |
| 208 | 208 | |
@@ -211,9 +211,9 @@ discard block |
||
| 211 | 211 | $builder = $this->builderFactory(); |
| 212 | 212 | |
| 213 | 213 | $builder->create('test', Link::class, |
| 214 | - function (LinkFactory $factory) {}); |
|
| 214 | + function(LinkFactory $factory) {}); |
|
| 215 | 215 | $builder->create('another', Text::class, |
| 216 | - function (TextFactory $factory) {}); |
|
| 216 | + function(TextFactory $factory) {}); |
|
| 217 | 217 | |
| 218 | 218 | $this->assertTrue($builder->has('test')); |
| 219 | 219 | $builder->forget('test'); |
@@ -348,14 +348,14 @@ discard block |
||
| 348 | 348 | $factory->url = url('logout'); |
| 349 | 349 | }); |
| 350 | 350 | |
| 351 | - $builder->insertAfter('index', function (Builder $builder) { |
|
| 351 | + $builder->insertAfter('index', function(Builder $builder) { |
|
| 352 | 352 | $builder->create('users', Link::class, function(LinkFactory $factory) { |
| 353 | 353 | $factory->title = 'Users'; |
| 354 | 354 | $factory->url = url('users'); |
| 355 | 355 | }); |
| 356 | 356 | }); |
| 357 | 357 | |
| 358 | - $builder->insertBefore('users', function (Builder $builder) { |
|
| 358 | + $builder->insertBefore('users', function(Builder $builder) { |
|
| 359 | 359 | $builder->create('profile', Link::class, function(LinkFactory $factory) { |
| 360 | 360 | $factory->title = 'Profile'; |
| 361 | 361 | $factory->url = url('profile'); |
@@ -370,7 +370,7 @@ discard block |
||
| 370 | 370 | $this->expectException(\RuntimeException::class); |
| 371 | 371 | |
| 372 | 372 | $builder = $this->builderFactory(); |
| 373 | - $builder->insertBefore('not_exist', function (Builder $builder) {}); |
|
| 373 | + $builder->insertBefore('not_exist', function(Builder $builder) {}); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | public function testInsertExceptionDuplicate() |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | $factory->title = 'Some'; |
| 387 | 387 | $factory->url = '/'; |
| 388 | 388 | }); |
| 389 | - $builder->insertAfter('home', function (Builder $builder) { |
|
| 389 | + $builder->insertAfter('home', function(Builder $builder) { |
|
| 390 | 390 | $builder->create('some', Text::class, function(TextFactory $factory) { |
| 391 | 391 | $factory->text = 'Duplicate some'; |
| 392 | 392 | }); |
@@ -425,7 +425,7 @@ discard block |
||
| 425 | 425 | }); |
| 426 | 426 | }); |
| 427 | 427 | $builder->create('settings', Link::class, function(LinkFactory $factory) { |
| 428 | - $factory->displayRule = function () {return false;}; |
|
| 428 | + $factory->displayRule = function() {return false; }; |
|
| 429 | 429 | $factory->title = 'Settings'; |
| 430 | 430 | $factory->url = url('/settings'); |
| 431 | 431 | }); |