Hydrate definition tags from entity into definition array.

@param Definition $definition       the definition to convert
@param array      $definitionArray the definition array (passed by reference)
557778
private function hydrateDefinitionTags(Definition $definition, array &$definitionArray)
    {
        foreach ($definition->getTags() as $key => $tag) {
            $definitionTag = [
                'name' => $key,
            ];

            foreach (array_shift($tag) as $key => $option) {
                $definitionTag[$key] = $option;
            }

            $definitionArray['tags'][] = $definitionTag;
        }
    }
1143206
private function setDefinitionProperties(Definition $definition, array $array)
    {
        if (isset($array['public'])) {
            $definition->setPublic($array['public']);
        }

        if (isset($array['abstract'])) {
            $definition->setAbstract($array['abstract']);
        }

        if (isset($array['scope'])) {
            $definition->setScope($array['scope']);
        }

        if (isset($array['file'])) {
            $definition->setFile($array['file']);
        }
    }
980111
private function defineCollection($name, $definition)
    {
        // prepare definition object
        if (false === ($definition instanceof Definition)) {
            if (is_string($definition)) {
                $definition = new Definition(array('class' => $definition));
            } elseif (is_array($definition)) {
                $definition = new Definition($definition);
            } else {
                throw new Exception(sprintf('Wrong definition passed for collection %s', $name));
            }
        }

        // set definition
        if ('/' !== substr($name, 0, 1)) {
            $this->mapping[$name] = $definition;
        } else {
            $this->regexpMapping[$name] = $definition;
        }

        return $this;
    }
79673
public function add(DefinitionInterface $definition)
    {
        $index = count($this->_names);
        $this->_definitionSource[$index] = $definition;
        $this->_names[$definition->getName()] = $index;
        return $this;
    }
138990
public function load(\Asgard\Entity\Definition $definition) {
		$this->entityClass = $definition->getClass();

		if(!$definition->has('order_by'))
			$definition->set('order_by', 'id DESC');

		$definition->hook('get', [$this, 'hookGet']);
		$definition->hook('getTranslations', [$this, 'hookgetTranslations']);
		$definition->hook('validation', [$this, 'hookValidation']);
	}
478044
private function hydrateDefinitionConfigurator(Definition $definition, array &$definitionArray)
    {
        if (null !== $configurator = $definition->getConfigurator()) {
            if (is_string($configurator)) {
                $definitionArray['configurator'] = $definition->getConfigurator();
            } else {
                $definitionArray['configurator'] = [$this->convertArgument($configurator[0]), $configurator[1]];
            }
        }
    }
234794
private function convertDefinitionToPhpArray(Definition $definition)
    {
        $definitionArray = [];
        if ($definition->isSynthetic()) {
            $definitionArray = $this->convertSyntheticDefinitionToPhpArray($definition);
        }

        $this->hydrateDefinitionClass($definition, $definitionArray);
        $this->hydrateDefinitionArguments($definition, $definitionArray);
        $this->hydrateDefinitionFactory($definition, $definitionArray);
        $this->hydrateDefinitionTags($definition, $definitionArray);
        $this->hydrateDefinitionMethodCalls($definition, $definitionArray);
        $this->hydrateDefinitionConfigurator($definition, $definitionArray);
        $this->hydrateDefinitionParent($definition, $definitionArray);
        $this->hydrateDefinitionScopeProperty($definition, $definitionArray);
        $this->hydrateDefinitionPublicProperty($definition, $definitionArray);
        $this->hydrateDefinitionAbstractProperty($definition, $definitionArray);
        $this->hydrateDefinitionFileProperty($definition, $definitionArray);

        return $definitionArray;
    }
1168722
private function write_definitions_to_cache(array $definitions) {

        // Preserve the selected sharing option when updating the definitions.
        // This is set by the user and should never come from caches.php.
        foreach ($definitions as $key => $definition) {
            unset($definitions[$key]['selectedsharingoption']);
            unset($definitions[$key]['userinputsharingkey']);
            if (isset($this->configdefinitions[$key]) && isset($this->configdefinitions[$key]['selectedsharingoption'])) {
                $definitions[$key]['selectedsharingoption'] = $this->configdefinitions[$key]['selectedsharingoption'];
            }
            if (isset($this->configdefinitions[$key]) && isset($this->configdefinitions[$key]['userinputsharingkey'])) {
                $definitions[$key]['userinputsharingkey'] = $this->configdefinitions[$key]['userinputsharingkey'];
            }
        }

        $this->configdefinitions = $definitions;
        foreach ($this->configdefinitionmappings as $key => $mapping) {
            if (!array_key_exists($mapping['definition'], $definitions)) {
                unset($this->configdefinitionmappings[$key]);
            }
        }
        $this->config_save();
    }
1025864
private function getInlinedDefinitions(Definition $definition)
    {
        if (false === $this->inlinedDefinitions->contains($definition)) {
            $definitions = array_merge(
                $this->getDefinitionsFromArguments($definition->getArguments()),
                $this->getDefinitionsFromArguments($definition->getMethodCalls()),
                $this->getDefinitionsFromArguments($definition->getProperties()),
                $this->getDefinitionsFromArguments(array($definition->getConfigurator())),
                $this->getDefinitionsFromArguments(array($definition->getFactory()))
            );

            $this->inlinedDefinitions->offsetSet($definition, $definitions);

            return $definitions;
        }

        return $this->inlinedDefinitions->offsetGet($definition);
    }
446090
private function hydrateDefinitionArguments(Definition $definition, array &$definitionArray)
    {
        foreach ($definition->getArguments() as $arg) {
            $definitionArray['arguments'][] = $this->convertArgument($arg);
        }
    }
41124
private function setDefinitionArguments(Definition $definition, array $array)
    {
        if (true === array_key_exists('arguments', $array)) {
            foreach ($array['arguments'] as $arg) {
                $definition->addArgument($this->convertArgument($arg));
            }
        }
    }
466840
private function configureConsumer(Definition $definition, array $tag, array $references)
    {
        if (isset($tag['method'])) {

            if (isset($tag['bulk']) && $tag['bulk']) {
                $definition->addMethodCall($tag['method'], array($references));
            } else {
                foreach ($references as $name => $service) {
                    $definition->addMethodCall($tag['method'], array($service, $name));
                }
            }

        } else {

            if (isset($tag['bulk']) && !$tag['bulk']) {
                foreach ($references as $service) {
                    $definition->addArgument($service);
                }
            } else {
                $definition->addArgument($references);
            }
        }
    }
1286976
public static function reload(array $definitions = [])
    {
        $properties           = self::getProperties();
        $workerDefinitions    = self::getWorkerDefinition();
        $definitions          = ArrayHelper::merge($workerDefinitions, $definitions);

        self::$container->setProperties($properties);
        self::$container->addDefinitions($definitions);
        self::$container->autoloadWorkerAnnotation();

        $componentDefinitions = self::getComponentDefinitions();
        self::$container->addDefinitions($componentDefinitions);

        /* @var Aop $aop Init reload AOP */
        $aop = App::getBean(Aop::class);
        $aop->init();

        self::$container->initBeans();
    }
242047
public function setDefinition($definition)
    {
        if ($definition instanceof Expression) {
            $definition = (string) $definition;
        }

        $this->definition = $definition;
    }
5663
protected function processDefinition($locale, array $definition)
    {
        $definition['locale'] = $locale;
        // The generation script strips all keys that have the same values
        // as the ones in 'en'.
        if ($definition['locale'] != 'en') {
            $definitions = $this->getDefinitions();
            $definition += $definitions['en'];
        }

        return $definition;
    }
18690
private function merge(DataValidationDefinition $definition, DataValidationDefinition $profileDefinition): void
    {
        foreach ($profileDefinition->getProperties() as $key => $constraints) {
            $parameters = [];
            $parameters[] = $key;
            $parameters = array_merge($parameters, $constraints);

            call_user_func_array([$definition, 'add'], $parameters);
        }
    }
153411
protected function createTaxTypeFromDefinition(array $definition)
    {
        // Load the referenced zone.
        $definition['zone'] = $this->zoneRepository->get($definition['zone']);
        // Provide defaults.
        if (!isset($definition['compound'])) {
            $definition['compound'] = false;
        }
        if (!isset($definition['display_inclusive'])) {
            $definition['display_inclusive'] = false;
        }
        if (!isset($definition['rounding_mode'])) {
            $definition['rounding_mode'] = PHP_ROUND_HALF_UP;
        }

        $type = new TaxType();
        // Bind the closure to the TaxType object, giving it access to
        // its protected properties. Faster than both setters and reflection.
        $setValues = \Closure::bind(function ($definition) {
            $this->id = $definition['id'];
            $this->name = $definition['name'];
            $this->compound = $definition['compound'];
            $this->displayInclusive = $definition['display_inclusive'];
            $this->roundingMode = $definition['rounding_mode'];
            $this->zone = $definition['zone'];
            if (isset($definition['generic_label'])) {
                $this->genericLabel = $definition['generic_label'];
            }
            if (isset($definition['tag'])) {
                $this->tag = $definition['tag'];
            }
        }, $type, '\CommerceGuys\Tax\Model\TaxType');
        $setValues($definition);

        foreach ($definition['rates'] as $rateDefinition) {
            $rate = $this->createTaxRateFromDefinition($rateDefinition);
            $type->addRate($rate);
        }

        return $type;
    }