/** * @return array * @throws NotSupportedException if the attributeIndexOrDerivedType has not been populated yet */ public function getOperatorValuesAndLabels() { if ($this->attributeIndexOrDerivedType == null) { throw new NotSupportedException(); } $type = $this->getAvailableOperatorsType(); $data = array(); ModelAttributeToWorkflowOperatorTypeUtil::resolveOperatorsToIncludeByType($data, $type); $data[OperatorRules::TYPE_DOES_NOT_CHANGE] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_DOES_NOT_CHANGE); if ($type != ModelAttributeToWorkflowOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_BOOLEAN && $type != ModelAttributeToWorkflowOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_HAS_ONE) { $data[OperatorRules::TYPE_IS_EMPTY] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_IS_EMPTY); $data[OperatorRules::TYPE_IS_NOT_EMPTY] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_IS_NOT_EMPTY); } return $data; }
/** * @param string $attribute * @return null|string * @throws NotSupportedException if the attribute is a derived attribute */ public function getAvailableOperatorsType($attribute) { assert('is_string($attribute)'); //Currently only User is supported as a dynamically derived attributed if ($this->isDynamicallyDerivedAttribute($attribute)) { return ModelAttributeToOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_HAS_ONE; } if ($this->isDerivedAttribute($attribute)) { throw new NotSupportedException(); } $resolvedAttribute = static::resolveRealAttributeName($attribute); if (null != ($availableOperatorsTypeFromRule = $this->rules->getAvailableOperatorsTypes($this->model, $resolvedAttribute))) { return $availableOperatorsTypeFromRule; } return ModelAttributeToWorkflowOperatorTypeUtil::getAvailableOperatorsType($this->model, $resolvedAttribute); }
/** * @return array * @throws NotSupportedException if the attributeIndexOrDerivedType has not been populated yet */ public function getOperatorValuesAndLabels() { if ($this->attributeIndexOrDerivedType == null) { throw new NotSupportedException(); } $type = $this->getAvailableOperatorsType(); $data = array(); ModelAttributeToWorkflowOperatorTypeUtil::resolveOperatorsToIncludeByType($data, $type); if ($this->resolveShouldAddSpecialOnSaveNonRelatedOperators()) { $data[OperatorRules::TYPE_BECOMES] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_BECOMES); $data[OperatorRules::TYPE_WAS] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_WAS); $data[OperatorRules::TYPE_CHANGES] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_CHANGES); $data[OperatorRules::TYPE_DOES_NOT_CHANGE] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_DOES_NOT_CHANGE); } elseif ($this->resolveShouldAddSpecialByTimeNonRelatedOperators()) { $data[OperatorRules::TYPE_DOES_NOT_CHANGE] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_DOES_NOT_CHANGE); } if ($this->resolveShouldAddSpecialOnSaveNonRelatedOperators() && $type == ModelAttributeToOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_DROPDOWN && $this->getValueElementType() != 'StaticMultiSelectDropDownForWorkflow') { $data[OperatorRules::TYPE_BECOMES_ONE_OF] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_BECOMES_ONE_OF); $data[OperatorRules::TYPE_WAS_ONE_OF] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_WAS_ONE_OF); } if ($type != ModelAttributeToWorkflowOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_BOOLEAN && $type != ModelAttributeToWorkflowOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_CURRENCY_VALUE) { $data[OperatorRules::TYPE_IS_EMPTY] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_IS_EMPTY); $data[OperatorRules::TYPE_IS_NOT_EMPTY] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_IS_NOT_EMPTY); } return $data; }
/** * @return array * @throws NotSupportedException */ public function getDurationValuesAndLabels() { if ($this->attributeIndexOrDerivedType == null) { throw new NotSupportedException(); } $modelToWorkflowAdapter = $this->makeResolvedAttributeModelRelationsAndAttributesToWorkflowAdapter(); $type = $modelToWorkflowAdapter->getDisplayElementType($this->getResolvedAttribute()); $data = array(); if ($type == 'DateTime') { return $this->makeDurationValuesAndLabels(true, true, true, true); } elseif ($type == 'Date') { return $this->makeDurationValuesAndLabels(true, true, true, false); } else { return $this->makeDurationValuesAndLabels(true, false, false, true); } return $data; ModelAttributeToWorkflowOperatorTypeUtil::resolveOperatorsToIncludeByType($data, $type); $data[OperatorRules::TYPE_DOES_NOT_CHANGE] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_DOES_NOT_CHANGE); if ($type != ModelAttributeToWorkflowOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_BOOLEAN && $type != ModelAttributeToWorkflowOperatorTypeUtil::AVAILABLE_OPERATORS_TYPE_HAS_ONE) { $data[OperatorRules::TYPE_IS_EMPTY] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_IS_EMPTY); $data[OperatorRules::TYPE_IS_NOT_EMPTY] = OperatorRules::getTranslatedTypeLabel(OperatorRules::TYPE_IS_NOT_EMPTY); } return $data; }