protected function resolveSettingAttributesForSubscribeToListType($valuesAttributes) { assert('$this->type != null'); foreach ($valuesAttributes as $attribute => $attributeData) { if ($this->type == self::TYPE_SUBSCRIBE_TO_LIST || $this->type == self::TYPE_UNSUBSCRIBE_FROM_LIST) { $form = new MarketingListWorkflowActionAttributeForm('MarketingList', 'id'); } else { $resolvedAttributeName = static::resolveRealAttributeName($attribute); $resolvedModelClassName = static::resolveRealModelClassName($attribute, $this->_modelClassName, $this->type, $this->relation, $this->relatedModelRelation); $form = WorkflowActionAttributeFormFactory::make($resolvedModelClassName, $resolvedAttributeName); } $form->setAttributes($attributeData); if ($form->shouldSetValue) { $this->_actionAttributes[$attribute] = $form; } } }
public function testMakePermissions() { $form = WorkflowActionAttributeFormFactory::make('WorkflowModelTestItem', 'permissions'); $this->assertTrue($form instanceof ExplicitReadWriteModelPermissionsWorkflowActionAttributeForm); }
protected function resolvePermissionsAttributeForm($modelClassName, $methodToCall, array &$attributeFormsIndexedByAttribute) { assert('is_string($modelClassName)'); assert('$methodToCall == "getNonRequiredAttributesForActions" || $methodToCall == "getRequiredAttributesForActions" || $methodToCall == "getAllAttributesForActions"'); if (($this->type == self::TYPE_CREATE || $this->type == self::TYPE_CREATE_RELATED) && is_subclass_of($modelClassName, 'OwnedSecurableItem') && ($methodToCall == 'getRequiredAttributesForActions' || $methodToCall == 'getAllAttributesForActions')) { if ($this->hasActionAttributeFormByName('permissions')) { $attributeFormsIndexedByAttribute['permissions'] = $this->getActionAttributeFormByName('permissions'); } else { $attributeFormsIndexedByAttribute['permissions'] = WorkflowActionAttributeFormFactory::make($modelClassName, 'permissions'); if ($methodToCall == 'getRequiredAttributesForActions') { $attributeFormsIndexedByAttribute['permissions']->shouldSetValue = true; } } } }