0

我有这个 PHP 控制器类(属于 Symfony2 包):

class ReptoolController extends PageController
{
    // ...

    private function _get($request, $action, $case)
    {
        $app_id = $this->getRequested('app_id');
        if( ( $repappConfig = $this->getDoctrine()->getRepository('PDOneBundle:RepappConfig')->findOneBy(array("app_id"=>$app_id))) )
        {
            $current_timestamp = new \DateTime(date('Y-m-d'));
            if($repappConfig->getExpireDate())
                $expire_date = $repappConfig->getExpireDate()->getTimestamp();
            else
            {
                $temp = $current_timestamp;
                $temp->modify("+7 day");
                $temp->format("Y-m-d");
                $expire_date = $temp->getTimestamp();
            }
            if($expire_date < $current_timestamp->getTimestamp())
            {
                $response = new \stdClass();
                $response->status = FormUtilities::RESPONSE_STATUS_BAD;
                $controller_response = new Response( json_encode($response) );
                $controller_response->headers->set('Content-Type', 'application/json; charset=utf-8');
                return $controller_response;
            }
        }

        switch($case)
        {
            // ...
            case FormUtilities::CASE_BRAND_CUSTOM_MESSAGES:
                return $this->getBrandCustomMessages($request, $action, $case);
                break;
            // ...
            default:
                $response = new \stdClass();
                $response->status = FormUtilities::RESPONSE_STATUS_BAD;
                $controller_response = new Response( json_encode($response) );
                $controller_response->headers->set('Content-Type', 'application/json; charset=utf-8');
                return $controller_response;
                break;
        }
    }

    // ...

    private function getBrandCustomMessages($request, $action, $case)
    {
        $id = $this->getRequested('app_id');
        $reptool_records = $this->getRequestedSync();

        $response = new \stdClass();
        $response->status = FormUtilities::RESPONSE_STATUS_BAD;

        $repappConfig = new RepappConfig();
        $repappConfig = $this->getDoctrine()->getRepository('PDOneBundle:RepappConfig')->findOneBy(array("app_id"=>$id));
        $project_id = $repappConfig->getProjectId();
        $brand_table = $this->getDoctrine()->getRepository('PDOneBundle:Brand')->findBy(array("project"=>$project_id));

        if($brand_table)
        {
            foreach($brand_table as $bt)
            {
                $brand_id = $bt->getID();

                    $brandCustomMessages = new BrandCustomMessages();
                    if( $brandCustomMessages = $this->getDoctrine()->getRepository('PDOneBundle:BrandCustomMessages')->findBy(array("brand_id"=>$brand_id) ))
                    {
                        $sync = array();
                        foreach ($brandCustomMessages as $brandCustomMessage)
                        {

                            $response->status = FormUtilities::RESPONSE_STATUS_VALID;

                            $brandCustMess = new PDOneResponse(
                                                                                    $brandCustomMessage->getID(),
                                                                                    strtotime($brandCustomMessage->getModifiedAt()->format("Y-m-d H:i:s"))
                                                                                    );


                            $brandCustMess->id = $brandCustomMessage->getID();
                            $brandCustMess->message_text = $brandCustomMessage->getMessageText();
                            $brandCustMess->message_code = $brandCustomMessage->getMessageCode();
                            $brandCustMess->brand_id = (int)$brandCustomMessage->getBrandId();

                            $reptool_records = $brandCustMess->setRecordStatus($reptool_records);

                            // ADD BACKEND RECORD TO SYNC
                            if($brandCustMess->status != FormUtilities::RESPONSE_STATUS_OK ) $sync[] = $brandCustMess;
                        }
                        // COMPOSITE SYNC WITH REPTOOL RECORDS
                        $sync = PDOneResponse::compositeSync($sync, $reptool_records);
                        $response->sync = $sync;

                    }

            }
        }

        $controller_response = new Response( json_encode($response) );
        $controller_response->headers->set('Content-Type', 'application/json; charset=utf-8');
        return $controller_response;
    }

    // ...

我需要为参与者的流程(这是一个向该控制器PDOneApp发出请求的 iPad 应用程序)构建一个序列图 (SD)。get|set这是我在SD Version1SD Version 2中所做的:

版本 1

在此处输入图像描述

版本 2

在此处输入图像描述

关于上面显示的图表,我有以下疑问,并以上面显示的代码为例:

  • 哪个图表是正确的?

  • 实体的调用(意思是图中的表示):RepappConfigBrand吗?在代码中,这些调用是从方法内部进行的getBrandCustomMessages(),我直接从控制器中获取ReptoolController它们,这让我认为这是错误的。如果是这种情况,他们应该如何表示?

  • 我知道 SD 并不是要按原样表示代码,但是,您如何表示函数的条件?也许我可以将条件包装在一个函数中并从内部调用该函数getBrandCustomMessages()这是正确的方法吗?你对这个疑问有什么建议?

  • 正如您将在函数中看到的,最后一个返回是一个 Response 对象,该部分是否在图表上?或者该行应该用返回标签破折号?

任何人都可以帮助完成这个图表并理解conditionalUML SD 的部分吗?

4

1 回答 1

1

您的第二张图getBrandCustomMessages正确显示了内部调用。

如果你真的想展示if然后使用片段(http://www.uml-diagrams.org/sequence-diagrams-combined-fragment.html)。您可以将片段划分为单个分区(if/else 或 case;任何合适的)。

最后一个响应不应该发送给实体,而是作为返回消息(来自内部调用之后)给参与者。这可能就是您打算展示的内容。

于 2015-03-18T10:18:34.003 回答