Releases: tunecino/yii2-nested-rest
Add support to non numeric IDs like strings or uuid
This change Introduces a new variable $linkAttributePattern to allow changing the default RegEX parsing the main resource id from url.
/**
* @var string The Regular Expressions Syntax used to parse the id of the main resource from url.
* For example, in the following final rule, $linkAttributePattern is default to that `\d+` to parse $brand_id value:
*
* GET,HEAD v1/brands/<brand_id:\d+>/items/<IDs:\d[\d,]*>
*
* While that works fine with digital IDs, in a system using a different format, like uuid for example,
* you may use $linkAttributePattern to define different patterns. Something like this maybe:
*
* [
* // Nested Rules Brand
* 'class' => 'tunecino\nestedrest\UrlRule',
* 'modelClass' => 'app\modules\v1\models\Brand',
* 'modulePrefix' => 'v1',
* 'resourceName' => 'v1/brands',
* 'relations' => ['items'],
* 'tokens' => [
* '{id}' => '<id:[a-f0-9]{8}\\-[a-f0-9]{4}\\-4[a-f0-9]{3}\\-(8|9|a|b)[a-f0-9]{3}\\-[a-f0-9]{12}>',
* '{IDs}' => '<IDs:([a-f0-9]{8}\\-[a-f0-9]{4}\\-4[a-f0-9]{3}\\-(8|9|a|b)[a-f0-9]{3}\\-[a-f0-9]{12}(?:,|$))*>',
* ],
* 'linkAttributePattern' => '[a-f0-9]{8}\\-[a-f0-9]{4}\\-4[a-f0-9]{3}\\-(8|9|a|b)[a-f0-9]{3}\\-[a-f0-9]{12}',
* ],
*/
public $linkAttributePattern = '\d+';
Removed the DEPRECATED each function in PHP 7.2.0
Fixed 2 bugs & added singular form for relations.
-
[Enh] Allow config to specify plural or singular form for relations #11 (Thanks to @darrylkuhn)
-
[Bug] Fixes a bug related to array count on object #10 (Thanks to @rvkulikov)
-
[Bug][Possible BC !!] Fixed a bug where user's filters are overridden by the extension when set within relation method (now it uses
yii\db\QueryTrait::andWhere()
instead ofyii\db\QueryTrait::where()
)
Added PHP 7.2 support
Starting from v0.3.0 the library should work fine under PHP 7.2. Now it uses yii\base\BaseObject
instead of the deprecated yii\base\Object
. That also means that starting from this version, v2.0.13 of the Yii2 Framework is required as a minimal release. For prior versions of the framework, v0.2.1 should be used instead.
Fixed issue forcing createUrl() to throw exception when rulesFactory is null
0.2.1 fixed calling createUrl() on null