Retrieve the object's properties as form controls.

@param  array $group An optional group to use.
@throws UnexpectedValueException If a property data is invalid.
@return DocFormPropertyWidget[]|Generator
974918
public function formProperties(array $group = null)
    {
        $obj = $this->obj();
        $props = $obj->metadata()->properties();

        // We need to sort form properties by form group property order if a group exists
        if (!empty($group)) {
            $props = array_merge(array_flip($group), $props);
        }

        foreach ($props as $propertyIdent => $propertyMetadata) {
            if (method_exists($obj, 'filterPropertyMetadata')) {
                $propertyMetadata = $obj->filterPropertyMetadata($propertyMetadata, $propertyIdent);
            }

            if (!is_array($propertyMetadata)) {
                throw new UnexpectedValueException(sprintf(
                    'Invalid property data for "%1$s", received %2$s',
                    $propertyIdent,
                    (is_object($propertyMetadata) ? get_class($propertyMetadata) : gettype($propertyMetadata))
                ));
            }

            $propertyMetadata['display_options'] = $this->displayOptions();

            $formProperty = $this->createFormProperty();
            $formProperty->setViewController($this->viewController());
            $formProperty->setPropertyIdent($propertyIdent);
            $formProperty->setData($propertyMetadata);
            $formProperty->setPropertyVal($obj[$propertyIdent]);

            if ($formProperty->hidden()) {
                $this->hiddenProperties[$propertyIdent] = $formProperty;
            } else {
                yield $propertyIdent => $formProperty;
            }
        }
    }
313547
public function get($writer)
    {
        if (!array_key_exists($writer, $this->writers)) {
            throw new UnexpectedValueException('Unknown writer [' . $writer . ']');
        }

        if (count($this->writers[$writer]) == 1) {
            return reset($this->writers[$writer]);
        }

        return $this->writers[$writer];
    }
58075
protected function processNestedGroups($group)
    {
        $data = [];

        if (isset($group['fields']) && is_array($group['fields'])) {
            foreach ($group['fields'] as $fieldName => $field) {
                if (!empty($field['value'])) {
                    $data['fields'][$fieldName] = ['value' => $field['value']];
                }
            }
        }

        if (isset($group['groups']) && is_array($group['groups'])) {
            foreach ($group['groups'] as $groupName => $groupData) {
                $nestedGroup = $this->processNestedGroups($groupData);
                if (!empty($nestedGroup)) {
                    $data['groups'][$groupName] = $nestedGroup;
                }
            }
        }

        return $data;
    }
427592
public function serialize(Group $group, array $options = [])
    {
        return [
            'id' => $group->getUuid(),
            'name' => $group->getName(),
            'roles' => array_map(function (Role $role) use ($options) {
                return $this->roleSerializer->serialize($role, $options);
            }, $group->getEntityRoles()->toArray()),
            'organizations' => array_map(function (Organization $organization) use ($options) {
                return $this->organizationSerializer->serialize($organization, $options);
            }, $group->getOrganizations()->toArray()),
        ];
    }
1283549
public function getGroupControls(string $group): array
    {
        return array_filter($this->controls, function (Control $control) use ($group) {
            return $control->getGroup() === $group;
        });
    }
985286
protected function getAttributeFrom()
    {
        $attribute = array_get($this->formFieldData->options(), 'from', $this->formFieldData->source());

        if ( ! $attribute) {
            throw new UnexpectedValueException("DateRangeStrategy must have 'date_from' option set");
        }

        return $attribute;
    }
364357
protected function getItemsData($object, string $format = null, array $context = []): array
    {
        $data = [];

        foreach ($object as $obj) {
            $item = $this->normalizer->normalize($obj, $format, $context);
            if (!\is_array($item)) {
                throw new UnexpectedValueException('Expected item to be an array');
            }
            $data['_embedded']['item'][] = $item;
            $data['_links']['item'][] = $item['_links']['self'];
        }

        return $data;
    }
134784
public function group($group){
        if(is_array($group)){
            $this->group= 'GROUP BY ';
            foreach ($group as $value) {
                $this->group .= $value.',';
            }
            $this->group= rtrim($this->group, ',');
            $this->group.=' ';
        }else{
            $this->group= 'GROUP BY '.$group.' ';
        }
    }
207614
public function groupBy($group=null)
    {
        $group = LambdaUtils::toSelectCallable($group);

        $result = new ObjectArray(array());
        if($this instanceof ObjectArray)
        {
            $result = $this->newInstance();
        }

        foreach($this as $record)
        {
            $key = call_user_func($group, $record);

            $data = array();
            if($this->__converter instanceof IListConverter)
            {
                $data = $this->newConverterInstance();
            }
            $newitemtype = new ArrayList($data);

            $result->get($key, $newitemtype, true)->add($record);
        }

        return $result;
    }
612553
public function getConfigurable($group = null)
    {
        if (empty($this->configurable)) {
            foreach ($this->customfields as $category => $customfield) {
                foreach ($customfield as $field) {
                    if (!$field->configurable()) {
                        continue;
                    }
                    $this->configurable[strtolower(last(explode('\\', $category)))][] = $field->getName();
                }
            }
        }
        return !is_null($group) ? array_get($this->configurable, $group, []) : $this->configurable;
    }
661942
public function setGroup($group)
    {
        //Argument 1 must be a string or array
        Argument::i()->test(1, 'string', 'array');
            
        if (is_string($group)) {
            $group = array($group);
        }
        
        $this->group = $group;
        return $this;
    }
886144
public function init($group)
	{
		// Lets validate if the post type exists and if so, continue.
		$postTypeModel = $this->getPostType($group);
		if(!$postTypeModel){
    		$errorMessages = 'You are not authorized to do this.';
    		return $this->abort($errorMessages);
    	}

		// Receiving the current data of the group
		$config = NikuConfig::where('group', '=', $group)
			->get()
			->keyBy('option_name')
			->toArray();

		$templates = $postTypeModel->view;

		// Appending the key added in the config to the array
        // so we can use it very easliy in the component.
        foreach($templates as $key => $template){

	    	if(!empty($template['customFields'])){

	    		// For each custom fields
	            foreach($template['customFields'] as $ckey => $customField){
	                $templates[$key]['customFields'][$ckey]['id'] = $ckey;

	                // Adding the values to the result
	            	if(!empty($config[$ckey])){
	            		$templates[$key]['customFields'][$ckey]['value'] = $config[$ckey]['option_value'];
	            	}
	            }
	        }
	    }

		$collection = collect([
			'config' => $this->getConfig($postTypeModel),
			'templates' => $templates,
		]);

		return response()->json($collection);
	}
550645
protected function createFormGroup(array $data = null)
    {
        if (isset($data['type'])) {
            $type = $data['type'];
        } else {
            $type = $this->defaultGroupType();
        }

        $group = $this->formGroupFactory()->create($type);
        $group->setForm($this->formWidget());

        if ($data !== null) {
            $group->setData($data);
        }

        return $group;
    }
966412
public function getRuleResultsByGroup($group)
    {
        $results = [];
        foreach ($this->getRuleResults() as $rule => $ruleResult) {
            if (in_array($group, $ruleResult->getGroups())) {
                $results[$rule] = $ruleResult;
            }
        }

        return $results;
    }
871365
public static function formatConfig($config)
    {
        if (\is_string($config)) {
            $config = ['file' => $config];
        }

        if (!\is_array($config)) {
            throw new UnexpectedTypeException($config, 'array');
        }

        if (!isset($config['file'])) {
            $msg = 'The "file" attribute must be defined in config of layout template';

            throw new InvalidConfigurationException($msg);
        }

        return $config;
    }
270909
private function getValue(array $values, $languages, $group, $parent = NULL)
    {
    	foreach($values as $key => $value){

			foreach($languages as $language){
				$entry = Translation::firstOrCreate([
					'key' => $key,
					'language' => $language,
					'translation_group' => $group->id,
					'parent' => $parent
				]);
				if(is_array($value)){
					$this->getValue($value, $languages, $group, $entry->id);
				} else {
					if($entry->value === NULL){
						$entry->value = $value;
						$entry->save();
					}
				}
			}
	    }
    }
1053394
public function asObjectDescriptor(): Primitive\ObjectDescriptor
    {
        if (!$this->_element instanceof Primitive\ObjectDescriptor) {
            throw new \UnexpectedValueException(
                $this->_generateExceptionMessage(
                    Element::TYPE_OBJECT_DESCRIPTOR));
        }
        return $this->_element;
    }