private function _saveResponse($aResponse, $oRemoteApp)
        {

            // get model by app-type
            $sClassName      = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType());
            $sQueryClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType() . 'Query');

            // if class exists, proceed...
            if (class_exists($sClassName)) {
                // find histories for remote-app
                $aHistories = $sQueryClassName::create()->findByRemoteAppId($oRemoteApp->getId());

                // create new history-entry
                $oRemoteHistoryClass = new $sClassName();
                $oRemoteHistoryClass->setRemoteApp($oRemoteApp);
                $oRemoteHistoryClass->setData($aResponse);

                // convert created class to array for comparsion
                $aNewHistory               = $oRemoteHistoryClass->toArray();
                $aNewHistory['Extensions'] = $aNewHistory['Extensions']->getArrayCopy();
                if (is_object($aNewHistory['Log'])) {
                    $aNewHistory['Log'] = $aNewHistory['Log']->getArrayCopy();
                } else {
                    $aNewHistory['Log'] = array();
                }
                unset($aNewHistory['Id']);


                // interate old histories and convert to array for comparsion
                foreach ($aHistories as $oHistory) {
                    $aHistory               = $oHistory->toArray();
                    $aHistory['Extensions'] = $aHistory['Extensions']->getArrayCopy();
                    if (is_object($aHistory['Log'])) {
                        $aHistory['Log'] = $aHistory['Log']->getArrayCopy();
                    } else {
                        $aHistory['Log'] = array();
                    }

                    unset($aHistory['Id']);

                    // if api-call was not successful, send notifiations if configured
                    if ($aResponse['statuscode'] != 200) {
                        if ($oRemoteApp->checkNotificationSetting("NotificationError")) {
                            $this->_sendErrorNotification($oRemoteApp, $aResponse);
                        }
                    } else {
                        // if api-call was successful, compare old and new history and send differences to user
                        $aNew = $this->arrayRecursiveDiff($aNewHistory, $aHistory);
                        // diff exists?
                        if (!empty($aNew) && $oRemoteApp->checkNotificationSetting("NotificationChange")) {
                            $aOld = $this->arrayRecursiveDiff($aHistory, $aNewHistory);
                            $this->_sendNotification(array(
                                                         'old' => $aOld,
                                                         'new' => $aNew
                                                     ), $oRemoteApp, $aNewHistory);
                        }
                    }
                    // delete old history
                    $oHistory->delete();
                }

                // save created history
                $oRemoteHistoryClass->save();
                $oRemoteApp->setLastRun(time());
                $oRemoteApp->save();

            } else {
                $this->getContainer()->get('logger')->error('Class \'' . $sClassName . '\' not found... ', array("Method"    => __METHOD__,
                                                                                                                                         "RemoteApp" => $oRemoteApp->getName(),
                                                                                                                                         "RemoteURL" => $oRemoteApp->getFullApiUrl()
                ));
                throw new \Exception('Class \'' . $sClassName . '\' not found... ');
            }
        }
private function _saveResponse($aResponse, $oRemoteApp)
        {

            // get model by app-type
            $sClassName      = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType());
            $sQueryClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst($oRemoteApp->getType() . 'Query');

            // if class exists, proceed...
            if (class_exists($sClassName)) {
                // find histories for remote-app
                $aHistories = $sQueryClassName::create()->findByRemoteAppId($oRemoteApp->getId());

                // create new history-entry
                $oRemoteHistoryClass = new $sClassName();
                $oRemoteHistoryClass->setRemoteApp($oRemoteApp);
                $oRemoteHistoryClass->setData($aResponse);

                // convert created class to array for comparsion
                $aNewHistory               = $oRemoteHistoryClass->toArray();
                $aNewHistory['Extensions'] = $aNewHistory['Extensions']->getArrayCopy();
                if (is_object($aNewHistory['Log'])) {
                    $aNewHistory['Log'] = $aNewHistory['Log']->getArrayCopy();
                } else {
                    $aNewHistory['Log'] = array();
                }
                unset($aNewHistory['Id']);


                // interate old histories and convert to array for comparsion
                foreach ($aHistories as $oHistory) {
                    $aHistory               = $oHistory->toArray();
                    $aHistory['Extensions'] = $aHistory['Extensions']->getArrayCopy();
                    if (is_object($aHistory['Log'])) {
                        $aHistory['Log'] = $aHistory['Log']->getArrayCopy();
                    } else {
                        $aHistory['Log'] = array();
                    }

                    unset($aHistory['Id']);

                    // if api-call was not successful, send notifiations if configured
                    if ($aResponse['statuscode'] != 200) {
                        if ($oRemoteApp->checkNotificationSetting("NotificationError")) {
                            $this->_sendErrorNotification($oRemoteApp, $aResponse);
                        }
                    } else {
                        // if api-call was successful, compare old and new history and send differences to user
                        $aNew = $this->arrayRecursiveDiff($aNewHistory, $aHistory);
                        // diff exists?
                        if (!empty($aNew) && $oRemoteApp->checkNotificationSetting("NotificationChange")) {
                            $aOld = $this->arrayRecursiveDiff($aHistory, $aNewHistory);
                            $this->_sendNotification(array(
                                                         'old' => $aOld,
                                                         'new' => $aNew
                                                     ), $oRemoteApp, $aNewHistory);
                        }
                    }
                    // delete old history
                    $oHistory->delete();
                }

                // save created history
                $oRemoteHistoryClass->save();
                $oRemoteApp->setLastRun(time());
                $oRemoteApp->save();

            } else {
                $this->getContainer()->get('logger')->error('Class \'' . $sClassName . '\' not found... ', array("Method"    => __METHOD__,
                                                                                                                                         "RemoteApp" => $oRemoteApp->getName(),
                                                                                                                                         "RemoteURL" => $oRemoteApp->getFullApiUrl()
                ));
                throw new \Exception('Class \'' . $sClassName . '\' not found... ');
            }
        }
private function _saveResponse ( $ aResponse , $ oRemoteApp ) { // get model by app-type $ sClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst ( $ oRemoteApp -> getType ( ) ) ; $ sQueryClassName = '\Slashworks\AppBundle\Model\RemoteHistory' . ucfirst ( $ oRemoteApp -> getType ( ) . 'Query' ) ; // if class exists, proceed... if ( class_exists ( $ sClassName ) ) { // find histories for remote-app $ aHistories = $ sQueryClassName :: create ( ) -> findByRemoteAppId ( $ oRemoteApp -> getId ( ) ) ; // create new history-entry $ oRemoteHistoryClass = new $ sClassName ( ) ; $ oRemoteHistoryClass -> setRemoteApp ( $ oRemoteApp ) ; $ oRemoteHistoryClass -> setData ( $ aResponse ) ; // convert created class to array for comparsion $ aNewHistory = $ oRemoteHistoryClass -> toArray ( ) ; $ aNewHistory [ 'Extensions' ] = $ aNewHistory [ 'Extensions' ] -> getArrayCopy ( ) ; if ( is_object ( $ aNewHistory [ 'Log' ] ) ) { $ aNewHistory [ 'Log' ] = $ aNewHistory [ 'Log' ] -> getArrayCopy ( ) ; } else { $ aNewHistory [ 'Log' ] = array ( ) ; } unset ( $ aNewHistory [ 'Id' ] ) ; // interate old histories and convert to array for comparsion foreach ( $ aHistories as $ oHistory ) { $ aHistory = $ oHistory -> toArray ( ) ; $ aHistory [ 'Extensions' ] = $ aHistory [ 'Extensions' ] -> getArrayCopy ( ) ; if ( is_object ( $ aHistory [ 'Log' ] ) ) { $ aHistory [ 'Log' ] = $ aHistory [ 'Log' ] -> getArrayCopy ( ) ; } else { $ aHistory [ 'Log' ] = array ( ) ; } unset ( $ aHistory [ 'Id' ] ) ; // if api-call was not successful, send notifiations if configured if ( $ aResponse [ 'statuscode' ] != 200 ) { if ( $ oRemoteApp -> checkNotificationSetting ( "NotificationError" ) ) { $ this -> _sendErrorNotification ( $ oRemoteApp , $ aResponse ) ; } } else { // if api-call was successful, compare old and new history and send differences to user $ aNew = $ this -> arrayRecursiveDiff ( $ aNewHistory , $ aHistory ) ; // diff exists? if ( ! empty ( $ aNew ) && $ oRemoteApp -> checkNotificationSetting ( "NotificationChange" ) ) { $ aOld = $ this -> arrayRecursiveDiff ( $ aHistory , $ aNewHistory ) ; $ this -> _sendNotification ( array ( 'old' => $ aOld , 'new' => $ aNew ) , $ oRemoteApp , $ aNewHistory ) ; } } // delete old history $ oHistory -> delete ( ) ; } // save created history $ oRemoteHistoryClass -> save ( ) ; $ oRemoteApp -> setLastRun ( time ( ) ) ; $ oRemoteApp -> save ( ) ; } else { $ this -> getContainer ( ) -> get ( 'logger' ) -> error ( 'Class \'' . $ sClassName . '\' not found... ' , array ( "Method" => __METHOD__ , "RemoteApp" => $ oRemoteApp -> getName ( ) , "RemoteURL" => $ oRemoteApp -> getFullApiUrl ( ) ) ) ; throw new \ Exception ( 'Class \'' . $ sClassName . '\' not found... ' ) ; } }
Save response to database

@param array     $aResponse
@param RemoteApp $oRemoteApp

@throws \Exception

@return void
Save response to database