Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkudera committed Jul 18, 2015
2 parents f3381a3 + 41dd31a commit 75cb288
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 85 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ before_script:
- composer self-update
- composer install --no-interaction --prefer-source --dev

script: VERBOSE=true sh ./tests/run-tests.sh -s tests/DKTests/
script: ./vendor/bin/tester -s -p php -c ./tests/php.ini-unix ./tests/DKTests/
50 changes: 26 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[![Build Status](https://travis-ci.org/sakren/nette-menu.png?branch=master)](https://travis-ci.org/sakren/nette-menu)
[![Donate](http://b.repl.ca/v1/donate-PayPal-brightgreen.png)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPH6AC9D5LGHY)
[![Build Status](https://img.shields.io/travis/Carrooi/Nette-Menu.svg?style=flat-square)](https://travis-ci.org/Carrooi/Nette-Menu)
[![Donate](https://img.shields.io/badge/donate-PayPal-brightgreen.svg?style=flat-square)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=HPH6AC9D5LGHY)

# Nette menu

Expand All @@ -9,12 +9,11 @@ Nette component for creating menus and breadcrumbs.

```
$ composer require sakren/nette-menu
$ composer update
```

Now you need to register this as Nette extension in your config.neon file.

```
```yaml
extensions:
menu: DK\Menu\DI\Extension

Expand All @@ -24,7 +23,7 @@ includes:

Than you can create new `menu` section for example in menu.neon.

```
```yaml
menu:

default:
Expand All @@ -49,13 +48,13 @@ Of course you can create more nested menu.
Also you can see that there are more ways how to write link. If you have got single link without children, you can use
this.

```
```yaml
Title of link: Presenter:action
```
or links with children
```
```yaml
Title of link:
target: Presenter:action
items: []
Expand All @@ -65,7 +64,7 @@ there is actually also third way, but it is useful just for specific cases and i

## Render menu and breadcrumb

```
```php
class BasePresenter extends Nette\Application\UI\Presenter
{

Expand All @@ -87,7 +86,7 @@ class BasePresenter extends Nette\Application\UI\Presenter

@layout.latte:

```
```smarty
{control menu:breadcrumb}
{control menu}
Expand All @@ -96,12 +95,12 @@ class BasePresenter extends Nette\Application\UI\Presenter
## Render sitemap.xml

Router
```
```php
$router[] = new Route('sitemap.xml', 'Homepage:sitemap');
```

Homepage/sitemap.latte
```
```smarty
{extends none}
{control menu:sitemapXml}
```
Expand All @@ -111,7 +110,7 @@ Homepage/sitemap.latte
You can hide some links for example for users without specific role, guest users, actions in other module or when
needed presenter parameter is missing.

```
```yaml
menu:

default:
Expand Down Expand Up @@ -145,7 +144,7 @@ menu:

or whole menu can be allowed for example just logged users:

```
```yaml
menu:

default:
Expand All @@ -161,7 +160,7 @@ menu:
Imagine that you have for example link to books settings and page for adding book which you do not wish to add to your
menu but at the same time you want base books settings link to be highlighted.

```
```yaml
menu:

default:
Expand All @@ -179,7 +178,7 @@ menu:
if you want to highlight "Books settings" link for all actions in BookPresenter, you can include all targets with
regexp.

```
```yaml
menu:

default:
Expand All @@ -191,7 +190,7 @@ menu:

or with array of included targets.

```
```yaml
menu:

default:
Expand All @@ -207,7 +206,7 @@ menu:

## Custom templates

```
```yaml
menu:

default:
Expand All @@ -221,7 +220,7 @@ menu:

## Translated titles

```
```yaml
menu:

default:
Expand All @@ -233,7 +232,7 @@ menu:

Lets say that we want base menu and menu just for users in `admin` role.

```
```yaml
menu:

default:
Expand All @@ -250,7 +249,7 @@ menu services.

Solution is to create custom control and factory classes.

```
```php
namespace App\Components\AdminMenu;

use DK;
Expand All @@ -271,7 +270,7 @@ interface IMenuControlFactory

now we have to update our menu configuration

```
```yaml
menu:

admin:
Expand All @@ -288,7 +287,7 @@ below:

Books / Harry Potter / Edit

```
```yaml
menu:

default:
Expand All @@ -304,7 +303,7 @@ link for adding another links into it.

First, we will add just one small helper method to our BasePresenter.

```
```php
class BasePresenter extends Nette\Application\UI\Presenter
{

Expand Down Expand Up @@ -337,7 +336,7 @@ class BasePresenter extends Nette\Application\UI\Presenter

BookPresenter:

```
```php
class BookPresenter extends BasePresenter
{

Expand All @@ -355,6 +354,9 @@ class BookPresenter extends BasePresenter

## Changelog

* 1.1.1
+ Move under Carrooi organization

* 1.1.0
+ Support for ACL permissions (thanks [whipsterCZ](https://github.com/whipsterCZ))
+ Support for generating sitemap (thanks [whipsterCZ](https://github.com/whipsterCZ))
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "sakren/nette-menu",
"name": "carrooi/nette-menu",
"type": "library",
"description": "Menu controls for Nette framework",
"keywords": ["nette", "menu", "control", "breadcrumbs"],
"homepage": "http://github.com/sakren/nette-menu",
"homepage": "https://github.com/Carrooi/Nette-Menu",
"license": "MIT",
"authors": [
{
Expand All @@ -13,10 +13,10 @@
}
],
"support": {
"issues": "https://github.com/sakren/nette-menu/issues"
"issues": "https://github.com/Carrooi/Nette-Menu/issues"
},
"require": {
"nette/nette": ">= 2.1.0"
"nette/nette": ">= 2.2.0"
},
"require-dev": {
"nette/tester": "@dev"
Expand Down
20 changes: 17 additions & 3 deletions tests/DKTests/Menu/Extension.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ class ExtensionTest extends TestCase
{
$di = $this->createContainer('more');

$controlFactory = $di->getByType('DKTests\Menu\ICustomControlFactory'); /** @var $controlFactory \DKTests\Menu\ICustomControlFactory */
Assert::true($controlFactory instanceof ICustomControlFactory);
Assert::true($controlFactory->create() instanceof CustomControl);
$controlFactory = $di->getByType('DKTests\Menu\IOtherCustomControlFactory'); /** @var $controlFactory \DKTests\Menu\ICustomControlFactory */
Assert::true($controlFactory instanceof IOtherCustomControlFactory);
Assert::true($controlFactory->create() instanceof OtherCustomControl);
}

}
Expand All @@ -129,4 +129,18 @@ interface ICustomControlFactory
}


class OtherCustomControl extends Control {}

interface IOtherCustomControlFactory
{


/**
* @return \DKTests\Menu\OtherCustomControl
*/
public function create();

}


\run(new ExtensionTest);
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace DKTests\BooksModule\Presenters;

require_once __DIR__ . '/../../presenters/BasePresenter.php';
require_once __DIR__ . '/../../Presenters/BasePresenter.php';

use DKTests\Presenters\BasePresenter;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace DKTests\Presenters;

use Nette\Application\UI\Presenter;
use Nette\DI\Container;

/**
*
Expand All @@ -12,8 +13,19 @@ class BasePresenter extends Presenter
{


/** @var \DK\Menu\UI\IControlFactory @inject */
public $menuFactory;
/** @var \DK\Menu\UI\IControlFactory */
private $menuFactory;


/**
* @param \Nette\DI\Container $context
*/
public function __construct(Container $context)
{
parent::__construct();

$this->menuFactory = $context->getByType('DK\Menu\UI\IControlFactory'); // just for disabling warning about non existing services
}


/**
Expand Down
5 changes: 1 addition & 4 deletions tests/DKTests/app/config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ nette:
mapping:
*: DKTests\*Module\Presenters\*Presenter

security:
frames: null

session:
autoStart: false

Expand All @@ -21,7 +18,7 @@ services:
cacheStorage:
class: Nette\Caching\Storages\MemoryStorage

# to lazy to create new factory service
# too lazy to create new factory service
router:
class: Nette\Application\Routers\RouteList
setup:
Expand Down
6 changes: 4 additions & 2 deletions tests/DKTests/app/config/more.neon
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
menu:

default:

other:
controlClass: DKTests\Menu\CustomControl
controlInterface: DKTests\Menu\ICustomControlFactory

other:
controlClass: DKTests\Menu\OtherCustomControl
controlInterface: DKTests\Menu\IOtherCustomControlFactory
4 changes: 3 additions & 1 deletion tests/DKTests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php

if (@!include __DIR__ . '/../../vendor/autoload.php') {
if (!$loader = @include __DIR__ . '/../../vendor/autoload.php') {
echo 'Install Nette Tester using `composer update --dev`';
exit(1);
}

$loader->addPsr4('DKTests\\', __DIR__. '/app');

// configure environment
Tester\Environment::setup();
class_alias('Tester\Assert', 'Assert');
Expand Down
43 changes: 0 additions & 43 deletions tests/run-tests.sh

This file was deleted.

0 comments on commit 75cb288

Please sign in to comment.