- Discussions
- 4 644
- Messages
- 12 049
- Solutions
- 81
- J'aime
- 7 606
- Points
- 198
A library that contains helper functions for our add-ons
1. Introduction
During use, Add the requires section to addon.json to document the dependancy :
2. Template additions
We are adding various functions for templates that will make it easier for you to work with them, as well as add several useful functions.
Template Function:
Get the difference time in a human readable format in the current locale
Template Function:
After defining a translation phrase that has pluralization options, you may use the
3. Options
4. Traits. New in 2.2.3
Callables passed to the macro function will be bound to the
5. Collections. New in 2.2.3
The
Collections are "macroable", which allows you to add additional methods to the Collection class at run time. The
6. Conclusion
At this point I should acknowledge the work of Taylor Otwell and other contributors to the Laravel PHP Framework - the [MMO] Core Lib was heavily inspired by the framework developed for Laravel and some of the reflection classes are taken directly from the
Télécharger V2.2.0 :
Version 2.2.1 :
Small refactor
Add helper functions for String and Array
Télécharger V2.2.1 :
Version 2.2.2 change :
Add Pluralization phrases. In the future, it is planned to support conditions in phrases.
Added the ability to create the following options:
multiple select usergroups
custom fields: contact, preferences and personal
multiple select user upgrade
Télécharger V2.2.2 :
Version 2.2.3 change :
Min php ver 7.3
Provides a trait, when applied to a class, makes it possible to add methods to that class at runtime
Add support for plural phrases
The message supports two different types of pluralization rules:
Use global namespace
Version 2.2.4 change :
- Add helper for html
- Add helper Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
- Add helper for Determine if a given string starts with a given substring
- Sort collections by key when given a string even when key is callable
- Add Uncountable word forms
- Adds a few PHP 8.1 related changes
Télécharger V2.24 :
Version 2.2.5 : Add Masks a portion of a string with a repeated character.
Télécharger V2.2.5 :
Version 2.2.7 :
- Fix incorrect id in user upgrade option
- Add new payment profile option
Télécharger V2.2.7 :
1. Introduction
During use, Add the requires section to addon.json to document the dependancy :
JSON:
{
"require": {
"MMO/CoreLib": [
2020270,
"[MMO] Core Library v2.2.2+"
]
}
}
2. Template additions
We are adding various functions for templates that will make it easier for you to work with them, as well as add several useful functions.
Template Function:
mcl_diff_for_human
Get the difference time in a human readable format in the current locale
Template Function:
mcl_phrase_plural
After defining a translation phrase that has pluralization options, you may use the
mcl_phrase_plural
function to retrieve the phrase for a given "count".3. Options
MMO\CoreLib\Option\UserGroup
- Displays a list of user groups with the ability to select a checkbox type.MMO\CoreLib\Option\UserUpgrade
- Displays a list of promotions of user groups with the ability to select the type of checkboxMMO\CoreLib\Option\CustomFields\Contact
- Displays additional user fields of type contactsMMO\CoreLib\Option\CustomFields\Personal
- Displays additional user fields of type personalsMMO\CoreLib\Option\CustomFields\Prefefernces
- Displays additional user fields of type preferences4. Traits. New in 2.2.3
Macroable
- A trait to dynamically add methods to a class.
PHP:
$macroableClass = new class() {
use Illuminate\Support\Traits\Macroable;
};
$macroableClass::macro('concatenate', function(... $strings) {
return implode('-', $strings);
};
$macroableClass->concatenate('one', 'two', 'three'); // returns 'one-two-three'
Callables passed to the macro function will be bound to the
class
PHP:
$macroableClass = new class() {
protected $name = 'myName';
use Illuminate\Support\Traits\Macroable;
};
$macroableClass::macro('getName', function() {
return $this->name;
};
$macroableClass->getName(); // returns 'myName'
5. Collections. New in 2.2.3
The
MMO\CoreLib\Util\Collection
class provides a fluent, convenient wrapper for working with arrays of data. The collect helper returns a new MMO\CoreLib\Util\Collection
instance for the given array. So, creating a collection is as simple as:
PHP:
$collection = collect([1, 2, 3]);
Collections are "macroable", which allows you to add additional methods to the Collection class at run time. The
MMO\CoreLib\Util\Collection
class' macro method accepts a closure that will be executed when your macro is called. The macro closure may access the collection's other methods via $this, just as if it were a real method of the collection class.6. Conclusion
At this point I should acknowledge the work of Taylor Otwell and other contributors to the Laravel PHP Framework - the [MMO] Core Lib was heavily inspired by the framework developed for Laravel and some of the reflection classes are taken directly from the
Illuminate\Support
component. The library also uses some separate libraries from the framework. And it is worth praising for the tighten collections outside of laravelTélécharger V2.2.0 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Small refactor
Add helper functions for String and Array
Télécharger V2.2.1 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Add Pluralization phrases. In the future, it is planned to support conditions in phrases.
Added the ability to create the following options:
multiple select usergroups
custom fields: contact, preferences and personal
multiple select user upgrade
Télécharger V2.2.2 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Min php ver 7.3
Provides a trait, when applied to a class, makes it possible to add methods to that class at runtime
Add support for plural phrases
The message supports two different types of pluralization rules:
- interval
- indexed
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Version 2.2.4 change :
- Add helper for html
- Add helper Get the first item in the collection, but only if exactly one item exists. Otherwise, throw an exception.
- Add helper for Determine if a given string starts with a given substring
- Sort collections by key when given a string even when key is callable
- Add Uncountable word forms
- Adds a few PHP 8.1 related changes
Télécharger V2.24 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
Télécharger V2.2.5 :
Vous devez répondre avant de pouvoir voir le contenu des données cachées.
- Fix incorrect id in user upgrade option
- Add new payment profile option
Télécharger V2.2.7 :
Pour voir ce contenu caché, votre nombre de messages doit être supérieur ou égal à 10.