Set definitions for property and interface injection.

@param array $definitions
@return ContainerAwareInterface
346941
public function setDefinitions(array $definitions) : ContainerAwareInterface
    {
        $this->set('definition.config', $definitions);
        parent::setPropertyDefinition($definitions['property.definition']);

        return $this;
    }
763251
private function setDefinitionTags(Definition $definition, array $array)
    {
        if (isset($array['tags'])) {
            if (!is_array($array['tags'])) {
                throw new InvalidArgumentException(sprintf('Parameter "tags" must be an array for service "%s".', $id));
            }

            foreach ($array['tags'] as $tag) {
                if (!isset($tag['name'])) {
                    throw new InvalidArgumentException(sprintf(
                        'A "tags" entry is missing a "name" key for service "%s".',
                        $id
                    ));
                }

                $name = $tag['name'];
                unset($tag['name']);

                foreach ($tag as $attribute => $value) {
                    if (!is_scalar($value)) {
                        throw new InvalidArgumentException(sprintf(
                            'A "tags" attribute must be of a scalar-type for service "%s", tag "%s".',
                            $id,
                            $name
                        ));
                    }
                }

                $definition->addTag($name, $tag);
            }
        }
    }
202301
private static function createArgument(array $definition): ReflectionArgument
    {
        $result = new static(self::EXPRESSION, $definition['value']);

        if (count($definition['tokens']) == 1) {
            //If argument represent by one token we can try to resolve it's type more precisely
            switch ($definition['tokens'][0][0]) {
                case T_VARIABLE:
                    $result->type = self::VARIABLE;
                    break;
                case T_LNUMBER:
                case T_DNUMBER:
                    $result->type = self::CONSTANT;
                    break;
                case T_CONSTANT_ENCAPSED_STRING:
                    $result->type = self::STRING;
                    break;
            }
        }

        return $result;
    }
854805
public function parseRulesDefinition($definition): RulesCollection
    {
        if (is_callable($definition)) {

            $definition = [$definition];

        }

        if (is_string($definition)) {

            $definition = array_map('trim', explode('|', $definition));

        }

        if (is_array($definition)) {

            $keys = array_keys($definition);

            return array_reduce($keys, function ($rules, $key) use ($definition) {

                $definition = $definition[$key];

                $rule = $this->parseRuleDefinition($key, $definition);

                return $rules->withRule($rule);

            }, new RulesCollection);

        }

        throw new InvalidRuleFormatException($definition);
    }
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();
    }
118856
protected function resolveObjectRealInterfaceExtensions(ClassAwareDefinitionInterface $definition): void
    {
        $class = $definition->getClass();

        if (class_exists($class)) {
            $refClass = new \ReflectionClass($definition->getClass());
            if ($interfaces = $refClass->getInterfaceNames()) {
                foreach ($interfaces as $interface) {
                    $bundleNamespace = ClassUtils::relatedBundleNamespace($interface);
                    if (preg_match('/(\w+)Interface?$/', $interface, $matches)) {
                        $extensionClass = ClassUtils::applyNamingConvention($bundleNamespace, 'Extension', null, $matches[1].'Extension');
                        if (class_exists($extensionClass)) {
                            if ($definition instanceof HasExtensionsInterface) {
                                $definition->addExtension($extensionClass);
                            }
                        }
                    }
                }
            }
        }
    }
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]];
            }
        }
    }
492969
public function bind(string $name, $definition)
    {
        $this->definitions[$name] = new Singleton($name, $definition);
        return $this;
    }
761073
public function define(array $definitions, array &$context)
    {
        if (!is_array($definitions)) {
            throw new InvalidConfigurationException(
                "Step 'define' in AbstractConfigurableProducer expected an array as configuration"
            );
        }

        if (!array_key_exists(self::CONTEXT_VARS, $context)) {
            $context[self::CONTEXT_VARS] = [];
        }

        foreach ($definitions as $key => $definition) {
            $context[self::CONTEXT_VARS][$key] = $this->resolve($definition, $context);
        }
    }
1165158
public static function factory(array $source, array $definitions, $translator)
    {
        return new self($source, $definitions, new DefinitionParser(new ConstraintFactory()), $translator);
    }
651287
protected function wrap( StorageInterface $input, array $definition ) {
    foreach( $definition as $property => $class ) {

      // wrap the whole value in a class, or every subvalue
      $is_array = $class{0} == '[' && $class{1} == ']';
      /** @var self $class */
      $class = ltrim( $class, '[]' );

      // choose between wrap modes
      $value = $input[ $property ];
      if( !class_exists( $class ) || !is_subclass_of( $class, self::class ) ) $input[ $property ] = null;
      else if( !$is_array ) $input[ $property ] = $class::instance( $value );
      else {

        $list = [];
        if( Collection::is( $value, true ) ) {
          foreach( $value as $i => $t ) {
            $list[ $i ] = $class::instance( $t );
          }
        }

        $input[ $property ] = $list;
      }
    }
  }
431898
public function setDefinition($id, Definition $definition)
    {
        if ($this->isCompiled()) {
            throw new BadMethodCallException('Adding definition to a compiled container is not allowed');
        }

        $id = $this->normalizeId($id);

        unset($this->aliasDefinitions[$id], $this->removedIds[$id]);

        return $this->definitions[$id] = $definition;
    }
856785
public function buildDefinition($definition)
    {
        if (is_callable($definition)) {
            return $definition;
        }

        if (is_array($definition) && isset($definition['component'])) {
            return new Listener(
                $definition['component'],
                $definition['method'] ?: null,
                $definition['arguments'] ? (array) $definition['arguments'] : []
            );
        }

        throw new AppException('Invalid listener format, must be callable or array with component key');
    }
705596
public function configureResources(array $definitions, array $interfaceMap)
    {
        $inheritanceMap = $translationMap = [];

        $registry = $this->getConfigurationRegistry();
        $factory = $this->getConfigurationFactory();

        foreach ($definitions as $namespace => $resources) {
            foreach ($resources as $id => $config) {
                $translation = null;
                if (isset($config['translation'])) {
                    $translation = $config['translation'];
                    unset($config['translation']);

                    $translationMap[$translation['entity']] = $config['entity'];
                    $translationMap[$config['entity']] = $translation['entity'];
                }

                $inheritance = [
                    'class'      => $config['entity'],
                ];
                if (array_key_exists('repository', $config)) {
                    $inheritance['repository'] = $config['repository'];
                }
                $inheritanceMap = [
                    $namespace.'.'.$id => $inheritance,
                ];

                $registry->addConfiguration($factory->createConfiguration([
                    'namespace'   => $namespace,
                    'id'          => $id,
                    'classes'     => $config,
                    'translation' => $translation,
                ]));
            }
        }

        $evm = $this->em->getEventManager();

        // Resolve entity target subscriber
        if (!empty($interfaceMap)) {
            $rtel = new ResolveTargetEntityListener();
            foreach ($interfaceMap as $model => $implementation) {
                $rtel->addResolveTargetEntity($model, $implementation, []);
            }
            $evm->addEventSubscriber($rtel);
        }

        // Load metadata listener
        $lms = new LoadMetadataListener($inheritanceMap, $interfaceMap);
        $evm->addEventSubscriber($lms);

        // Translatable listener
        $tl = new TranslatableListener(
            $this->getConfigurationRegistry(),
            $this->getLocaleProvider(),
            $translationMap
        );
        $evm->addEventSubscriber($tl);

        // Load Entity listener
        $el = new EntityListener($this->getPersistenceEventQueue());
        $evm->addEventSubscriber($el);


        return [$inheritanceMap, $translationMap];
    }
73738
public function load(array $definitions)
    {
        $this->data = $definitions['data'] ?? [];
        $this->parentAliases = $definitions['parent_aliases'] ?? [];
        foreach ($this->data as $value) {
            $this->validateDefinitions($value);
        }
    }
1051904
public function resolve(
        DefinitionInterface $definition, array $parameters = [])
    {
        /** @var CallableDefinition $definition */
        $args = (empty($parameters)) ? $definition->getArgs(): $parameters;
        return call_user_func_array($definition->getCallable(), $args);
    }
1053634
public function arrayToClassElement($definition)
    {
        $class = new Classes();
        if (isset($definition['docblock'])) {
            $docblock = $this->arrayToDocblockElement($definition['docblock']);
            $class->setDocbloc($docblock);
        }
        if (isset($definition['namespace'])) {
            $class->setNamespace($definition['namespace']);
        }
        if (isset($definition['name'])) {
            $class->setName($definition['name']);
        }
        if (isset($definition['extends'])) {
           $class->setExtends($definition['extends']);
        }
        if (isset($definition['implements'])) {
            foreach ($definition['implements'] as $interface) {
                $class->addImplements($interface);
            }
        }
        if (isset($definition['uses'])) {
            foreach ($definition['uses'] as $alias => $use) {
                $alias = is_string($alias) ? $alias : null;
                $class->addUse($use, $alias);
            }
        }
        if (isset($definition['functions'])) {
            foreach ($definition['functions'] as $definition) {
                $function = $this->arrayToFunctionElement($definition);
                $class->addFunction($function);
            }
        }
        return $class;
    }