Skip to content

Commit c62790e

Browse files
authored
Release 4.4.0
2 parents d35dfa8 + 8eafd4b commit c62790e

File tree

169 files changed

+2851
-1096
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+2851
-1096
lines changed

.gitignore

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Ignores text editor metadata
22
*.komodoproject
3-
.php_cs.cache
4-
.serenata
3+
.editorconfig
4+
.vscode
55

66
# Ignores Mac metadata. You can configure this globally if you use a Mac: http://islegend.com/development/setting-global-gitignore-mac-windows/
77
.DS_Store
@@ -73,6 +73,10 @@ app/assets/*
7373
vagrant/Homestead/
7474
.vagrant/*
7575

76+
# Ignore dev utils cache
77+
.phpunit.result.cache
78+
.php_cs.cache
79+
7680
# Igore npm lockfile
7781
build/package-lock.json
7882
build/package.lock

.travis.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
sudo: false
2-
dist: trusty
2+
dist: xenial
33
language: php
44

55
services:
@@ -12,6 +12,7 @@ php:
1212
- 7.1
1313
- 7.2
1414
- 7.3
15+
- 7.4
1516

1617
env:
1718
matrix:
@@ -20,6 +21,9 @@ env:
2021
- DB=pgsql
2122
- DB=memory
2223

24+
matrix:
25+
fast_finish: true
26+
2327
cache:
2428
directories:
2529
- $HOME/.composer/cache

CHANGELOG.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,48 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [v4.4.0]
9+
10+
### Changed Requirements
11+
- PHP 7.3 is now the recommended version, as 7.2 is already security fixes only.
12+
13+
### Changed Composer Dependencies
14+
- Reset Slim version to ^3.12
15+
- Updated PHPUnit to 8.5 (Version 7.5 still used for PHP 7.1)
16+
17+
### Added
18+
- PHP 7.4 Support & Travis environment.
19+
- New `Locale` service. Provides a list of available locales in diffeent form.
20+
- New `BaseServicesProvider` abstract class added as base for all ServiceProvider class.
21+
- Sprinkle Services Provider can now be autoloaded using the `$servicesproviders` property in the sprinkle bootstrapper class.
22+
- Current locale code can now be accessed from Twig using the `currentLocale` global variable ([#1056]).
23+
- Locale now have config & metadata file ([#850])
24+
- Added `locale:compare`, `locale:dictionary` and `locale:info` Bakery commands.
25+
- New `cli` service. Returns true if current app is a CLI envrionement, false otherwise.
26+
27+
### Changed
28+
- `Interop\Container\ContainerInterface` has been replaced with `Psr\Container\ContainerInterface`.
29+
- `\UserFrosting\I18n\MessageTranslator` is now `\UserFrosting\I18n\Translator`.
30+
- Translator service moved to it's own `UserFrosting\Sprinkle\Core\I18n\TranslatorServicesProvider` class.
31+
- Travis now uses Xenial instead of Trusty.
32+
- `site.locales.available` config now accept `(string) identifier => (bool) enabled`. Set identifier to false or null to remove it from the list.
33+
- Locale plural rules moved from the keys file to the new metadata files.
34+
35+
### Fixed
36+
- When internationalizing, the lang attribute value of the Twig template is not set to follow changes ([#982])
37+
- `pt_Br` locale identifier renamed to `pt_BR`.
38+
- Improved Docker support ([#1057])
39+
- Improved Bakery debug command output
40+
- Improve ordering by activity date ([#1061] & [#1062]; Thanks @ktecho!)
41+
- Updated Vagrant config and documentation
42+
- Fixed a bug where `withTrashed` in `findUnique` was not available when `SoftDeletes` trait is not included in a model.
43+
- CSRF global middleware is not loaded anymore if in a CLI envrionement. This will avoid sessions to be created for bakery and tests by default.
44+
- Browserified node modules not being correctly loaded.
45+
- Browserified node modules potentially colliding with real entrypoints.
46+
47+
### Removed
48+
- `localePathBuilder` service removed. Task now handled by the `locale` and `translator` services.
49+
850
## [v4.3.3]
951

1052
### Fixed
@@ -786,7 +828,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
786828
- Implemented DB-driven home pages for groups. Upon login, a user will be redirected to the `home_page` for their primary group.
787829
- Implemented templated menus. Every group has a corresponding menu template in `models/menu-templates`. Upon login, the menu for a user's primary group is automatically loaded and rendered.
788830
- Implemented function-level user authorization. Whenever a function in `secure_functions` is called, the `user_action_permits` table is checked to see whether or not that user has access to the function (the `action` column), conditional on the boolean functions specified in the `permits` column.
789-
- Organized pages into four categories: account pages, API pages, form pages, and public pages. Public pages reside in the root directory and can be accessed by anyone. Account pages are in the `account` directory and are only accessible after logging in. API pages are in the `api` directory, and consist of all the pages that process or fetch data from the DB and interact with the frontend via AJAX/JSON. They are accessible by any logged in user, but will only perform a function if the user is authorized. Form pages are in the `forms` directory, and consist of pages that generate forms (for creating/updating users, groups, etc.)
831+
- Organized pages into four categories: account pages, API pages, form pages, and public pages. Public pages reside in the root directory and can be accessed by anyone. Account pages are in the `account` directory and are only accessible after logging in. API pages are in the `api` directory, and consist of all the pages that process or fetch data from the DB and interact with the frontend via AJAX/JSON. They are accessible by any logged in user, but will only perform a function if the user is authorized. Form pages are in the `forms` directory, and consist of pages that generate forms (for creating/updating users, groups, etc.)
790832
- Converted registration page to AJAX.
791833
- Improved installer with site configuration.
792834

@@ -834,6 +876,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
834876
[#829]: https://github.com/userfrosting/UserFrosting/issues/829
835877
[#833]: https://github.com/userfrosting/UserFrosting/issues/833
836878
[#838]: https://github.com/userfrosting/UserFrosting/issues/838
879+
[#850]: https://github.com/userfrosting/UserFrosting/issues/850
837880
[#853]: https://github.com/userfrosting/UserFrosting/issues/853
838881
[#854]: https://github.com/userfrosting/UserFrosting/issues/854
839882
[#867]: https://github.com/userfrosting/UserFrosting/issues/867
@@ -859,6 +902,7 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
859902
[#968]: https://github.com/userfrosting/UserFrosting/issues/968
860903
[#976]: https://github.com/userfrosting/UserFrosting/issues/976
861904
[#981]: https://github.com/userfrosting/UserFrosting/issues/981
905+
[#982]: https://github.com/userfrosting/UserFrosting/issues/982
862906
[#983]: https://github.com/userfrosting/UserFrosting/issues/983
863907
[#986]: https://github.com/userfrosting/UserFrosting/issues/986
864908
[#987]: https://github.com/userfrosting/UserFrosting/issues/987
@@ -890,6 +934,10 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
890934
[#1042]: https://github.com/userfrosting/UserFrosting/issues/1042
891935
[#1045]: https://github.com/userfrosting/UserFrosting/issues/1045
892936
[#1050]: https://github.com/userfrosting/UserFrosting/issues/1050
937+
[#1056]: https://github.com/userfrosting/UserFrosting/issues/1056
938+
[#1057]: https://github.com/userfrosting/UserFrosting/issues/1057
939+
[#1061]: https://github.com/userfrosting/UserFrosting/issues/1061
940+
[#1062]: https://github.com/userfrosting/UserFrosting/issues/1062
893941

894942
[v4.2.0]: https://github.com/userfrosting/UserFrosting/compare/v4.1.22...v4.2.0
895943
[v4.2.1]: https://github.com/userfrosting/UserFrosting/compare/v4.2.0...v.4.2.1
@@ -899,3 +947,4 @@ See [http://learn.userfrosting.com/upgrading/40-to-41](Upgrading 4.0.x to 4.1.x
899947
[v4.3.1]: https://github.com/userfrosting/UserFrosting/compare/v4.3.0...v4.3.1
900948
[v4.3.2]: https://github.com/userfrosting/UserFrosting/compare/v4.3.1...v4.3.2
901949
[v4.3.3]: https://github.com/userfrosting/UserFrosting/compare/v4.3.2...v4.3.3
950+
[v4.4.0]: https://github.com/userfrosting/UserFrosting/compare/v4.3.3...v4.4.0

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# UserFrosting 4.3
1+
# UserFrosting 4.4
22

33
[![Latest Version](https://img.shields.io/github/release/userfrosting/UserFrosting.svg)](https://github.com/userfrosting/UserFrosting/releases)
44
![PHP Version](https://img.shields.io/packagist/php-v/userfrosting/userfrosting.svg?color=brightgreen)
@@ -11,8 +11,8 @@
1111
| Branch | Version | Build | Coverage | Style |
1212
| ------ |:-------:|:-----:|:--------:|:-----:|
1313
| [master] | ![](https://img.shields.io/github/release/userfrosting/userfrosting.svg?color=success&label=Version) | [![](https://travis-ci.org/userfrosting/UserFrosting.svg?branch=master)][UF-Travis] | [![](https://codecov.io/gh/userfrosting/userfrosting/branch/master/graph/badge.svg)][UF-Codecov] | [![][style-master]][style] |
14-
| [hotfix] | ![](https://img.shields.io/badge/Version-v4.3.x-yellow.svg) | [![](https://travis-ci.org/userfrosting/UserFrosting.svg?branch=hotfix)][UF-Travis] | [![](https://codecov.io/gh/userfrosting/userfrosting/branch/hotfix/graph/badge.svg)][UF-Codecov] | [![][style-hotfix]][style] |
15-
| [develop] | ![](https://img.shields.io/badge/Version-v4.4.x-orange.svg) | [![](https://travis-ci.org/userfrosting/UserFrosting.svg?branch=develop)][UF-Travis] | [![](https://codecov.io/gh/userfrosting/userfrosting/branch/develop/graph/badge.svg)][UF-Codecov] | [![][style-develop]][style] |
14+
| [hotfix] | ![](https://img.shields.io/badge/Version-v4.4.x-yellow.svg) | [![](https://travis-ci.org/userfrosting/UserFrosting.svg?branch=hotfix)][UF-Travis] | [![](https://codecov.io/gh/userfrosting/userfrosting/branch/hotfix/graph/badge.svg)][UF-Codecov] | [![][style-hotfix]][style] |
15+
| [develop] | ![](https://img.shields.io/badge/Version-v4.5.x-orange.svg) | [![](https://travis-ci.org/userfrosting/UserFrosting.svg?branch=develop)][UF-Travis] | [![](https://codecov.io/gh/userfrosting/userfrosting/branch/develop/graph/badge.svg)][UF-Codecov] | [![][style-develop]][style] |
1616

1717
<!-- Links -->
1818
[master]: https://github.com/userfrosting/UserFrosting
@@ -56,7 +56,7 @@ Please see our [installation guide](https://learn.userfrosting.com/installation)
5656

5757
If you are having trouble installing UserFrosting, please [join us in chat](https://chat.userfrosting.com) or try our [forums](https://forums.userfrosting.com).
5858

59-
If you are generally confused about the structure and layout of the code, or it doesn't look like the kind of PHP code that you're used to, please [start from the beginning](https://learn.userfrosting.com/background).
59+
If you are generally confused about the structure and layout of the code, or it doesn't look like the kind of PHP code that you're used to, please [start from the beginning](https://learn.userfrosting.com/background).
6060

6161
## Mission Objectives
6262

app/defines.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@
1111
namespace UserFrosting;
1212

1313
// Some standard defines
14-
define('UserFrosting\VERSION', '4.3.3');
14+
define('UserFrosting\VERSION', '4.4.0');
1515
define('UserFrosting\DS', '/');
1616
define('UserFrosting\PHP_MIN_VERSION', '7.1');
17-
define('UserFrosting\PHP_RECOMMENDED_VERSION', '7.2');
17+
define('UserFrosting\PHP_RECOMMENDED_VERSION', '7.3');
1818
define('UserFrosting\NODE_MIN_VERSION', 'v10.12.0');
1919
define('UserFrosting\NPM_MIN_VERSION', '6.0.0');
2020

app/sprinkles/account/composer.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,15 @@
99
{
1010
"name": "Alexander Weissman",
1111
"homepage": "https://alexanderweissman.com"
12+
},
13+
{
14+
"name": "Louis Charette",
15+
"homepage": "https://bbqsoftwares.com"
16+
},
17+
{
18+
"name": "Jordan Mele",
19+
"email": "SiliconSoldier@outlook.com.au",
20+
"homepage": "https://blog.djmm.me"
1221
}
1322
],
1423
"require": {

app/sprinkles/account/src/Account.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
namespace UserFrosting\Sprinkle\Account;
1212

13+
use UserFrosting\Sprinkle\Account\I18n\LocaleServicesProvider;
1314
use UserFrosting\System\Sprinkle\Sprinkle;
1415

1516
/**
@@ -19,4 +20,10 @@
1920
*/
2021
class Account extends Sprinkle
2122
{
23+
/**
24+
* @var string[] List of services provider to register
25+
*/
26+
protected $servicesproviders = [
27+
LocaleServicesProvider::class,
28+
];
2229
}

app/sprinkles/account/src/Account/Registration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
namespace UserFrosting\Sprinkle\Account\Account;
1212

1313
use Illuminate\Database\Capsule\Manager as Capsule;
14-
use Interop\Container\ContainerInterface;
14+
use Psr\Container\ContainerInterface;
1515
use UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface;
1616
use UserFrosting\Sprinkle\Account\Facades\Password;
1717
use UserFrosting\Sprinkle\Core\Mail\EmailRecipient;

app/sprinkles/account/src/Authenticate/Authenticator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ public function __construct(ClassMapper $classMapper, Session $session, Config $
118118
$this->rememberMe->getCookie()->setPath($this->config['remember_me.session.path']);
119119

120120
// Set expire time, if specified
121-
if ($this->config->has('remember_me.expire_time') && $this->config->has('remember_me.expire_time') != null) {
121+
if ($this->config->has('remember_me.expire_time') && $this->config->get('remember_me.expire_time') !== null) {
122122
$this->rememberMe->getCookie()->setExpireTime($this->config['remember_me.expire_time']);
123123
}
124124

app/sprinkles/account/src/Authorize/AuthorizationManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace UserFrosting\Sprinkle\Account\Authorize;
1212

13-
use Interop\Container\ContainerInterface;
13+
use Psr\Container\ContainerInterface;
1414
use UserFrosting\Sprinkle\Account\Database\Models\Interfaces\UserInterface;
1515

1616
/**

app/sprinkles/account/src/Controller/AccountController.php

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ class AccountController extends SimpleController
5858
*/
5959
public function checkUsername(Request $request, Response $response, $args)
6060
{
61-
/** @var \UserFrosting\Sprinkle\Core\Alert\AlertStream $ms */
62-
$ms = $this->ci->alerts;
63-
6461
// GET parameters
6562
$params = $request->getQueryParams();
6663

@@ -97,7 +94,7 @@ public function checkUsername(Request $request, Response $response, $args)
9794
/** @var \UserFrosting\Sprinkle\Core\Util\ClassMapper $classMapper */
9895
$classMapper = $this->ci->classMapper;
9996

100-
/** @var \UserFrosting\I18n\MessageTranslator $translator */
97+
/** @var \UserFrosting\I18n\Translator $translator */
10198
$translator = $this->ci->translator;
10299

103100
// Log throttleable event
@@ -500,9 +497,6 @@ public function pageRegister(Request $request, Response $response, $args)
500497
/** @var \UserFrosting\Support\Repository\Repository $config */
501498
$config = $this->ci->config;
502499

503-
/** @var \UserFrosting\I18n\LocalePathBuilder */
504-
$localePathBuilder = $this->ci->localePathBuilder;
505-
506500
if (!$config['site.registration.enabled']) {
507501
throw new NotFoundException();
508502
}
@@ -526,14 +520,17 @@ public function pageRegister(Request $request, Response $response, $args)
526520
$validatorRegister = new JqueryValidationAdapter($schema, $this->ci->translator);
527521

528522
// Get locale information
529-
$currentLocales = $localePathBuilder->getLocales();
523+
$currentLocale = $this->ci->translator->getLocale()->getIdentifier();
524+
525+
// Get a list of all locales
526+
$locales = $this->ci->locale->getAvailableOptions();
530527

531528
// Hide the locale field if there is only 1 locale available
532529
$fields = [
533530
'hidden' => [],
534531
'disabled' => [],
535532
];
536-
if (count($config->getDefined('site.locales.available')) <= 1) {
533+
if (count($locales) <= 1) {
537534
$fields['hidden'][] = 'locale';
538535
}
539536

@@ -545,8 +542,8 @@ public function pageRegister(Request $request, Response $response, $args)
545542
],
546543
'fields' => $fields,
547544
'locales' => [
548-
'available' => $config['site.locales.available'],
549-
'current' => end($currentLocales),
545+
'available' => $locales,
546+
'current' => $currentLocale,
550547
],
551548
]);
552549
}
@@ -708,14 +705,14 @@ public function pageSettings(Request $request, Response $response, $args)
708705
$validatorProfileSettings = new JqueryValidationAdapter($schema, $this->ci->translator);
709706

710707
// Get a list of all locales
711-
$locales = $config->getDefined('site.locales.available');
708+
$locales = $this->ci->locale->getAvailableOptions();
712709

713710
// Hide the locale field if there is only 1 locale available
714711
$fields = [
715712
'hidden' => [],
716713
'disabled' => [],
717714
];
718-
if (count($config->getDefined('site.locales.available')) <= 1) {
715+
if (count($locales) <= 1) {
719716
$fields['hidden'][] = 'locale';
720717
}
721718

@@ -830,8 +827,11 @@ public function profile(Request $request, Response $response, $args)
830827

831828
$error = false;
832829

830+
// Get locales
831+
$locales = $this->ci->locale->getAvailableIdentifiers();
832+
833833
// Ensure that in the case of using a single locale, that the locale is set
834-
if (count($config->getDefined('site.locales.available')) <= 1) {
834+
if (count($locales) <= 1) {
835835
$data['locale'] = $currentUser->locale;
836836
}
837837

@@ -843,8 +843,7 @@ public function profile(Request $request, Response $response, $args)
843843
}
844844

845845
// Check that locale is valid
846-
$locales = $config->getDefined('site.locales.available');
847-
if (isset($data['locale']) && !array_key_exists($data['locale'], $locales)) {
846+
if (isset($data['locale']) && !in_array($data['locale'], $locales)) {
848847
$ms->addMessageTranslated('danger', 'LOCALE.INVALID', $data);
849848
$error = true;
850849
}
@@ -953,7 +952,7 @@ public function register(Request $request, Response $response, $args)
953952
$error = false;
954953

955954
// Ensure that in the case of using a single locale, that the locale is set
956-
if (count($config->getDefined('site.locales.available')) <= 1) {
955+
if (count($this->ci->locale->getAvailableIdentifiers()) <= 1) {
957956
$data['locale'] = $config['site.registration.user_defaults.locale'];
958957
}
959958

@@ -1252,7 +1251,7 @@ public function settings(Request $request, Response $response, $args)
12521251
$error = false;
12531252

12541253
// Ensure that in the case of using a single locale, that the locale is set
1255-
if (count($config->getDefined('site.locales.available')) <= 1) {
1254+
if (count($this->ci->locale->getAvailableIdentifiers()) <= 1) {
12561255
$data['locale'] = $currentUser->locale;
12571256
}
12581257

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?php
2+
3+
/*
4+
* UserFrosting (http://www.userfrosting.com)
5+
*
6+
* @link https://github.com/userfrosting/UserFrosting
7+
* @copyright Copyright (c) 2019 Alexander Weissman
8+
* @license https://github.com/userfrosting/UserFrosting/blob/master/LICENSE.md (MIT License)
9+
*/
10+
11+
namespace UserFrosting\Sprinkle\Account\I18n;
12+
13+
use UserFrosting\Sprinkle\Core\ServicesProvider\BaseServicesProvider;
14+
15+
/**
16+
* Locale service provider, replacing the Core one.
17+
*
18+
* Registers:
19+
* - locale : \UserFrosting\Sprinkle\Account\I18n\SiteLocale
20+
*/
21+
class LocaleServicesProvider extends BaseServicesProvider
22+
{
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function register(): void
27+
{
28+
$this->ci['locale'] = new SiteLocale($this->ci);
29+
}
30+
}

0 commit comments

Comments
 (0)