/** * Dynamically generate rules based on policyRules * @return array of rules */ public function rules() { assert('!empty($this->data)'); $rules = array(); foreach ($this->data as $moduleClassName => $policies) { foreach ($policies as $policy => $policyInformation) { $policyRules = PolicyRulesFactory::createPolicyRulesByModuleClassNameAndPolicyInformation($moduleClassName, $policy, $policyInformation['explicit'], $policyInformation['inherited']); $rules = array_merge($rules, $policyRules->getFormRules()); } } return $rules; }
/** * @return - element array or null if the element should not be added to the metadata. */ protected static function getElementInformation($moduleClassName, $policy, $policyInformation) { $rules = PolicyRulesFactory::createPolicyRulesByModuleClassNameAndPolicyInformation($moduleClassName, $policy, $policyInformation['explicit'], $policyInformation['inherited']); if (!$rules->showInView()) { return null; } if ($rules->isElementTypeDerived()) { $attributeName = 'null'; } else { $attributeName = FormModelUtil::getDerivedAttributeNameFromTwoStrings($moduleClassName, $policy); } $element = array('attributeName' => $attributeName, 'type' => $rules->getElementAttributeType()); return $element; }