Skip to content

Releases: tunecino/yii2-nested-rest

Add support to non numeric IDs like strings or uuid

23 Aug 16:14
729c52a
Compare
Choose a tag to compare

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

23 Aug 16:03
5009397
Compare
Choose a tag to compare
  • [Bug] Remove deprecated each() #12 (Thanks to @kl4ver)

Fixed 2 bugs & added singular form for relations.

01 Jun 00:17
Compare
Choose a tag to compare
  • [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 of yii\db\QueryTrait::where())

Added PHP 7.2 support

02 Jun 00:45
Compare
Choose a tag to compare

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

22 Jun 20:54
Compare
Choose a tag to compare

0.2.0

16 Apr 18:28
Compare
Choose a tag to compare

Added more configuration options to the $relation property.
Now there are 3 different ways to declare a relation:

'relations' => ['relation'],
'relations' => ['relation' => 'controller'],
'relations' => ['relation' => ['url' => controller']],

0.1.1

11 Apr 18:51
Compare
Choose a tag to compare

Fixed wrong class name