Skip to content
This repository has been archived by the owner on Dec 13, 2022. It is now read-only.

fix(api) Use the web service or initialize it #7265

Merged
merged 2 commits into from
Apr 3, 2019
Merged

Conversation

loiclau
Copy link
Contributor

@loiclau loiclau commented Mar 11, 2019

Pull Request Template

Description

Use the existing web service or initialize it.
Need to use web service with cron script.

Type of change

  • New functionality (non-breaking change)

Target serie

  • 19.04.x (master)

How this pull request can be tested ?

Please describe the procedure to verify that the goal of the PR is matched. Provide clear instructions so that it can be correctly tested.

Any relevant details of the configuration to perform the test should be added.

Checklist

Community contributors & Centreon team
  • I followed the coding style guidelines provided by Centreon
  • I have commented my code, especially hard-to-understand areas of the PR.
  •  I have rebased my development branch on the base branch (master, maintenance).

@loiclau loiclau requested a review from callapa March 11, 2019 08:50
www/api/class/webService.class.php Outdated Show resolved Hide resolved
Co-Authored-By: loiclau <loic.lau@gmail.com>
@vhr
Copy link
Contributor

vhr commented Mar 13, 2019

@loiclau can you explain the idea behind the changes?

Copy link
Contributor

@victorvassilev victorvassilev left a comment

Choose a reason for hiding this comment

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

please explain what is the reason for this change, we can't understand it

@loiclau
Copy link
Contributor Author

loiclau commented Mar 13, 2019

It's because the webservice need a repository to work.
It's add and initialized on the service provider.
Without this change we can not create objects with argument.

@vhr
Copy link
Contributor

vhr commented Mar 14, 2019

You can register your webservice here

https://github.com/centreon/centreon/blob/master/src/Centreon/ServiceProvider.php#L37

example:
$pimple['centreon.webservice']->add(Webservice\MyWebservice::class);

about calling of repositories

class MyWebservice extends CentreonWebServiceAbstract
{
    public function getSomeMethod() {
		$entities = $this->getDi()['centreon.db-manager']
			->getRepository(Repository\MyRepository::class)
			->someMethodFromRepository();

		...

		return [];
	}

	...
}

@loiclau loiclau merged commit f45974c into master Apr 3, 2019
@loiclau loiclau deleted the initialize-webservice branch April 3, 2019 12:18
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants