Skip to content

Commit

Permalink
Merge pull request #93 from ARCANEDEV/develop
Browse files Browse the repository at this point in the history
Updating the package
  • Loading branch information
arcanedev-maroc authored Apr 27, 2017
2 parents aa3e86b + 08b47fd commit 328c301
Show file tree
Hide file tree
Showing 42 changed files with 425 additions and 281 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ env:

before_script:
- travis_retry composer self-update
- travis_retry composer require --prefer-source --no-interaction --dev "orchestra/testbench-browser-kit:${TESTBENCH_VERSION}" "orchestra/database:${TESTBENCH_VERSION}"
- travis_retry composer require --prefer-dist --no-interaction "orchestra/testbench-browser-kit:${TESTBENCH_VERSION}"

script:
- composer validate
Expand Down
27 changes: 7 additions & 20 deletions _docs/3-Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,14 @@ If you want to hide the default locale but always show other locales in the url,
/**
* Returns an URL adapted to $locale or current locale.
*
*
* @param string|bool $locale
* @param string|false $url
* @param array $attributes
* @param string|null $locale
* @param string|null $url
* @param array $attributes
* @param bool|false $showHiddenLocale
*
* @return string|false
*
* @throws UndefinedSupportedLocalesException
* @throws UnsupportedLocaleException
*/
public function getLocalizedURL($locale = null, $url = null, $attributes = [])
public function getLocalizedURL($locale = null, $url = null, array $attributes = [], $showHiddenLocale = false)

// OR

Expand All @@ -124,8 +121,6 @@ public function getLocalizedURL($locale = null, $url = null, $attributes = [])
* @param string $url
* @param string|null $locale
*
* @throws UnsupportedLocaleException
*
* @return string
*/
public function localizeURL($url = null, $locale = null);
Expand Down Expand Up @@ -157,13 +152,11 @@ It returns a clean URL of any localization.
* @param string|bool $locale
* @param string $transKey
* @param array $attributes
* @param bool|false $showHiddenLocale
*
* @return string|false
*
* @throws UndefinedSupportedLocalesException
* @throws UnsupportedLocaleException
*/
public function getUrlFromRouteName($locale, $transKey, $attributes = [])
public function getUrlFromRouteName($locale, $transKey, array $attributes = [], $showHiddenLocale = false)
```

It returns a route, localized to the desired locale using the locale passed.
Expand Down Expand Up @@ -192,8 +185,6 @@ function localized_route($transRoute, array $attributes = [], $locale = null)
* Return an array of all supported Locales.
*
* @return \Arcanedev\Localization\Entities\LocaleCollection
*
* @throws UndefinedSupportedLocalesException
*/
public function getSupportedLocales()
```
Expand All @@ -207,8 +198,6 @@ It returns all locales as a `Arcanedev\Localization\Entities\LocaleCollection` C
* Get supported locales keys.
*
* @return array
*
* @throws UndefinedSupportedLocalesException
*/
public function getSupportedLocalesKeys()
```
Expand Down Expand Up @@ -370,8 +359,6 @@ public function setBaseUrl($url)
*
* @param string|bool $locale
*
* @throws UndefinedSupportedLocalesException
*
* @return bool
*/
public function isLocaleSupported($locale)
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
}
},
"scripts": {
"testbench": "composer require --dev \"orchestra/testbench-browser-kit=~3.4\" \"orchestra/database=~3.4\""
"testbench": "composer require --dev \"orchestra/testbench-browser-kit=~3.4\""
},
"suggest": {
"ext-intl": "Use Intl extension for 'Locale' class (an identifier used to get language)."
Expand Down
2 changes: 2 additions & 0 deletions src/Contracts/LocalesManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface LocalesManager
| Getters & Setters
| -----------------------------------------------------------------
*/

/**
* Set and return current locale.
*
Expand Down Expand Up @@ -94,6 +95,7 @@ public function setSupportedLocales(array $supportedLocales);
| Check Methods
| -----------------------------------------------------------------
*/

/**
* Check if default is supported.
*
Expand Down
15 changes: 10 additions & 5 deletions src/Contracts/Localization.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface Localization
| Getters & Setters
| -----------------------------------------------------------------
*/

/**
* Returns default locale.
*
Expand Down Expand Up @@ -127,6 +128,7 @@ public function setRouteNameFromRequest(Request $request);
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Translate routes and save them to the translated routes array (used in the localize route filter).
*
Expand Down Expand Up @@ -158,13 +160,14 @@ public function getNonLocalizedURL($url = null);
/**
* Returns an URL adapted to $locale.
*
* @param string|bool $locale
* @param string|false $url
* @param array $attributes
* @param string|null $locale
* @param string|null $url
* @param array $attributes
* @param bool|bool $showHiddenLocale
*
* @return string|false
*/
public function getLocalizedURL($locale = null, $url = null, $attributes = []);
public function getLocalizedURL($locale = null, $url = null, array $attributes = [], $showHiddenLocale = false);

/**
* Create an url from the uri.
Expand All @@ -185,15 +188,17 @@ public function createUrlFromUri($uri);
* @param string|bool $locale
* @param string $transKey
* @param array $attributes
* @param bool|false $showHiddenLocale
*
* @return string|false
*/
public function getUrlFromRouteName($locale, $transKey, $attributes = []);
public function getUrlFromRouteName($locale, $transKey, array $attributes = [], $showHiddenLocale = false);

/* -----------------------------------------------------------------
| Check Methods
| -----------------------------------------------------------------
*/

/**
* Hide the default locale in URL ??
*
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/Negotiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ interface Negotiator
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Make Negotiator instance.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Contracts/RouteBindable.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@
*/
interface RouteBindable
{
/* -----------------------------------------------------------------
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Get the wildcard value from the class.
*
Expand Down
6 changes: 5 additions & 1 deletion src/Contracts/RouteTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ interface RouteTranslator
| Getters & Setters
| -----------------------------------------------------------------
*/

/**
* Get current route.
*
Expand Down Expand Up @@ -41,6 +42,7 @@ public function getTranslatedRoutes();
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Translate routes and save them to the translated routes array (used in the localize route filter).
*
Expand Down Expand Up @@ -93,17 +95,19 @@ public function findTranslatedRouteByPath($path, $locale);
* @param string $transKey
* @param array $attributes
* @param bool|false $defaultHidden
* @param bool|false $showHiddenLocale
*
* @return string
*/
public function getUrlFromRouteName(
$locale, $defaultLocale, $transKey, $attributes = [], $defaultHidden = false
$locale, $defaultLocale, $transKey, $attributes = [], $defaultHidden = false, $showHiddenLocale = false
);

/* -----------------------------------------------------------------
| Check Methods
| -----------------------------------------------------------------
*/

/**
* Check if has current route.
*
Expand Down
1 change: 1 addition & 0 deletions src/Contracts/Url.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ interface Url
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Extract attributes for current url.
*
Expand Down
5 changes: 5 additions & 0 deletions src/Entities/Locale.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Locale implements Arrayable, Jsonable, JsonSerializable
| Properties
| -----------------------------------------------------------------
*/

/**
* Locale key.
*
Expand Down Expand Up @@ -69,6 +70,7 @@ class Locale implements Arrayable, Jsonable, JsonSerializable
| Constructor
| -----------------------------------------------------------------
*/

/**
* Create Locale instance.
*
Expand All @@ -89,6 +91,7 @@ public function __construct($key, array $data)
| Getters & Setters
| -----------------------------------------------------------------
*/

/**
* Get local key.
*
Expand Down Expand Up @@ -268,6 +271,7 @@ private function setDefault()
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Create Locale instance.
*
Expand All @@ -285,6 +289,7 @@ public static function make($key, array $data)
| Other Methods
| -----------------------------------------------------------------
*/

/**
* Get the locale entity as an array.
*
Expand Down
5 changes: 4 additions & 1 deletion src/Entities/LocaleCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class LocaleCollection extends Collection
| Properties
| -----------------------------------------------------------------
*/

/**
* Supported locales.
*
Expand All @@ -25,6 +26,7 @@ class LocaleCollection extends Collection
| Getters & Setters
| -----------------------------------------------------------------
*/

/**
* Set supported locales keys.
*
Expand All @@ -43,13 +45,14 @@ public function setSupportedKeys(array $supported)
| Main Methods
| -----------------------------------------------------------------
*/

/**
* Get the first locale from the collection.
*
* @param callable|null $callback
* @param mixed $default
*
* @return Locale|mixed
* @return \Arcanedev\Localization\Entities\Locale|mixed
*/
public function first(callable $callback = null, $default = null)
{
Expand Down
Loading

0 comments on commit 328c301

Please sign in to comment.