/** * @param string $moduleClassName * @param string $modelClassName * @param string $workflowType * @return array * @throws NotSupportedException */ public static function resolveDataAndLabelsForTimeTriggerAvailableAttributes($moduleClassName, $modelClassName, $workflowType) { assert('is_string($moduleClassName)'); assert('is_string($modelClassName)'); assert('is_string($workflowType)'); $modelToWorkflowAdapter = ModelRelationsAndAttributesToWorkflowAdapter::make($moduleClassName, $modelClassName, $workflowType); if (!$modelToWorkflowAdapter instanceof ModelRelationsAndAttributesToByTimeWorkflowAdapter) { throw new NotSupportedException(); } $attributes = $modelToWorkflowAdapter->getAttributesForTimeTrigger(); $dataAndLabels = array('' => Zurmo::t('Core', '(None)')); return array_merge($dataAndLabels, WorkflowUtil::renderDataAndLabelsFromAdaptedAttributes($attributes)); }
/** * @param string $moduleClassName * @param string $modelClassName * @return ModelRelationsAndAttributesToWorkflowAdapter based object */ protected function makeModelRelationsAndAttributesToWorkflowAdapter($moduleClassName, $modelClassName) { assert('is_string($moduleClassName)'); assert('is_string($modelClassName)'); return ModelRelationsAndAttributesToWorkflowAdapter::make($moduleClassName, $modelClassName, $this->workflow->getType()); }
/** * @param string $methodToCall * @return array */ protected function resolveActionAttributeFormsAndLabelsAndSortByMethod($methodToCall) { assert('$methodToCall == "getNonRequiredAttributesForActions" || $methodToCall == "getRequiredAttributesForActions" || $methodToCall == "getAllAttributesForActions"'); $modelClassName = $this->getModelClassNameAndResolveForRelations(); $attributeFormsIndexedByAttribute = array(); $adapter = ModelRelationsAndAttributesToWorkflowAdapter::make($modelClassName::getModuleClassName(), $modelClassName, $this->_workflowType); foreach ($adapter->{$methodToCall}() as $attribute => $data) { if ($this->hasActionAttributeFormByName($attribute)) { $attributeFormsIndexedByAttribute[$attribute] = $this->getActionAttributeFormByName($attribute); } else { $attributeFormsIndexedByAttribute[$attribute] = $this->makeActionAttributeFormByAttribute($attribute); } if ($methodToCall == 'getRequiredAttributesForActions') { $attributeFormsIndexedByAttribute[$attribute]->shouldSetValue = true; } $additionalLabelContent = $this->resolveTooltipHelpContentByElementType($adapter->getModel(), $attribute); $attributeFormsIndexedByAttribute[$attribute]->setDisplayLabel($data['label'] . $additionalLabelContent); } $this->resolvePermissionsAttributeForm($modelClassName, $methodToCall, $attributeFormsIndexedByAttribute); return $attributeFormsIndexedByAttribute; }
/** * @return array */ public function getRelationValuesAndLabels() { $modelClassName = $this->modelClassName; $adapter = ModelRelationsAndAttributesToWorkflowAdapter::make($modelClassName::getModuleClassName(), $modelClassName, $this->workflowType); $valueAndLabels = array(); foreach ($adapter->getSelectableContactRelationsDataForEmailMessageRecipientModelRelation() as $relation => $data) { $valueAndLabels[$relation] = $data['label']; } return $valueAndLabels; }
/** * @param array $attributeAndRelationData * @param $modelClassName * @return string $lastModelClassName */ protected function resolvePenultimateModelClassNameFromData(array $attributeAndRelationData, $modelClassName) { assert('count($attributeAndRelationData) > 0'); array_pop($attributeAndRelationData); foreach ($attributeAndRelationData as $relationOrAttribute) { $lastModelClassName = $modelClassName; $modelToWorkflowAdapter = ModelRelationsAndAttributesToWorkflowAdapter::make($modelClassName::getModuleClassName(), $modelClassName, $this->workflowType); if ($modelToWorkflowAdapter->isUsedAsARelation($relationOrAttribute)) { $modelClassName = $modelToWorkflowAdapter->getRelationModelClassName($relationOrAttribute); } } return $lastModelClassName; }