From fe8da978b1383e59214d10ee2dcf81c58ee4029c Mon Sep 17 00:00:00 2001 From: Andrey Kutejko Date: Wed, 20 Mar 2019 00:56:43 +0100 Subject: [PATCH] switch to stable missing-tools --- composer.json | 2 +- composer.lock | 37 ++++++++++++++++++------------------ ipf/admin/component.php | 10 ++++------ ipf/form/field/set.php | 11 +++++++++-- ipf/form/widget/settable.php | 6 +++--- 5 files changed, 36 insertions(+), 30 deletions(-) diff --git a/composer.json b/composer.json index 0d10a2a..f4e7e7d 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ "pear/archive_tar": "1.3.*", "doctrine/dbal": "v2.5.13", "d11wtq/boris": "dev-master", - "andy128k/missing-tools": "0.2.*@dev", + "andy128k/missing-tools": "~0.3", "andy128k/pegp": "0.2", "pimple/pimple": "~3.0", "twig/twig": "~1" diff --git a/composer.lock b/composer.lock index 384c5a3..d13ce29 100644 --- a/composer.lock +++ b/composer.lock @@ -4,22 +4,28 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "73a01ff77b33bdec0cab728b7116b494", + "content-hash": "73647829ab13dadd59aa63d053c0ab49", "packages": [ { "name": "andy128k/missing-tools", - "version": "0.2.x-dev", + "version": "0.3.x-dev", "source": { "type": "git", - "url": "git://git.andy128k.net/missing-tools.git", - "reference": "5d1ceab2d8b79e9b3823d1444dcff03ca3beebec" + "url": "https://github.com/andy128k/missing-tools.git", + "reference": "9ba81e33e389cb80b80ce114fb664506fab1859e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/andy128k/missing-tools/zipball/9ba81e33e389cb80b80ce114fb664506fab1859e", + "reference": "9ba81e33e389cb80b80ce114fb664506fab1859e", + "shasum": "" }, "require": { "andy128k/pegp": "0.2", - "php": ">=5.3" + "php": ">=5.6" }, "require-dev": { - "phpunit/phpunit": "4.4.*" + "phpunit/phpunit": "~5" }, "type": "library", "autoload": { @@ -27,11 +33,7 @@ "src/" ] }, - "scripts": { - "test": [ - "phpunit ./t" - ] - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -42,7 +44,7 @@ } ], "description": "Miscellaneous utilities", - "time": "2019-03-17T13:31:26+00:00" + "time": "2019-03-19T23:50:24+00:00" }, { "name": "andy128k/pegp", @@ -968,12 +970,12 @@ "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "931a8b5cdf99dbe222ca1491e8ce96e674d35882" + "reference": "f0efbc5b20bc5fe13119e97fcf8c9e5e6daf9ad1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/931a8b5cdf99dbe222ca1491e8ce96e674d35882", - "reference": "931a8b5cdf99dbe222ca1491e8ce96e674d35882", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/f0efbc5b20bc5fe13119e97fcf8c9e5e6daf9ad1", + "reference": "f0efbc5b20bc5fe13119e97fcf8c9e5e6daf9ad1", "shasum": "" }, "require": { @@ -1026,7 +1028,7 @@ "keywords": [ "templating" ], - "time": "2019-03-16T10:32:43+00:00" + "time": "2019-03-19T13:07:27+00:00" } ], "packages-dev": [ @@ -2291,8 +2293,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "d11wtq/boris": 20, - "andy128k/missing-tools": 20 + "d11wtq/boris": 20 }, "prefer-stable": false, "prefer-lowest": false, diff --git a/ipf/admin/component.php b/ipf/admin/component.php index 3d949c2..2785abc 100644 --- a/ipf/admin/component.php +++ b/ipf/admin/component.php @@ -1,8 +1,6 @@ getPerms($request)))) return false; - $authPermissions = F::bind('array_map', - F::bind('sprintf', '%s|%s|%s', $this->app->slug(), $this->slug(), P::p()), - P::p()) - ->call($what); + $prefix = $this->app->slug() . '|' . $this->slug() . '|'; + $authPermissions = array_map(function ($action) use ($prefix) { + return $prefix . $action; + }, $what); return $this->auth_app->userCan($request->user, $authPermissions); } diff --git a/ipf/form/field/set.php b/ipf/form/field/set.php index cbd9e7a..b65d923 100644 --- a/ipf/form/field/set.php +++ b/ipf/form/field/set.php @@ -11,7 +11,7 @@ class IPF_Form_Field_Set extends IPF_Form_Field if (!$value) return $value; - $errors = new \PFF\MultidimensionalArray; + $errors = new \PFF\Map(); $newValue = array(); foreach ($value as $index => $row) { @@ -22,7 +22,14 @@ class IPF_Form_Field_Set extends IPF_Form_Field try { $value = $field->clean(\PFF\Arr::get($row, $name)); } catch (IPF_Exception_Form $ex) { - $errors->pushToKey(array($index, $name), $ex->getError()); + $error = $ex->getError(); + $errors->updateOrInsert( + array($index, $name), + function ($arr) use ($error) { + return array_merge($arr, [$error]); + }, + [$error] + ); } $row[$name] = $value; } diff --git a/ipf/form/widget/settable.php b/ipf/form/widget/settable.php index d3a1e25..554f25f 100644 --- a/ipf/form/widget/settable.php +++ b/ipf/form/widget/settable.php @@ -33,7 +33,7 @@ class IPF_Form_Widget_SetTable extends IPF_Form_Widget public function render($name, $value, $extra_attrs=array()) { - $errors = new \PFF\MultidimensionalArray; + $errors = new \PFF\Map; foreach (\PFF\Arr::pop($extra_attrs, 'errors', array()) as $e) $errors = $e->meta; // TODO: merge @@ -64,11 +64,11 @@ class IPF_Form_Widget_SetTable extends IPF_Form_Widget return $table->html(); } - protected function renderRow($prefix, $obj, $errors, $index) + protected function renderRow($prefix, $obj, \PFF\Map $errors, $index) { $tr = Tag::tr(); foreach ($this->widgets as $w) { - $cellErrors = $errors->get($index, $w['name']); + $cellErrors = $errors->get([$index, $w['name']]); $e = IPF_Form::renderErrorsAsHTML($cellErrors); $val = \PFF\Arr::get($obj, $w['name']); -- 2.49.0