Adds new definitions to the current definitions manager

@param DefinitionManager $current
@param DefinitionManager $new
167364
protected function _merge(DefinitionManager $current, DefinitionManager $new)
    {
        /** @var DefinitionInterface $definition */
        foreach ($new as $definition) {
            if (!$current->has($definition->getName())) {
                $current->add($definition);
            }
        }
    }
709654
protected function normalizeDefinition($definition) {
		if ($definition instanceof DefinitionInterface) {
			return $definition;
		}
		
		if ($definition instanceof Closure) {
			return new Definition\CallbackDefinition($definition);
		}
		
		if (is_string($definition)) {
			return new Definition\ClassDefinition($definition);
		}
		
		return new Definition\InstanceDefinition($definition);
	}
1093803
public function createDictionary(DictionaryDefinition $definition): DictionaryInterface
    {
        $builder = $this->getDictionaryBuilder($definition);

        /** @var DictionaryBuilderInterface $builder */
        return $builder->build($this, $definition);
    }
627033
private void rewriteDefinition(Node definitionSite, String newMethodName) {
    final Node function;
    final Node subtreeToRemove;
    final Node nameSource;

    switch (definitionSite.getToken()) {
      case GETPROP:
        function = definitionSite.getParent().getLastChild();
        nameSource = definitionSite.getLastChild();
        subtreeToRemove = NodeUtil.getEnclosingStatement(definitionSite);
        break;

      case STRING_KEY:
      case MEMBER_FUNCTION_DEF:
        function = definitionSite.getLastChild();
        nameSource = definitionSite;
        subtreeToRemove = definitionSite;
        break;

      default:
        throw new IllegalArgumentException(definitionSite.toString());
    }

    // Define a new variable after the original declaration.
    Node statement = NodeUtil.getEnclosingStatement(definitionSite);
    Node newNameNode = IR.name(newMethodName).useSourceInfoIfMissingFrom(nameSource);
    Node newVarNode = IR.var(newNameNode).useSourceInfoIfMissingFrom(nameSource);
    statement.getParent().addChildBefore(newVarNode, statement);

    // Attatch the function to the new variable.
    function.detach();
    newNameNode.addChildToFront(function);

    // Create the `this` param.
    String selfName = newMethodName + "$self";
    Node paramList = function.getSecondChild();
    paramList.addChildToFront(IR.name(selfName).useSourceInfoIfMissingFrom(function));
    compiler.reportChangeToEnclosingScope(paramList);

    // Eliminate `this`.
    replaceReferencesToThis(function.getSecondChild(), selfName); // In default param values.
    replaceReferencesToThis(function.getLastChild(), selfName); // In function body.

    fixFunctionType(function);

    // Clean up dangling AST.
    NodeUtil.deleteNode(subtreeToRemove, compiler);
    compiler.reportChangeToEnclosingScope(newVarNode);
  }
175367
public function move($current,$new)
	{
		$metaFile = $this->getMetaFilePath($current);
		if ($this->fs->exists($metaFile)) {
			$this->fs->move($metaFile,$this->getMetaFilePath($new));
			if ($this->f3->get('CACHE')) {
				$cache = \Cache::instance();
				if ($cache->exists($cacheHash = $this->getCacheHash($current)))
					$cache->clear($cacheHash);
			}
		}
	}
901039
def new_term(self, term, value, **kwargs):
        """"""

        tc = self.doc.get_term_class(term.lower())

        t = tc(term, value, doc=self.doc, parent=None, section=self).new_children(**kwargs)

        self.doc.add_term(t)
        return t
109445
def new_control(self, type, name, value, **kwargs):
        """"""
        return self.get_current_form().new_control(type, name, value, **kwargs)
17097
private function applyNestedDefinitions($definitions, $record, $world)
    {
        foreach ($definitions as $definition) {
            $result = $definition->run($record, $world);
            $record = $this->applyTraits($record, $world);
            $record = array_merge($record, $result);
        }
        return $record;
    }
158263
public static function addOptions(InputDefinition $definition, array $fields, $description)
    {
        foreach ($fields as $field => $type) {
            $mode = 'array' === $type
                ? InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY
                : InputOption::VALUE_REQUIRED;

            if (!$definition->hasOption($field) && !$definition->hasArgument($field)) {
                $definition->addOption(new InputOption($field, null, $mode, sprintf($description, $field, $type)));
            }
        }
    }
567994
public function initialise(cache_definition $definition) {
        if ($this->is_initialised()) {
            throw new coding_exception('This mongodb instance has already been initialised.');
        }
        $this->database = $this->connection->selectDatabase($this->databasename);
        $this->definitionhash = 'm'.$definition->generate_definition_hash();
        $this->collection = $this->database->selectCollection($this->definitionhash);

        $options = array('name' => 'idx_key');

        $w = $this->usesafe ? 1 : 0;
        $wc = new MongoDB\Driver\WriteConcern($w);

        $options['writeConcern'] = $wc;

        $this->collection->createIndex(array('key' => 1), $options);
    }
454049
public function add()
    {
        $this->loadModel('Taxonomy.Vocabularies');
        $vocabulary = $this->Vocabularies->newEntity();

        if ($this->request->data()) {
            $vocabulary = $this->Vocabularies->patchEntity($vocabulary, $this->request->data, [
                'fieldList' => [
                    'name',
                    'description',
                ],
            ]);

            if ($this->Vocabularies->save($vocabulary, ['atomic' => true])) {
                $this->Flash->success(__d('taxonomy', 'Vocabulary has been created, now you can start adding terms!'));
                $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'add', $vocabulary->id]);
            } else {
                $this->Flash->danger(__d('taxonomy', 'Vocabulary could not be created, please check your information'));
            }
        }

        $this->title(__d('taxonomy', 'Create New Vocabulary'));
        $this->set('vocabulary', $vocabulary);
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('taxonomy', 'Taxonomy'), '/admin/taxonomy/manage')
            ->push(__d('taxonomy', 'Vocabularies'), ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'index'])
            ->push(__d('taxonomy', 'Crating new vocabulary'), '#');
    }
478118
public function addDefinition(string $name, array $definition)
    {
        if (isset($this->_definition[$name])) {
            throw new Exception('Definition for "' . $name . '" already exists');
        }

        $this->_definition[$name] = $definition;

        return $this;
    }
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;
    }
307192
public static function update_definitions($coreonly = false) {
        global $CFG;
        // Include locallib.
        require_once($CFG->dirroot.'/cache/locallib.php');
        // First update definitions
        cache_config_writer::update_definitions($coreonly);
        // Second reset anything we have already initialised to ensure we're all up to date.
        cache_factory::reset();
    }
1046447
public function addToManager(Manager $manager)
    {
        $this->extend('onBeforeAddToManager', $manager);
        $scaffold = $this->scaffold($manager);
        if (!$manager->hasType($this->getTypeName())) {
            $manager->addType($scaffold, $this->getTypeName());
        }

        foreach ($this->operations as $op) {
            $op->addToManager($manager);
        }

        foreach ($this->nestedQueries as $scaffold) {
            $scaffold->addToManager($manager);
        }

        $this->extend('onAfterAddToManager', $manager);
    }
712206
public function setNew(string $new = "T") : CNabuDataObject
    {
        if ($new === null) {
            throw new ENabuCoreException(
                    ENabuCoreException::ERROR_NULL_VALUE_NOT_ALLOWED_IN,
                    array("\$new")
            );
        }
        $this->setValue('nb_user_group_member_new', $new);
        
        return $this;
    }
182578
public function add($vocabularyId)
    {
        $this->loadModel('Taxonomy.Vocabularies');
        $vocabulary = $this->Vocabularies->get($vocabularyId);
        $term = $this->Vocabularies->Terms->newEntity(['vocabulary_id' => $vocabulary->id], ['validate' => false]);
        $this->Vocabularies->Terms->addBehavior('Tree', ['scope' => ['vocabulary_id' => $vocabulary->id]]);

        if ($this->request->data()) {
            $term = $this->Vocabularies->Terms->patchEntity($term, $this->request->data, [
                'fieldList' => [
                    'parent_id',
                    'name',
                ]
            ]);

            if ($this->Vocabularies->Terms->save($term)) {
                $this->Flash->success(__d('taxonomy', 'Term has been created.'));
                if (!empty($this->request->data['action_vocabulary'])) {
                    $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'vocabulary', $vocabulary->id]);
                } elseif (!empty($this->request->data['action_add'])) {
                    $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'add', $vocabulary->id]);
                }
            } else {
                $this->Flash->danger(__d('taxonomy', 'Term could not be created, please check your information.'));
            }
        }

        $parentsTree = $this->Vocabularies->Terms
            ->find('treeList', ['spacer' => '--'])
            ->map(function ($link) {
                if (strpos($link, '-') !== false) {
                    $link = str_replace_last('-', '- ', $link);
                }

                return $link;
            });

        $this->title(__d('taxonomy', 'Create New Term'));
        $this->set(compact('vocabulary', 'term', 'parentsTree'));
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('taxonomy', 'Taxonomy'), '/admin/taxonomy/manage')
            ->push(__d('taxonomy', 'Vocabularies'), ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'index'])
            ->push("\"{$vocabulary->name}\"", ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'edit', $vocabulary->id])
            ->push(__d('taxonomy', 'Terms'), ['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'vocabulary', $vocabulary->id])
            ->push(__d('taxonomy', 'Add new term'), '#');
    }