update filter param for get promo codes
added type param valid values ( "ACCEPTED", "ALTERNATE", "VIP","ATC","MEDIA ANALYST","SPONSOR" ) Change-Id: I29069cf4cf6b523265e72f0595ca8abaaeecf69c
This commit is contained in:
parent
91358d8b72
commit
bdd9e9b59c
@ -11,7 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Models\Foundation\Summit\PromoCodes\PromoCodesValidClasses;
|
||||
use App\Models\Foundation\Summit\PromoCodes\PromoCodesConstants;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Request;
|
||||
use models\exceptions\EntityNotFoundException;
|
||||
@ -85,11 +85,26 @@ final class OAuth2SummitPromoCodesApiController extends OAuth2ProtectedControlle
|
||||
*/
|
||||
private function validateClassName($filter_element){
|
||||
if($filter_element instanceof FilterElement){
|
||||
return in_array($filter_element->getValue(), PromoCodesValidClasses::$valid_class_names);
|
||||
return in_array($filter_element->getValue(), PromoCodesConstants::$valid_class_names);
|
||||
}
|
||||
$valid = true;
|
||||
foreach($filter_element[0] as $elem){
|
||||
$valid = $valid && in_array($elem->getValue(), PromoCodesValidClasses::$valid_class_names);
|
||||
$valid = $valid && in_array($elem->getValue(), PromoCodesConstants::$valid_class_names);
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $filter_element
|
||||
* @return bool
|
||||
*/
|
||||
private function validateTypes($filter_element){
|
||||
if($filter_element instanceof FilterElement){
|
||||
return in_array($filter_element->getValue(), PromoCodesConstants::getValidTypes());
|
||||
}
|
||||
$valid = true;
|
||||
foreach($filter_element[0] as $elem){
|
||||
$valid = $valid && in_array($elem->getValue(), PromoCodesConstants::getValidTypes());
|
||||
}
|
||||
return $valid;
|
||||
}
|
||||
@ -141,6 +156,7 @@ final class OAuth2SummitPromoCodesApiController extends OAuth2ProtectedControlle
|
||||
'speaker_email' => ['=@', '=='],
|
||||
'sponsor' => ['=@', '=='],
|
||||
'class_name' => ['=='],
|
||||
'type' => ['=='],
|
||||
]);
|
||||
}
|
||||
|
||||
@ -162,7 +178,17 @@ final class OAuth2SummitPromoCodesApiController extends OAuth2ProtectedControlle
|
||||
sprintf
|
||||
(
|
||||
"class_name filter has an invalid value ( valid values are %s",
|
||||
implode(", ", PromoCodesValidClasses::$valid_class_names)
|
||||
implode(", ", PromoCodesConstants::$valid_class_names)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if($filter->hasFilter("type") && !$this->validateTypes($filter->getFilter("type"))){
|
||||
throw new ValidationException(
|
||||
sprintf
|
||||
(
|
||||
"type filter has an invalid value ( valid values are %s",
|
||||
implode(", ", PromoCodesConstants::getValidTypes())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -11,7 +11,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
**/
|
||||
use App\Models\Foundation\Summit\PromoCodes\PromoCodesValidClasses;
|
||||
use App\Models\Foundation\Summit\PromoCodes\PromoCodesConstants;
|
||||
use models\exceptions\ValidationException;
|
||||
use models\summit\MemberSummitRegistrationPromoCode;
|
||||
use models\summit\SpeakerSummitRegistrationPromoCode;
|
||||
@ -33,12 +33,12 @@ final class PromoCodesValidationRulesFactory
|
||||
|
||||
$class_name = trim($data['class_name']);
|
||||
|
||||
if(!in_array($class_name, PromoCodesValidClasses::$valid_class_names)){
|
||||
if(!in_array($class_name, PromoCodesConstants::$valid_class_names)){
|
||||
throw new ValidationException(
|
||||
sprintf
|
||||
(
|
||||
"class_name param has an invalid value ( valid values are %s",
|
||||
implode(", ", PromoCodesValidClasses::$valid_class_names)
|
||||
implode(", ", PromoCodesConstants::$valid_class_names)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -14,16 +14,22 @@
|
||||
use models\summit\MemberSummitRegistrationPromoCode;
|
||||
use models\summit\SpeakerSummitRegistrationPromoCode;
|
||||
use models\summit\SponsorSummitRegistrationPromoCode;
|
||||
|
||||
/**
|
||||
* Class PromoCodesValidClasses
|
||||
* @package App\Models\Foundation\Summit\PromoCodes
|
||||
*/
|
||||
final class PromoCodesValidClasses
|
||||
final class PromoCodesConstants
|
||||
{
|
||||
public static $valid_class_names = [
|
||||
SpeakerSummitRegistrationPromoCode::ClassName,
|
||||
SponsorSummitRegistrationPromoCode::ClassName,
|
||||
MemberSummitRegistrationPromoCode::ClassName,
|
||||
];
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public static function getValidTypes(){
|
||||
return array_merge(MemberSummitRegistrationPromoCode::$valid_type_values, SpeakerSummitRegistrationPromoCode::$valid_type_values);
|
||||
}
|
||||
}
|
@ -88,6 +88,10 @@ class DoctrineSummitRegistrationPromoCodeRepository
|
||||
(
|
||||
"(sprr.email :operator ':value' OR spmm.email :operator ':value')"
|
||||
),
|
||||
'type' => new DoctrineFilterMapping
|
||||
(
|
||||
"(mpc.type :operator ':value' OR spkpc.type :operator ':value')"
|
||||
),
|
||||
'class_name' => new DoctrineInstanceOfFilterMapping(
|
||||
"pc",
|
||||
[
|
||||
|
Loading…
x
Reference in New Issue
Block a user