Sets definition data for form creation

@param mixed $definitions

@return self|$this|ParserInterface
184780
public function setData($definitions)
    {
        if (is_array($definitions)) {
            $this->parsedData = $definitions;
            return;
        }

        if (!is_file($definitions)) {
            throw new InvalidArgumentException(
                "The form definition file '{$definitions}' does not exists."
            );
        }

        try {
            $this->parsedData = Yaml::parse(file_get_contents($definitions));
        } catch (\Exception $caught) {
            throw new ParserErrorException(
                'Error parsing form definitions: '.$caught->getMessage(),
                0,
                $caught
            );
        }
    }
998131
public function setDefinition(EntityStructure $definition)
    {
        $tmp = new \ReflectionProperty(entity::class, 'definition');
        $tmp->setAccessible(true);
        $tmp->setValue($this->entity, $definition);
    }
9484
static protected function createResources($definitions) {
		$resources = [];
		
		foreach ($definitions as $name => $options) {
			if (! isset($options['type'])) {
				throw new InvalidOptions('Type of resource must be specified');
			}
			
			$class = self::NAMESPACE_RESOURCE . '\\' . ucfirst($options['type']);
			unset($options['type']);
			
			$resources[$name] = new $class($options);
		}
		
		return $resources;
	}
669537
public function merge($definition)
    {
        $constraints = $this->explodeConstraints($definition);

        foreach ($constraints as $index=>$definition) {

            list($name, $parameters) = is_array($definition) ?
                                       [$index, $definition] :
                                       $this->nameAndParameters($definition);

            $constraint = $this->newConstraint(
                Type::snake_case($name),
                $parameters,
                ''
            );
            $this->constraints[$constraint->name()] = $constraint;

        }
        return $this;
    }
1197594
public static function createFromFieldset($definition)
    {
        $definition = self::parseDefinition($definition);
        $root       = new Group();
        $group      = $root;

        /** @var bool|Dropdown $dropdown */
        $dropdown = false;
        $first    = true;

        foreach ($definition as $button) {
            // dont add empty items
            if (self::isInvalidDefinition($button)) {
                continue;
            }

            // encode value
            $button = self::encodeValue($button);

            // finish dropdown
            if (self::hasToCloseDropdown($dropdown, $button)) {
                $dropdown = false;
            }

            if (in_array($button['type'], array('group', 'vgroup'))) {
                // create new group
                $group = self::createNewGroup($root, $button, $dropdown, !$first);
            } elseif ($button['type'] == 'dropdown') {
                // create dropdown

                $dropdown      = static::createDropdown($button['label'], $button['attributes'], true);
                $dropdownGroup = static::createGroup();
                $dropdownGroup->addChild($dropdown);

                $group->addChild($dropdownGroup);
            } elseif ($button['type'] == 'child' || $button['type'] == 'header') {
                // add dropdown child

                static::parseDropdownChild($dropdown, $button);
            } elseif ($dropdown !== false) {
                $child = static::createDropdownItem($button['label'], $button['url'], $button['attributes'], true);
                $dropdown->addChild($child);
            } else {
                $child = static::createButton($button['label'], $button['url'], $button['attributes'], true);
                $group->addChild($child);
            }

            $first = false;
        }

        return $root;
    }
1043226
public function setDefinition($definition) {
        if ($definition instanceof Definition) {
            $this->definition = $definition;
        }
        else {
            $this->definition->setDefinition($definition);
        }

        $this->consoleDefinitionMerged = false;

        return $this;
    }
417083
protected function fillObjectValidators($definitions, $validators)
    {
        foreach ($definitions as $class => $definition) {
            foreach ($definition->validators['properties'] as $property => $validatorsDefinitions) {
                foreach ($validatorsDefinitions as $validatorDefinition) {
                    if ($validatorDefinition instanceof ObjectReferenceDefinition) {
                        $validator = $validators[$class];
                        $propertyValidators = $validator->getValidators();
                        $propertyValidators[$property] = $validators[$validatorDefinition->class];
                        $validator->setValidators($propertyValidators);
                    }
                }
            }
        }

        return $validators;
    }
257382
private function _initType($definition)
    {
        if (isset(self::$typeAliases[$definition])) {
            $definition = self::$typeAliases[$definition];
        }

        if (self::isScalarType($definition)
            || in_array(
                $definition,
                [self::TYPE_ARRAY, self::TYPE_DATE, self::TYPE_DATETIME],
                true
            )
        ) {
            // Scalar, array, date, datetime

            $this->type = $definition;
        } elseif (class_exists(Convention::nameToClass($definition, Convention::ENTITY_MASK))) {
            // Entity

            $this->type = self::TYPE_ENTITY;
            $this->typeOption = $definition;
        } elseif (substr($definition, -2) === "[]") {
            // Collection

            $this->type = self::TYPE_COLLECTION;
            $this->typeOption = rtrim($definition, "[]");
        } else {
            throw new Exception\PropertyException(
                "Unsupported type '" . $definition . "'!"
            );
        }
    }
227827
public function setDefinition($reportDefinition)
    {
        if ($reportDefinition instanceof ReportDefinitionBuilder) {
            $reportDefinition = $reportDefinition->build();
        }

        $this->definition = $reportDefinition;

        return $this;
    }
73738
public function load(array $definitions)
    {
        $this->data = $definitions['data'] ?? [];
        $this->parentAliases = $definitions['parent_aliases'] ?? [];
        foreach ($this->data as $value) {
            $this->validateDefinitions($value);
        }
    }
35498
protected function _init($definition=null)
    {

        if (!is_null($definition)) {
            $this->_packageXml = simplexml_load_string($definition);
        } else {
            $packageXmlStub = <<<END
<?xml version="1.0"?>
<package>
    <name />
    <version />
    <stability />
    <license />
    <channel />
    <extends />
    <summary />
    <description />
    <notes />
    <authors />
    <date />
    <time />
    <contents />
    <compatible />
    <dependencies />
</package>
END;
            $this->_packageXml = simplexml_load_string($packageXmlStub);
        }
        return $this;
    }
596747
private static function parseDefinitions(array $definitions): array
    {
        if (\count($definitions) === 0) {
            return $definitions;
        }

        return \array_map(
            function ($definition) {
                if (\is_array($definition)) {
                    return $definition;
                }

                return self::loadDefinitionsFromPath($definition);
            },
            $definitions
        );
    }
801363
protected function createTaxRateFromDefinition(array $definition)
    {
        $rate = new TaxRate();
        $setValues = \Closure::bind(function ($definition) {
            $this->id = $definition['id'];
            $this->name = $definition['name'];
            if (isset($definition['default'])) {
                $this->default = $definition['default'];
            }
        }, $rate, '\CommerceGuys\Tax\Model\TaxRate');
        $setValues($definition);

        foreach ($definition['amounts'] as $amountDefinition) {
            $amount = $this->createTaxRateAmountFromDefinition($amountDefinition);
            $rate->addAmount($amount);
        }

        return $rate;
    }
901746
public function build($definition)
    {
        if (is_callable($definition)) {
            return call_user_func($definition, $this);
        }

        return $this->buildFromDefinition($definition);
    }
298115
private function importFromDefinitions(array $dataTypes, array $definitions)
    {
        foreach ($dataTypes as $dataTypeHandle) {
            $dataType = $this->module->getDataType($dataTypeHandle);
            if (null == $dataType) {
                continue;
            }

            $mapper = $dataType->getMapperHandle();
            if (!$this->module->checkMapper($mapper)) {
                continue;
            }

            Schematic::info('Importing '.$dataTypeHandle);
            Schematic::$force = $this->force;
            if (array_key_exists($dataTypeHandle, $definitions) && is_array($definitions[$dataTypeHandle])) {
                $records = $dataType->getRecords();
                try {
                    $this->module->$mapper->import($definitions[$dataTypeHandle], $records);
                    $dataType->afterImport();
                } catch (WrongEditionException $e) {
                    Schematic::error('Craft Pro is required for datatype '.$dataTypeHandle);
                }
            }
        }
    }
1093803
public function createDictionary(DictionaryDefinition $definition): DictionaryInterface
    {
        $builder = $this->getDictionaryBuilder($definition);

        /** @var DictionaryBuilderInterface $builder */
        return $builder->build($this, $definition);
    }
831430
public function setAlias($aliasName, $definition = '')
    {
        if (is_array($aliasName) && !empty($aliasName)) {

            foreach ($aliasName as $id => $item) {
                $this->_alias[$id] = array(
                    'class' => $item,
                    'params' => '',
                    'type' => self::TYPE_DEFINITION_STRING,
                );

                $this->_definitions[$id] = $item;
            }

        } else {

            $aliasName = strtolower($aliasName);
            $this->_alias[$aliasName] = array(
                'class' => $definition,
                'params' => '',
                'type' => self::TYPE_DEFINITION_STRING,
            );

            $this->_definitions[$aliasName] = $definition;

        }

        return $this;
    }