Symfony: ServiceNotFoundException - php

when I call the service i made OutsourcingLogService i get this error
You have requested a non-existent service "MyApp\BackendBundle\Service\OutsourcingLogService". Did you mean one of these:
However in my controller i imported this classes and if I Ctrl + Click it takes me to the service class, but when i call the service, this exception appears.
enter image description here
enter image description here If somenone had the same error, or have any idea of why is this happening, please let me know how can I fix this.
Im trying to make a log service, that store when I Create, Update, Delete a registry.

Related

Symfony 4 - Endpoint for uploaded files

I've developped an simple FileUploader Service based on the Symfony documentation found here: https://symfony.com/doc/current/controller/upload_file.html
My app is just a simple API called inside a Ionic Mobile App.
What I want to know is what is the best practices to give access to my uploaded images.
For exemple, I have an Sport entity App\Entity\Sport that stores an image:
When i request GET /api/sports/ I want to send as response the full url to the image so it can be displayed inside the mobile app (e.g. http://symfony/api/public/uploads/sports/XXXXX.jpg)
Maybe I'm overcomplicating the issue but do I need to make an GET /public/uploads/sports/{id} as an endpoint to get my pictures ? because if possible i would like to have the pictures instantly available after the GET /api/sports and not having to query another time for the picture aswell
Why not just simply add the URL into a field of the JSON response object, where you can access the the picture directly? IMHO there is nothing wrong with that.
I find https://github.com/WhiteHouse/api-standards a good reference to start with if it comes to these kind of decisions.

Google calendar has an event that is stuck and cannot be deleted

I have been using the Google Calendar API with PHP to create events and I got the following error after trying to create an event:
Error calling POST
https://www.googleapis.com/calendar/v3/calendars/mycalendar_nrfo11fd4vi2a83ir85b8b2rp0%40group.calendar.google.com/events:
(409) The requested identifier already exists.
I then searched in Google Calendar to see if the event exists and it showed this result:
I can't seem to do anything with this event, I can't find any option to delete it. Anyone know how I can get rid of this?
Go to calendar.google.com and sign-in with your account. Upon right-clicking the event, there should be an option to either DELETE or REMOVE the event.

LinkedIn Companies endpoint error

I'm using the LinkedIn api and would like to access companies but I'm running into a vague error that I haven't been able to figure out.
I'm using php and the php libracy 'Happyr\LinkedIn\LinkedIn' to access the API. My current application also has the 'rw_company_admin' permission attached to it.
When I make a call to the api endpoint '/v1/people/~:(id,first-name,last-name)', I get the correct response.
But when I make a call to the '/v1/companies?format=json&is-company-admin=true' endpoint I get the following error:
"Invalid company query request"
When I perform the exact same query in the LinkedIn Rest Console, I get the response I'm looking for. Any ideas?
Figured it out after hours of debugging.
The issue will probably be specific to the php package mentioned in the question. The LinkedIn library in use was automatically appending 'format=json' to the query call which sparked an error.
By removing the default output setting in the library, the call worked fine.
In my case, it was related to permissions of the application.
If you want to retrieve company list of the user, you should check rw_company_admin permission in the settings page of the application or give it to scope parameter. Then, you should get a new access token and make requests with it.

Moodle: get user picture from webservice

By using Moodle Web Service (REST) call core_user_get_users_by_field I successfully get my user details. One of the returned fields is profileimageurl that links to my user profile picture and look like this:
http://my_moodle_server/pluginfile.php/89/user/icon/f1
Unfortunately that link works only in a browser where I have already logged in, otherwise it will redirect to a standard user icon (the grey anonymous face).
So in order to get the actual picture form a client app that is using moodle web services I think I have to call core_files_get_files and pass correct values. So I tried to remap that link to calls paramenters like this:
contextid: 89
component: "user"
filearea: "icon"
itemid: 0
filepath: "/"
filename: "f1.png" (also tryed without .png)
and of course my valid token
but all I get is:
{"parents":[],"files":[]}
Parameters seem to be formally correct (otherwise I would get an exception) however I only get empty response which tells me that some values are not correct.
Ok I found the solution to my problem. I'm posting the answer here also because there's not much information about Moodle web service around...
First of all, core_files_get_files is not the way... it will only show files information, it won't give you the actual file contents (binary).
Fortunately, there's an equivalent URL to be used when calling from external client app:
http://my_moodle_server/webservice/pluginfile.php
It accepts the same parameters/format as http://my_moodle_server/pluginfile.php and in addition you can also pass your token for web service authentication.
So profileimageurl field returned by core_user_get_users_by_field which looks like this:
http://my_moodle_server/pluginfile.php/89/user/icon/f1
can be turned into
http://my_moodle_server/webservice/pluginfile.php/89/user/icon/f1?token=my_web_service_token
Also note that appending ?token= parameter is required

zendframework2 avoid or improve error router no match logs

on my logs on data/log/....log
I found many:
[17-Nov-2014 10:22:24] Dispatch ERROR: error-router-no-match
[17-Nov-2014 10:22:24] Dispatch ERROR: error-router-no-match
[17-Nov-2014 10:23:01] Dispatch ERROR: error-controller-not-found
[17-Nov-2014 10:23:01] Dispatch ERROR: error-controller-not-found
I wish i can either get rid of them or show more info from where these hits or to where these hits are being made so i can correct things.
How this works and is there a established way to do this and how?
Thanks
Probably, these logs are generated by some sort of Bootstrap code (maybe in module/Application/Module.php or any other appropriate place). You need to find that code and add more information to the logging service.

Categories