public static function upgradeTariffPlanLifeCycle($template)
 {
     $oldData = $template->exportData();
     $tariff = new TariffPlanLifeCycleModel();
     $tariff->importData($oldData);
     $newStatuses = array(LifeCycleModel::STATUS_ACTIVATION_READY, LifeCycleModel::STATUS_ACTIVATION_PENDANT);
     $changed = false;
     foreach ($newStatuses as $statusConst) {
         $status = $tariff->findStatus($statusConst);
         if (!$status) {
             $status = new StatusCostModel(array('status' => $statusConst, 'cost' => 0));
             $tariff->addStatus($status);
             $changed = true;
         }
     }
     if (!$changed) {
         throw new App_MigrationTool_TemplatesTo24_Exception("LifeCycle tariff plan template {$template->id} already upgraded.");
     }
     $validator = new TariffPlanLifeCycleValidate();
     if (!$validator->isValid($tariff)) {
         throw new App_MigrationTool_TemplatesTo24_Exception("Invalid LifeCycle tariff plan template {$template->id}. " . var_export($validator->getMessages(), true));
     }
     return $tariff;
 }
 protected function _insertEricsson(TariffPlanLifeCycleModel $tariff)
 {
     $methodName = self::METHOD_NAME_CREATE;
     try {
         $proto = $this->_createProto($methodName);
         $createData = new TariffPlanDefinition();
         $proto->setCreateData($createData);
         $mappedData = $this->_mapModelToEricssonModel($tariff->exportData());
         $createData->parse($mappedData, new \DrSlump\Protobuf\Codec\PhpArray());
         $response = $this->_sendRequest($methodName, array('protoMessage' => $proto));
     } catch (Exception $e) {
         \App::log()->CRIT($e);
     }
     $this->_checkPostResponse($response);
     $tariff->setId($response->getId());
     return $tariff->getId();
 }