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

Error when registering transformer #27

Closed
agentphoenix opened this issue May 5, 2014 · 12 comments
Closed

Error when registering transformer #27

agentphoenix opened this issue May 5, 2014 · 12 comments

Comments

@agentphoenix
Copy link
Contributor

I'm trying to get transformers working and I keep getting an error exception that the delimiter is empty. I've tracked this down to the registration of the transformer in the service provider and when I dump the $app['config']['api::embeds'] I get an empty array instead of what's in the config file. (I did a fresh config:publish just to be sure.) Any reason why the service provider wouldn't be able to grab those config values?

@jasonlewis
Copy link
Contributor

Running the latest version?

@agentphoenix
Copy link
Contributor Author

Yep, just did a composer update last night. My lock file says 0.2.4.

@jasonlewis
Copy link
Contributor

Can you paste the full exception stack trace please.

@agentphoenix
Copy link
Contributor Author

[2014-05-05 11:27:26] local.ERROR: exception 'ErrorException' with message 'explode(): Empty delimiter' in C:\ampps\www\bjga\scheduler\vendor\dingo\api\src\Transformer.php:228
Stack trace:
#0 [internal function]: Illuminate\Exception\Handler->handleError(2, 'explode(): Empt...', 'C:\ampps\www\bj...', 228, Array)
#1 C:\ampps\www\bjga\scheduler\vendor\dingo\api\src\Transformer.php(228): explode('', '')
#2 C:\ampps\www\bjga\scheduler\vendor\dingo\api\src\Transformer.php(96): Dingo\Api\Transformer->setRequestedScopes()
#3 C:\ampps\www\bjga\scheduler\vendor\dingo\api\src\Http\Response.php(50): Dingo\Api\Transformer->transformResponse(Object(Scheduler\Models\Eloquent\ServiceModel))
#4 C:\ampps\www\bjga\scheduler\vendor\dingo\api\src\Routing\Router.php(166): Dingo\Api\Http\Response->morph('json')
#5 C:\ampps\www\bjga\scheduler\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(738): Dingo\Api\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#6 C:\ampps\www\bjga\scheduler\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(708): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#7 C:\ampps\www\bjga\scheduler\vendor\dingo\api\src\Http\Middleware\RateLimit.php(96): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#8 C:\ampps\www\bjga\scheduler\vendor\dingo\api\src\Http\Middleware\Authentication.php(102): Dingo\Api\Http\Middleware\RateLimit->handle(Object(Illuminate\Http\Request), 1, true)
#9 C:\ampps\www\bjga\scheduler\vendor\laravel\framework\src\Illuminate\Http\FrameGuard.php(38): Dingo\Api\Http\Middleware\Authentication->handle(Object(Illuminate\Http\Request), 1, true)
#10 C:\ampps\www\bjga\scheduler\vendor\laravel\framework\src\Illuminate\Session\Middleware.php(72): Illuminate\Http\FrameGuard->handle(Object(Illuminate\Http\Request), 1, true)
#11 C:\ampps\www\bjga\scheduler\vendor\laravel\framework\src\Illuminate\Cookie\Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#12 C:\ampps\www\bjga\scheduler\vendor\laravel\framework\src\Illuminate\Cookie\Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#13 C:\ampps\www\bjga\scheduler\vendor\stack\builder\src\Stack\StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#14 C:\ampps\www\bjga\scheduler\vendor\laravel\framework\src\Illuminate\Foundation\Application.php(606): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#15 C:\ampps\www\bjga\scheduler\public\index.php(49): Illuminate\Foundation\Application->run()
#16 {main} [] []

@jasonlewis
Copy link
Contributor

Having a hard time reproducing this. Only thing I can think of is it being on Windows as I've not tested it at all in a Windows environment. Can you try dumping out other configuration items and see if they're loaded correctly?

@agentphoenix
Copy link
Contributor Author

I just tried to dump the version number out of the config file in the service provider's boot and register methods.

In boot, I get the v1 string out of the config file like expected.

In register, I get an empty array.

For whatever reason, the API config file doesn't seem to be available in register. Not sure what about Windows would be causing that issue though as it's a pretty straightforward operation.

@jasonlewis
Copy link
Contributor

No it shouldn't be possible to call it inside register, but it's safe to do so inside a binding as they shouldn't be called until the application has booted.

Okay so this doesn't produce anything for you?

$this->app['dingo.api.transformer'] = $this->app->share(function($app)
{
    dd($app['config']['api::embeds']);
    return new Transformer(new Fractal, $app, $app['config']['api::embeds.key'], $app['config']['api::embeds.separator']);
});

Dumping other config keys there produce anything?

@agentphoenix
Copy link
Contributor Author

Nothing, just an empty array no matter which of the values I try to dump.

@jasonlewis
Copy link
Contributor

But you can dump the exact same thing (api::embeds) in the boot method with no worries at all?

@agentphoenix
Copy link
Contributor Author

In boot, I can dump api::embeds and get an array (or any of the other items in the API config file), but when I try to dump api::embeds.key it comes back NULL. The only way for me to get the key directly is ['config']['api::embeds']['key'].

Strangely enough, grabbing other nested array items doesn't have the same issue (like rate_limiting.exceeded).

@jasonlewis
Copy link
Contributor

I've had a go at this on Windows and am still unable to reproduce. Sorry, not much more I can do here I don't think.

@agentphoenix
Copy link
Contributor Author

No biggie. I'll have to keep digging through things and see if I can figure it out. Thanks for your help!

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

No branches or pull requests

2 participants