Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve hooks and allow to delete/check specific priority #133

Merged
merged 3 commits into from
Mar 21, 2020
Merged

Improve hooks and allow to delete/check specific priority #133

merged 3 commits into from
Mar 21, 2020

Conversation

mvorisek
Copy link
Member

@mvorisek mvorisek commented Mar 13, 2020

Fixes #131

@mvorisek
Copy link
Member Author

Fix composer/tests first, see #134

@PhilippGrashoff
Copy link

Well, this solution is perfectly backwards compatible and easy, but also not perfectly save to use :) There could be more than one hook with the same priority set, and so one could accidently delete more hooks than intended. But this chance is definitely low when passing a custom priority to a hook. To me, this is good enough...

@codecov
Copy link

codecov bot commented Mar 14, 2020

Codecov Report

Merging #133 into develop will decrease coverage by 2.07%.
The diff coverage is 68.88%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop     #133      +/-   ##
=============================================
- Coverage      99.08%   97.00%   -2.08%     
- Complexity       420      442      +22     
=============================================
  Files             24       24              
  Lines            983     1035      +52     
=============================================
+ Hits             974     1004      +30     
- Misses             9       31      +22     
Impacted Files Coverage Δ Complexity Δ
src/HookTrait.php 78.57% <68.18%> (-15.66%) 30.00 <29.00> (+7.00) ⬇️
src/DynamicMethodTrait.php 100.00% <100.00%> (ø) 33.00 <0.00> (ø)
src/StaticAddToTrait.php 75.00% <0.00%> (-25.00%) 17.00% <0.00%> (+15.00%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 42bdb7a...2b6fd15. Read the comment docs.

@mvorisek
Copy link
Member Author

mvorisek commented Mar 14, 2020

I analysed this more deeply and returning an index under which the hook was saved seems to be the best solutions for later manipulation. This and only this concept prevents collisions.

PR ready to be merged.

Feel free to add more tests if desired.

src/HookTrait.php Outdated Show resolved Hide resolved
@mvorisek mvorisek merged commit 3615739 into atk4:develop Mar 21, 2020
@mvorisek mvorisek deleted the improve_hooks branch March 21, 2020 02:04
DarkSide666 added a commit that referenced this pull request Apr 8, 2020
* Clean up badges in README file (#116)

* improve badges

* cleanup

* wip

* wip

* wip

* Configuration Elements cannot be replaced (#117)

* Apply fixes from StyleCI

* Update composer.json

* Update release-drafter.yml

* Update release-drafter.yml

* Create bundler.yml

* Add POC for "CRUD::addTo($app)" syntax (#123)

* Add POC for "CRUD::addTo($app)" syntax

* Apply fixes from StyleCI

* Add unit tests

* Apply fixes from StyleCI

* remove this weird file

* [REFACTOR] rename addHook to onHook with argument naming consistency (#124)

* rename addHook to onHook with argument naming consistency

* Apply fixes from StyleCI

* rename addHook to onHook with argument naming consistency

* update docs

* hook $this by default (#126)

* assign $this as default value for fx

* update exception info

* update docs

* Move doc builder instructions into Docker (#125)

* Releasing 2.0.1 into master (#122)

* Clean up badges in README file (#116)

* improve badges

* cleanup

* wip

* wip

* wip

* Configuration Elements cannot be replaced (#117)

* Apply fixes from StyleCI

* Update composer.json

* Update release-drafter.yml

* Update release-drafter.yml

* Create bundler.yml

* Setting release dependencies

Co-authored-by: Romans Malinovskis <me@nearly.guru>
Co-authored-by: Georg Marx <bepixeld@users.noreply.github.com>
Co-authored-by: Imants Horsts <DarkSide666@users.noreply.github.com>
Co-authored-by: GitHub Web Flow <noreply@github.com>

* Add POC for "CRUD::addTo($app)" syntax

* Apply fixes from StyleCI

* Add unit tests

* Apply fixes from StyleCI

* remove this weird file

* Add dockerfile for easier doc preview

* Update instructions

* add doc integration instructions for PhpStorm

* Add mention of addTo() into the docs

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Georg Marx <bepixeld@users.noreply.github.com>
Co-authored-by: Imants Horsts <DarkSide666@users.noreply.github.com>
Co-authored-by: GitHub Web Flow <noreply@github.com>

* Rename hook spot argument (#127)

* improve hook arguments versatility

* rename $hookSpot to $spot

* update tests

* update comment

* Apply fixes from StyleCI

* improve hook default argument versatility

* Apply fixes from StyleCI

* Update unit-tests.yml

* Update unit-tests.yml

* Update unit-tests.yml

* avoid code duplication (#128)

* avoid code duplication

* outline logic by using brackets

* setLayout -> initLayout (#130)

* setLayout -> initLayout

* Apply fixes from StyleCI

* style

* Rename HEAD to develop for Composer in unit tests (#135)

* Fix EOL to NL (#132)

* Do not fail-fast PHP test matrix (#136)

* Improve StaticAddToTrait trait (#139)

* Fix initial StaticAddTo trait

* Prevent bad addTo usage

* Improve addTo method

* Fix add_arguments in tests

* Add similar method to addTo for seeds with class name

* Improve readability and prevent even more bad usage

* Fix typo

* Improve StaticAddTo tests and add unsafe method for BC UI impl. (#140)

* Improve StaticAddTo tests

* Add unsafe method of addToWithClassName to skip instanceof check

* Do not wrap exception message in array (#141)

* Add skip_add param to StaticAddToTrait trait methods (#143)

* Require class name in seed for addToWithClassName methods (#144)

* Update release-drafter.yml

* Update release-drafter.yml

* Update StaticAddToTrait.php

* Improve hooks and allow to delete/check specific priority (#133)

* Improve hooks and allow to delete/check specific priority

* Fix tests

* Introduce indexes hooks

* Fix hook doc

* fix compatibility

* Fix bad phpdoc

* Add injection of solutions in Exception constructor (#119)

* Rapid add solutions in constructor

* Apply fixes from StyleCI

* fixes

* Apply fixes from StyleCI

* style fix

Co-authored-by: DarkSide <imants.horsts@inbox.lv>
Co-authored-by: Imants Horsts <DarkSide666@users.noreply.github.com>

* Fix CS - do not import classes without namespace (#147)

* Fix CS - do not import classes without namespace

* Apply fixes from StyleCI

Co-authored-by: Romans Malinovskis <me@nearly.guru>

* Align exception header properly (#148)

* Setting release dependencies

Co-authored-by: Romans Malinovskis <me@nearly.guru>
Co-authored-by: Georg Marx <bepixeld@users.noreply.github.com>
Co-authored-by: Imants Horsts <imants.horsts@inbox.lv>
Co-authored-by: Imants Horsts <DarkSide666@users.noreply.github.com>
Co-authored-by: Georgi Hristov <georgehristov@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: GitHub Web Flow <noreply@github.com>
Co-authored-by: Michael Voříšek <mvorisek@mvorisek.cz>
Co-authored-by: Francesco Danti <fdanti@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multiple hooks for one action can be added, but they have to be currently deleted completely
3 participants