This method checks if the value is of the specified enumerable type.
A value is a valid enumerable value if it is equal to the name of a constant
in the specified enumerable type (class).
For more details about enumerable, see {@link TEnumerable}.
For backward compatibility, this method also supports sanity
check of a string value to see if it is among the given list of strings.
public static ensureEnum ( $value, $enums ) : string | ||
return | string | the valid enumeration value |
/** * @param TUserManagerPasswordMode how password is stored, clear text, or MD5 or SHA1 hashed. */ public function setPasswordMode($value) { $this->_passwordMode = TPropertyValue::ensureEnum($value, 'Prado\\Security\\TUserManagerPasswordMode'); }
/** * @param TDbNullConversionMode how the null and empty strings are converted */ public function setNullConversion($value) { switch (TPropertyValue::ensureEnum($value, 'Prado\\Data\\TDbNullConversionMode')) { case TDbNullConversionMode::Preserved: $value = PDO::NULL_NATURAL; break; case TDbNullConversionMode::EmptyStringToNull: $value = PDO::NULL_EMPTY_STRING; break; case TDbNullConversionMode::NullToEmptyString: $value = PDO::NULL_TO_STRING; break; } $this->setAttribute(PDO::ATTR_ORACLE_NULLS, $value); }
/** * Set wether the element should be constrainted in one direction * @param CDraggableConstraint */ public function setConstraint($value) { $this->setViewState('Constraint', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\ActiveControls\\DraggableConstraint'), TDraggableConstraint::None); }
/** * Client script to select/clear/check a drop down list, check box list, * or radio button list. * The second parameter determines the selection method. Valid methods are * - <b>Value</b>, select or check by value * - <b>Values</b>, select or check by a list of values * - <b>Index</b>, select or check by index (zero based index) * - <b>Indices</b>, select or check by a list of index (zero based index) * - <b>Clear</b>, clears or selections or checks in the list * - <b>All</b>, select all * - <b>Invert</b>, invert the selection. * @param TControl list control * @param string selection method * @param string|int the value or index to select/check. * @param string selection control type, either 'check' or 'select' */ public function select($control, $method = 'Value', $value = null, $type = null) { $method = TPropertyValue::ensureEnum($method, 'Value', 'Index', 'Clear', 'Indices', 'Values', 'All', 'Invert'); $type = $type === null ? $this->getSelectionControlType($control) : $type; $total = $this->getSelectionControlIsListType($control) ? $control->getItemCount() : 1; // pass the ID to avoid getting the surrounding elements (ISurroundable) if ($control instanceof TControl) { $control = $control->getClientID(); } $this->callClientFunction('Prado.Element.select', array($control, $type . $method, $value, $total)); }
/** * Sets the comparison operation to perform * @param TValidationCompareOperator the comparison operation */ public function setOperator($value) { $this->setViewState('Operator', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TValidationCompareOperator'), TValidationCompareOperator::Equal); }
/** * This method has been deprecated since version 3.2.1. * Please use {@link setHashAlgorithm()} instead. * @param TSecurityManagerValidationMode hashing algorithm used to generate HMAC. */ public function setValidation($value) { $this->_hashAlgorithm = TPropertyValue::ensureEnum($value, 'Prado\\Security\\TSecurityManagerValidationMode'); }
/** * @param TTableRowSection location of a row in a table. */ public function setTableSection($value) { $this->setViewState('TableSection', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTableRowSection'), TTableRowSection::Body); }
/** * @param TValidatorDisplayStyle the style of displaying the error message */ public function setDisplay($value) { $this->setViewState('Display', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TValidatorDisplayStyle'), TValidatorDisplayStyle::Fixed); }
/** * @param TTableCaptionAlign table caption alignment. */ public function setCaptionAlign($value) { $this->setViewState('CaptionAlign', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTableCaptionAlign'), TTableCaptionAlign::NotSet); }
/** * @param TScrollBars the visibility and position of scroll bars in a panel control. */ public function setScrollBars($value) { $this->_scrollBars = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TScrollBars'); }
/** * @param THttpSessionCookieMode how to use cookie to store session ID * @throws TInvalidOperationException if session is started already */ public function setCookieMode($value) { if ($this->_started) { throw new TInvalidOperationException('httpsession_cookiemode_unchangeable'); } else { $value = TPropertyValue::ensureEnum($value, 'Prado\\Web\\THttpSessionCookieMode'); if ($value === THttpSessionCookieMode::None) { ini_set('session.use_cookies', '0'); ini_set('session.use_only_cookies', '0'); } else { if ($value === THttpSessionCookieMode::Allow) { ini_set('session.use_cookies', '1'); ini_set('session.use_only_cookies', '0'); } else { ini_set('session.use_cookies', '1'); ini_set('session.use_only_cookies', '1'); ini_set('session.use_trans_sid', 0); } } } }
/** * Define the way an active record finder react if an invalid magic-finder invoked * @param TActiveRecordInvalidFinderResult * @since 3.1.5 * @see getInvalidFinderResult */ public function setInvalidFinderResult($value) { $this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'Prado\\Data\\ActiveRecord\\TActiveRecordInvalidFinderResult'); }
/** * Sets the grid line style of the table. * @param TTableGridLines the grid line setting of the table */ public function setGridLines($value) { $this->_gridLines = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTableGridLines'); }
/** * @return TBulletedListDisplayMode display mode of the list. */ public function setDisplayMode($value) { $this->setViewState('DisplayMode', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TBulletedListDisplayMode'), TBulletedListDisplayMode::Text); }
/** * @param TColorPickerMode color picker UI mode */ public function setMode($value) { $this->setViewState('Mode', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TColorPickerMode'), TColorPickerMode::Basic); }
/** * @param TButtonType the type of the button. */ public function setButtonType($value) { $this->setViewState('ButtonType', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TButtonType'), TButtonType::Submit); }
/** * @param TInlineFrameScrollBars the visibility and position of scroll bars in an iframe. */ public function setScrollBars($value) { $this->setViewState('ScrollBars', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TInlineFrameScrollBars'), TInlineFrameScrollBars::Auto); }
/** * @param TTextHighlighterLineNumberStyle style of row number */ public function setLineNumberStyle($value) { $this->setViewState('LineNumberStyle', TPropertyValue::ensureEnum($value, 'TTextHighlighterLineNumberStyle')); }
/** * @param TListItemType item type. */ public function setItemType($value) { $this->_itemType = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TListItemType'); }
/** * @param TWizardStepType the wizard step type. */ public function setStepType($type) { $type = TPropertyValue::ensureEnum($type, 'Prado\\Web\\UI\\WebControls\\TWizardStepType'); if ($type !== $this->getStepType()) { $this->setViewState('StepType', $type, TWizardStepType::Auto); if ($this->_wizard) { $this->_wizard->wizardStepsChanged(); } } }
/** * @param TRepeatLayout how the repeated items should be displayed, using table or using line breaks. */ public function setRepeatLayout($value) { $this->_repeatLayout = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TRepeatLayout'); }
/** * Sets the behavior of hotspot regions in this imagemap when they are clicked. * If an individual hotspot has a mode other than 'NotSet', the mode set in this * imagemap will be ignored. By default, 'NotSet' is equivalent to 'Navigate'. * @param THotSpotMode the behavior of hotspot regions in this imagemap when they are clicked. */ public function setHotSpotMode($value) { $this->setViewState('HotSpotMode', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\THotSpotMode'), THotSpotMode::NotSet); }
/** * @param TDisplayStyle control display style, default is TDisplayStyle::Fixed */ public function setDisplayStyle($value) { $this->_displayStyle = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDisplayStyle'); switch ($this->_displayStyle) { case TDisplayStyle::None: $this->_fields['display'] = 'none'; break; case TDisplayStyle::Dynamic: $this->_fields['display'] = ''; //remove the display property break; case TDisplayStyle::Fixed: $this->_fields['visibility'] = 'visible'; break; case TDisplayStyle::Hidden: $this->_fields['visibility'] = 'hidden'; break; } }
/** * @param TDataGridPagerPosition where the pager is to be displayed. */ public function setPosition($value) { $this->_position = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TDataGridPagerPosition'); }
/** * @param TWizardNavigationButtonType button type. */ public function setButtonType($value) { $this->_buttonType = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TWizardNavigationButtonType'); }
/** * @param TListSelectionMode the selection mode */ public function setSelectionMode($value) { $this->setViewState('SelectionMode', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TListSelectionMode'), TListSelectionMode::Single); }
/** * @param TTextAlign the alignment of the text caption. Valid values include Left and Right. */ public function setTextAlign($value) { $this->setViewState('TextAlign', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TTextAlign'), TTextAlign::Right); }
/** * Sets the vertical alignment of the contents within the table item. * @param TVerticalAlign the horizontal alignment */ public function setVerticalAlign($value) { $this->_verticalAlign = TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TVerticalAlign'); }
/** * Sets the behavior mode of the TTextBox component. * @param TTextBoxMode the text mode * @throws TInvalidDataValueException if the input value is not a valid text mode. */ public function setTextMode($value) { $this->setViewState('TextMode', TPropertyValue::ensureEnum($value, 'TTextBoxMode'), TTextBoxMode::SingleLine); }
/** * @param TSliderDirection Direction of slider (Horizontal or Vertical) */ public function setDirection($value) { $this->setViewState('Direction', TPropertyValue::ensureEnum($value, 'Prado\\Web\\UI\\WebControls\\TSliderDirection'), TSliderDirection::Horizontal); }