當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Self::validate_user_can_view_this_country_for_client方法代碼示例

本文整理匯總了PHP中Self::validate_user_can_view_this_country_for_client方法的典型用法代碼示例。如果您正苦於以下問題:PHP Self::validate_user_can_view_this_country_for_client方法的具體用法?PHP Self::validate_user_can_view_this_country_for_client怎麽用?PHP Self::validate_user_can_view_this_country_for_client使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Self的用法示例。


在下文中一共展示了Self::validate_user_can_view_this_country_for_client方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getOptionsCountriesAction

 /**
  * @ApiDoc(
  *    description = "Return a list of the countries which a user is allowed to see due to his permissions.",
  *    section="Z_DISABLED",
  *    statusCodes = {
  *     200 = "Returned when the request is without errors",
  *     403 = "Invalid API KEY",
  *     404 = "The database has no countries momentarely.",
  *     500 = "Header x-wsse does not exist"
  *    },
  *    requirements = {
  *      {
  *          "name" = "_format",
  *          "requirement" = "json|xml"
  *      }
  *    },
  *    parameters = {
  *          {"name"="client_id", "dataType"="integer", "required"=true, "description"="The client id"},
  *    }
  * )
  * @return array
  * @View()
  */
 public function getOptionsCountriesAction(Request $request)
 {
     $user = $this->getUser();
     $response = new Response();
     if (empty($request->get('client_id'))) {
         $response->setStatusCode(400);
         $response->setContent(json_encode(array('success' => false, 'message' => 'Client id must be provided in the call.')));
         return $response;
     }
     $client_id = $request->get('client_id');
     $client = $this->getDoctrine()->getRepository('CampaignBundle:Client')->find($client_id);
     if (!$client) {
         $response->setStatusCode(400);
         $response->setContent(json_encode(array('success' => false, 'message' => 'There is no client for that id.')));
         return $response;
     }
     //        $countries = $this->getDoctrine()->getRepository('CampaignBundle:Country')->findAllWithout_temp_country();
     $countries = $this->getDoctrine()->getRepository('CampaignBundle:Country')->findAll();
     if (!$countries) {
         $response->setStatusCode(404);
         $response->setContent(json_encode(array('success' => false, 'message' => 'The database has no countries momentarely.')));
     }
     $total = 0;
     $countries_array = array();
     foreach ($countries as $country) {
         $can_view = Self::validate_user_can_view_this_country_for_client($user, $client, $country);
         if ($can_view) {
             $countries_array[$country->getId()] = $country->getName();
             $total++;
         }
         if ($total > 0 && $country->getName() == 'temp_country') {
             $countries_array[$country->getId()] = ucfirst($country->getName());
         }
     }
     asort($countries_array);
     $response->setStatusCode(200);
     $response->setContent(json_encode(array('countries' => $countries_array)));
     return $response;
 }
開發者ID:bogdy2p,項目名稱:oviTiut,代碼行數:62,代碼來源:CampaignController.php


注:本文中的Self::validate_user_can_view_this_country_for_client方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。