extracting form properties

@return array
430189
public function extractForm($className = null)
    {
        $traced   = $this->findTraced($className);
        $form     = $traced['args'][1]['form'];
        $controls = [];

        foreach ($form->fieldsets as $fieldset) {
            foreach ($fieldset->controls as $control) {
                $controls[$control->name] = $this->resolveFieldValue($control->name, $form->row, $control);
            }
        }
        $this->extractHiddens($controls, $form->hiddens);

        $name = $this->extractModuleName($traced);
        $name = str_replace('_', '-', $name);
        $name = str_replace('components/', 'antaresproject/component-', $name);

        $memory = app('antares.memory')->get("extensions.active.{$name}");
        if (is_null($memory)) {
            $memory = ['fullname' => 'core'];
        }
        $component = Component::findOneByName($memory['fullname']);


        $attributes = [
            'component_id' => $component->id,
            'component'    => $name,
            'controls'     => $controls
        ];
        return $attributes;
    }
93701
public function getForm() {
		$form = new Form();
		
		$useBlacklist = (count($this->propertyBlacklist) > 0) ? true : false;
		$useWhitelist = (count($this->propertyWhitelist) > 0) ? true : false;
		
		$properties = EntityReader::getProperties($this->entityNamespace);
		foreach ($properties as $property) {
			$name = $property->getName();
			if (($useWhitelist && !in_array($name, $this->propertyWhitelist)) || ($useBlacklist && in_array($name, $this->propertyBlacklist))) {
				continue;
			}
			
			switch ($property->getType()) {
				case Property::PROPERTY_TYPE_COLUMN:
					if (!($property->getAnnotation() instanceof \Doctrine\ORM\Mapping\Id)) {
						$this->addColumnElementToForm($form, $property);
					}
					break;
				case Property::PROPERTY_TYPE_REF_ONE:
					$this->addSingleSelecterElementToForm($form, $property);
					break;
				case Property::PROPERTY_TYPE_REF_MANY:
					$this->addMultiSelecterElementToForm($form, $property);
					break;
				default:
					continue 2;
			}
		}
		
		$submit = new Submit('save');
		$submit->setValue('save');
		$form->add($submit);
		
		return $form;
	}
1142013
def get_attributes(self):
        
        items = {}
        items['form_method'] = self.form_method.strip()
        items['form_tag'] = self.form_tag
        items['form_style'] = self.form_style.strip()
        
        if self.form_action:
            items['form_action'] = self.form_action.strip()
        if self.form_id:
            items['id'] = self.form_id.strip()
        if self.form_class:
            items['class'] = self.form_class.strip()
        if self.inputs:
            items['inputs'] = self.inputs
        if self.form_error_title:
            items['form_error_title'] = self.form_error_title.strip()
        if self.formset_error_title:
            items['formset_error_title'] = self.formset_error_title.strip()
        return items
236565
protected static function define_properties() : array {
        return array(
                'name' => [
                        'type' => PARAM_TEXT,
                ],
                'shortname' => [
                        'type' => PARAM_TEXT,
                ],
                'type' => [
                        'type' => PARAM_PLUGIN,
                ],
                'description' => [
                        'type' => PARAM_RAW,
                        'optional' => true,
                        'default' => null,
                        'null' => NULL_ALLOWED
                ],
                'descriptionformat' => [
                        'type' => PARAM_INT,
                        'default' => FORMAT_MOODLE,
                        'optional' => true
                ],
                'sortorder' => [
                        'type' => PARAM_INT,
                        'optional' => true,
                        'default' => -1,
                ],
                'categoryid' => [
                        'type' => PARAM_INT
                ],
                'configdata' => [
                        'type' => PARAM_RAW,
                        'optional' => true,
                        'default' => null,
                        'null' => NULL_ALLOWED
                ],
        );
    }
448264
function getFormFields(form) {
  // Grab all fields that are enabled, and return them as an array.
  // If enabled, remove that property and apply the field name.
  var fields = Object.keys(form.fields).reduce(function (result, fieldKey) {
    var field = _.clone(form.fields[fieldKey]);

    if (!field.enabled) {
      return result;
    }

    // Append the field to field order in case it's not present.
    if (form.fieldOrder.indexOf(fieldKey) === -1) {
      form.fieldOrder.push(fieldKey);
    }

    field.name = fieldKey;
    delete field.enabled;

    result.push(field);

    return result;
  }, []);

  // Sort fields by the defined fieldOrder.
  // Fields that are not in fieldOrder will be placed at the end of the array.
  fields.sort(function (a, b) {
    var indexA = form.fieldOrder.indexOf(a.name);
    var indexB = form.fieldOrder.indexOf(b.name);

    if (indexA === -1) {
      return 0;
    }

    if (indexB === -1) {
      return -1;
    }

    if (indexA > indexB) {
      return 1;
    }

    if (indexA < indexB) {
      return -1;
    }

    return 0;
  });

  return fields;
}
1302350
public function formProperties()
    {
        $form = $this->form();
        $obj  = $form->obj();

        $availableProperties = $obj->properties();
        $sidebarProperties   = $this->sidebarProperties();
        $propertiesOptions   = $this->propertiesOptions();

        foreach ($sidebarProperties as $propertyIdent) {
            if (!$obj->hasProperty($propertyIdent)) {
                continue;
            }

            $property = $obj->property($propertyIdent);
            $value    = $obj->propertyValue($propertyIdent);

            $formProperty = $form->createFormProperty();
            $formProperty->setOutputType($formProperty::PROPERTY_DISPLAY);
            $formProperty->setShowNotes(false);
            $formProperty->setViewController($form->viewController());

            $formProperty->setProperty($property);
            $formProperty->setPropertyIdent($property->ident());
            $formProperty->setPropertyVal($obj[$propertyIdent]);

            if (!empty($propertiesOptions[$propertyIdent])) {
                $propertyOptions = $propertiesOptions[$propertyIdent];

                if (is_array($propertyOptions)) {
                    $formProperty->setData($propertyOptions);
                }
            }

            if (!empty($formProperty['required_acl_permissions']) && $this instanceof AuthAwareInterface) {
                $formProperty['active'] = $this->hasPermissions($formProperty['required_acl_permissions']);
                if (!$this->hasPermissions($formProperty['required_acl_permissions'])) {
                    continue;
                }
            }

            yield $propertyIdent => $formProperty;
        }
    }
67485
protected static function define_other_properties() {
        return [
            'id' => ['type' => PARAM_INT],
            'state' => [
                'type' => [
                    'groupmode' => ['type' => PARAM_INT],
                ],
            ],
            'userstate' => [
                'type' => [
                    'tracked' => ['type' => PARAM_INT],
                ],
            ],
            'capabilities' => [
                'type' => [
                    'viewdiscussions' => ['type' => PARAM_BOOL],
                    'create' => ['type' => PARAM_BOOL],
                    'subscribe' => ['type' => PARAM_BOOL],
                ]
            ],
            'urls' => [
                'type' => [
                    'create' => ['type' => PARAM_URL],
                    'markasread' => ['type' => PARAM_URL],
                    'view' => ['type' => PARAM_URL],
                    'sortrepliesasc' => ['type' => PARAM_URL],
                    'sortrepliesdesc' => ['type' => PARAM_URL],
                    'sortlastpostasc' => ['type' => PARAM_URL],
                    'sortlastpostdesc' => ['type' => PARAM_URL],
                    'sortcreatedasc' => ['type' => PARAM_URL],
                    'sortcreateddesc' => ['type' => PARAM_URL],
                ],
            ],
        ];
    }
1256325
protected static function define_properties() {
        return array(
            'name' => array(
                'type' => PARAM_TEXT,
            ),
            'description' => array(
                'type' => PARAM_CLEANHTML,
                'default' => ''
            ),
            'descriptionformat' => array(
                'choices' => array(FORMAT_HTML, FORMAT_MOODLE, FORMAT_PLAIN, FORMAT_MARKDOWN),
                'type' => PARAM_INT,
                'default' => FORMAT_HTML,
            ),
            'userid' => array(
                'type' => PARAM_INT,
            ),
            'templateid' => array(
                'type' => PARAM_INT,
                'default' => null,
                'null' => NULL_ALLOWED,
            ),
            'origtemplateid' => array(
                'type' => PARAM_INT,
                'default' => null,
                'null' => NULL_ALLOWED,
            ),
            'status' => array(
                'choices' => array(self::STATUS_DRAFT, self::STATUS_COMPLETE, self::STATUS_ACTIVE,
                    self::STATUS_WAITING_FOR_REVIEW, self::STATUS_IN_REVIEW),
                'type' => PARAM_INT,
                'default' => self::STATUS_DRAFT,
            ),
            'duedate' => array(
                'type' => PARAM_INT,
                'default' => 0,
            ),
            'reviewerid' => array(
                'type' => PARAM_INT,
                'default' => null,
                'null' => NULL_ALLOWED,
            )
        );
    }
125530
protected static function define_properties() {
        return array(
            'userid' => array(
                'type' => PARAM_INT,
            ),
            'competencyid' => array(
                'type' => PARAM_INT,
            ),
            'proficiency' => array(
                'type' => PARAM_BOOL,
                'default' => null,
                'null' => NULL_ALLOWED,
            ),
            'grade' => array(
                'type' => PARAM_INT,
                'default' => null,
                'null' => NULL_ALLOWED,
            ),
            'planid' => array(
                'type' => PARAM_INT,
            ),
            'sortorder' => array(
                'type' => PARAM_INT,
                'default' => 0,
            ),
        );
    }
424007
public function getForm()
    {
        $elementString = '';

        if (isset($this->attributes[self::$formHolder[self::$formName]])) {
            $elementString .= $this->attributes[self::$formHolder[self::$formName]][self::$formName];
        }

        $elementString .= $this->getHtmlElements();

        $close = null;
        $close = self::$formHolder[self::$formName].'_close';

        if (isset($this->attributes[$close])) {
            $elementString .= $this->attributes[$close];
        }

        return $this->element[self::$formHolder[self::$formName]] = $elementString;
    }
676401
public static function get_mandatory_properties() {
        $properties = self::define_properties();
        $mandatoryproperties = array_filter($properties, function($property) {
            return empty($property['optional']);
        });
        return array_keys($mandatoryproperties);
    }
1139771
protected static function define_properties() {
        return [
            'id' => [
                'type' => PARAM_INT,
                'description' => 'Badge id',
            ],
            'name' => [
                'type' => PARAM_TEXT,
                'description' => 'Badge name',
            ],
            'version' => [
                'type' => PARAM_TEXT,
                'description' => 'Version',
                'optional' => true,
                'null' => NULL_ALLOWED,
            ],
            'language' => [
                'type' => PARAM_NOTAGS,
                'description' => 'Language',
                'optional' => true,
                'null' => NULL_ALLOWED,
            ],
            'type' => [
                'type' => PARAM_INT,
                'description' => 'Type',
                'optional' => true,
            ],
        ];
    }
281225
public function formToArray($form)
    {
        $result = [];
        if (preg_match_all('/<input[^>]*>/sm', $form, $inputs) !== false) {
            foreach ($inputs[0] as $input) {
                if (preg_match('/name=["\']([^"\']*)["\']\s+value=["\']([^"\']*)["\']/', $input, $match) !== false) {
                    if (count($match) === 3) {
                        $result[$match[1]] = $match[2];
                    }
                }
            }
        }

        return $result;
    }
943711
protected static function define_other_properties() {
        return [
            'foruser' => [
                'type' => user_summary_exporter::read_properties_definition(),
            ],
            'requestedbyuser' => [
                'type' => user_summary_exporter::read_properties_definition(),
                'optional' => true
            ],
            'dpouser' => [
                'type' => user_summary_exporter::read_properties_definition(),
                'optional' => true
            ],
            'messagehtml' => [
                'type' => PARAM_RAW,
                'optional' => true
            ],
            'typename' => [
                'type' => PARAM_TEXT,
            ],
            'typenameshort' => [
                'type' => PARAM_TEXT,
            ],
            'statuslabel' => [
                'type' => PARAM_TEXT,
            ],
            'statuslabelclass' => [
                'type' => PARAM_TEXT,
            ],
            'canreview' => [
                'type' => PARAM_BOOL,
                'optional' => true,
                'default' => false
            ],
            'approvedeny' => [
                'type' => PARAM_BOOL,
                'optional' => true,
                'default' => false
            ],
            'canmarkcomplete' => [
                'type' => PARAM_BOOL,
                'optional' => true,
                'default' => false
            ],
        ];
    }
1103798
public function keyValues($form = null)
    {
        if (null === $this->configs) {
            $this->loadConfigs();
        }

        $keys = ($form) ? call_user_func([$form, 'getFields']) : [];

        $array = [];
        foreach ($this->configs as $key => $config) {
            if ($form && !in_array($key, $keys)) {
                continue;
            }

            $array[$key] = $config->getValue();
        }

        return $array;
    }
985432
protected function processProperties() {

		$ret = '';

		if ($this->required and (!isset($this->type) or (isset($this->type) and 'bool' != $this->type))) {
			$ret .= ' required';
		}

		if ($this->disabled) {
			$ret .= ' disabled';
		}

		if ($this->readonly) {
			$ret .= ' readonly';
		}

		if ($this->placeholder) {
			$ret .= ' placeholder="' . $this->placeholder . '"';
		}
		
		// CSS classes
		if (count($this->class)) {
			$ret .= ' class="' . implode(' ', $this->class) . '"';
		}
		
		// misc tag attributes
		foreach ($this->attributes as $attr=>$val) {
			$ret .= ' ' . $attr . '="' . addslashes($val) . '"';
		}
		
		return $ret;

	}
509520
protected function parsedFormProperties()
    {
        if ($this->parsedFormProperties === null) {
            $this->finalizeStructure();

            $groupProperties     = $this->groupProperties();
            $availableProperties = $this->structProperties();

            $structProperties = [];
            if (!empty($groupProperties)) {
                foreach ($groupProperties as $propertyIdent => $propertyMetadata) {
                    if (is_string($propertyMetadata)) {
                        $propertyIdent    = $propertyMetadata;
                        $propertyMetadata = null;
                    }

                    if (!isset($availableProperties[$propertyIdent])) {
                        continue;
                    }

                    if (is_array($propertyMetadata)) {
                        $propertyMetadata = array_merge($propertyMetadata, $availableProperties[$propertyIdent]);
                    } else {
                        $propertyMetadata = $availableProperties[$propertyIdent];
                    }

                    $structProperties[$propertyIdent] = $propertyMetadata;
                }
            }

            if (empty($structProperties)) {
                $structProperties = $availableProperties;
            }

            $this->parsedFormProperties = $structProperties;
        }

        return $this->parsedFormProperties;
    }