Skip to content

Comments

Add data providers and data persisters matches to the debug panel#2262

Merged
dunglas merged 7 commits intoapi-platform:masterfrom
antograssiot:data-collectors
Nov 1, 2018
Merged

Add data providers and data persisters matches to the debug panel#2262
dunglas merged 7 commits intoapi-platform:masterfrom
antograssiot:data-collectors

Conversation

@antograssiot
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets
License MIT
Doc PR

Even if I do like the data providers system, I generally find hard to debug them and end in dumping in vendor chain data providers.

This PR aims to provide a more developer friendly way to debug them by improving the Api Platform panel in Symfony debug toolbar
debugbar

Up to now I've implemented item/collection/subresources data provider and data persister
If you like the idea, I'll add tests before merging this.

@antograssiot
Copy link
Contributor Author

Add tabs to ease navigation and here is a screenshot, easier to see than the gif

capture d ecran 2018-10-20 a 21 50 54

@antograssiot antograssiot force-pushed the data-collectors branch 4 times, most recently from 71f5437 to 5bbeb47 Compare October 21, 2018 10:38
@dunglas
Copy link
Member

dunglas commented Oct 21, 2018

Very good idea!

/**
* @author Anthony GRASSIOT <antograssiot@free.fr>
*/
class TraceableChainDataPersister implements DataPersisterInterface
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class TraceableChainDataPersister implements DataPersisterInterface
final class TraceableChainDataPersister implements DataPersisterInterface

{
if ($dataPersister instanceof ChainDataPersister) {
$this->decorated = $dataPersister;
$reflection = new \ReflectionProperty(ChainDataPersister::class, 'persisters');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe can you make this parameter public and marked @internal?

public function __construct(CollectionDataProviderInterface $collectionDataProvider)
{
if ($collectionDataProvider instanceof ChainCollectionDataProvider) {
$reflection = new \ReflectionProperty(ChainCollectionDataProvider::class, 'dataProviders');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

public function __construct(SubresourceDataProviderInterface $subresourceDataProvider)
{
if ($subresourceDataProvider instanceof ChainSubresourceDataProvider) {
$reflection = new \ReflectionProperty(ChainSubresourceDataProvider::class, 'dataProviders');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

@@ -0,0 +1,21 @@
<?xml version="1.0" ?>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can me merged with the previous file isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to activate those listener only if the api platform profiler is enable and debug is on but I can simplify and remove extra files if you prefer, let me know.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it finaly 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it finally 👍. I updated the file and added test on the extension. just waiting for github hangover to be finished

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it finally 👍. I updated the file and added test on the extension. just waiting for github hangover to be finished

@antograssiot
Copy link
Contributor Author

antograssiot commented Oct 21, 2018

I've updated following your comments @dunglas, except the "extra" loops and the separates files waiting for more comments after my answers. thanks for your review

@antograssiot antograssiot force-pushed the data-collectors branch 4 times, most recently from b4871f2 to 3000eda Compare October 22, 2018 15:08
@antograssiot
Copy link
Contributor Author

everything has been updated here, just waiting for github webhooks to be back on the scene I guess now

@antograssiot
Copy link
Contributor Author

branched rebased.
A generic way to trace Extension would be great too I think, maybe something like a WrappedExtension class that would decorate every extension so we could check if they where call (in custom data providers too). Then all wrapped extension would be collected and displayed in a new tab. WDYT ?

@dunglas dunglas merged commit d5c9d0b into api-platform:master Nov 1, 2018
@dunglas
Copy link
Member

dunglas commented Nov 1, 2018

Thank you very much @antograssiot, very nice improvement

@antograssiot antograssiot deleted the data-collectors branch November 2, 2018 13:21
cr3a7ure added a commit to cr3a7ure/core that referenced this pull request Nov 5, 2018
* ApiPlatformExtension cleanup

* Remove a now useless composer hack

* remove unset attributes key in normalization context

* Add tests on doctrine collection purge

* Fix 2285 - force Yaml::dump to dump empty array as actual empty array

* improve graphiql CSS

* Prefix root resource route_prefix to sub-resources

Unit test also added

* Bump PHPStan analysis to level 6 (api-platform#2272)

* Bump PHPStan analysis to level 6

* Bump PHPStan analysis to level 6

* Bump PHPStan analysis to level 6

* Deprecate dead code in QueryJoinParser and remove internal usage

* Add a non regression test for api-platform#2285 api-platform#2286

* Ability to modify response headers (mainly cache related headers) (api-platform#2288)

* Allow user-defined cache headers

A user may wish to define response cache headers in a custom controller or per resource. E.g. a /entity/random endpoint should have a max-age of 0

* Override cache max-age and shared-max-age

Add annotation attributes for cache_headers which allows max_age and shared_max_age to be assigned per resource.

* Remove unused property

The property was added when I thought it may be good to have the option outside of 'attributes' - decided to put the option in attributes instead and failed to remove this property.

* Code style fixes

* Test code style fix

* Review changes applied

- Order of constructor arguments + default null value
- Remove 'throws' annotation
- setting $resourceCacheHeaders with default fallback to empty array
- Improved conditional statements

* Add cacheHeaders Attribute annotation

* Accidental typo

* Alphabetical order

Updated attribute annotation to alphabetical order - moved the property into alphabetical order as well

* Add data providers and data persisters matches to the debug panel (api-platform#2262)

* Add data providers and data persisters matches to the debug panel

* Add tests on traceable providers and persisters

* Use internal public properties

* Merge config file and add tests on Extension

* Avoid extra loop in data persister/providers

* remove duplicated code

* Fix after rebasing

* Allow an input and an output for a given resource class

* [Bugfix] Remove type Error
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.

2 participants