I have a working API platform endpoint, which supports POST, PATCH & GET. Just for an example, it's a book endpoint:
/api/books
Now, I have a new task of creating a Symfony command, which will have a part where I'll be creating a new Book object and will save it in the database.
I am into the direction of creating a new Service class to normalize the data to Book object, then using EntityManager to persist the data to DB, but since I have a working POST endpoint in API Platform that basically does the same thing, is it possible for me to call that endpoint instead from the Symfony command that I'll be creating?
Related
I am trying to create an application with mikro-orm and apollo-server-express, I want to use the batch processing and the caching of the Facebook dataloader.
Normally, Facebook dataloader instances are creates per request. If mikro-orm also creates custom repository instances per request and if all calls to EntityManager.getRepository() in the same request gets the same instance, it may be the perfect place to create the dataloader instances.
Repositories are created as singletons, so only one instance exists per EntityManager instance. You should fork this EM to have one instance per request, either manually, or via RequestContext middleware:
https://b4nan.github.io/mikro-orm/identity-map/
This way, each request will have its own EntityManager, that will have its own cache of repository instances.
Keep in mind that if you use RequestContext, you should get the request specific EntityManager from it, and get the repository from there:
// beware that this will return null if the context is not yet started
const em = RequestContext.getEntityManager();
// gets request specific repository instance
const repo = em.getRepository(Book);
In cloudera is there a way to update list of configurations at a time using CM-API or CURL?
Currently I am updating one by one one using below CM API.
services_api_instance.update_service_config()
How can we update all configurations stored in json/config file at a time.
The CM API endpoint you're looking for is PUT /cm/deployment. From the CM API documentation:
Apply the supplied deployment description to the system. This will create the clusters, services, hosts and other objects specified in the argument. This call does not allow for any merge conflicts. If an entity already exists in the system, this call will fail. You can request, however, that all entities in the system are deleted before instantiating the new ones.
This basically allows you to configure all your services with one call rather than doing them one at a time.
If you are using services that require a database (Hive, Hue, Oozie ...) then make sure you set them up before you call the API. It expects all the parameters you pass in to work so external dependencies must be resolved first.
I'm trying to find documentation for retrieving translated records via translatable (StofDoctrineExtensionsBundle) when executing a console command from Symfony. This command call a service that retrieves data from Doctrine using the
$query->setHint(\Doctrine\ORM\Query::HINT_CUSTOM_OUTPUT_WALKER, 'Gedmo\\Translatable\\Query\\TreeWalker\\TranslationWalker')
->setHint(\Gedmo\Translatable\TranslatableListener::HINT_TRANSLATABLE_LOCALE, $lang);
If I call this service from a URL (a Controller) translatable works fine, but if I run the command from the CLI , Translatable is not fired or fails to force the locale ($lang). Any idea to solve that?
I am new to Spring framework and trying to implement a simple CRUD application in spring boot with MySQL as database. Everything is working fine.
I have the Auto Increment enabled on Id field in the database. I am using EntityManager.persist() method to save the data in database and it is working fine. Now I want to return the auto generatedId back to the client as response of POST method but EntityManager.persist()return type is void.
Can anyone help me that how I can return the Id back?
the id is guaranteed after flush operation or when the transaction is completed.
em.persist(employee)
em.flush();
long id = employee.getId();
for more details read
What's the advantage of persist() vs save() in Hibernate?
I'm building an app with silex and I'm using the built-in SecurityServiceProvider and I'm trying to use the rememberme service and I'm looking at the documentation and there a option called token_provider but symfony doesn't really state if that is a string or if its an instance of an object.
any help will be appreciated.
This parameter is a service id of a token provider to use. Services id are strings (then Symfony looks for the class in the DIC, Silex does the same) so you need to declare a FQDN of your token provider class. By default Symfony uses the Symfony\Component\Security\Core\Authentication\RememberMe\InMemoryTokenProvider class
If you want to create your own (probably you won't), you can take a look at how Doctrine Project programed this service by implementing the TokenProviderInterface.