webservice = $webservice; $this->devicePostUrl = $devicePostUrl; $this->deviceDeletePostUrl = $deviceDeletePostUrl; } /** * @param LifecycleEventArgs $args */ public function postPersist(LifecycleEventArgs $args) { $this->send($args, $this->devicePostUrl, HttpRequestInterface::METHOD_POST); } /** * @param LifecycleEventArgs $args */ public function preRemove(LifecycleEventArgs $args) { $this->send($args, $this->deviceDeletePostUrl, HttpRequestInterface::METHOD_DELETE); } /** * @param LifecycleEventArgs $arg * @param string $url * @param string $method */ private function send(LifecycleEventArgs $args, $url, $method) { $entity = $args->getEntity(); if ($entity instanceof DeviceInterface) { $data = array( 'deviceType' => get_class($entity), 'deviceId' => $entity->getId(), 'ip' => $entity->getIp(), ); return $this->webservice->makeGetRequest($url, $method, $data); } } }