Function to add all context associations to an entry.

@param string $unused This does nothing, do not use it.
519130
public function add_associations($unused = null) {

        if ($unused !== null) {
            debugging('Illegal argument used in blog_entry->add_associations()', DEBUG_DEVELOPER);
        }

        $this->remove_associations();

        if (!empty($this->courseassoc)) {
            $this->add_association($this->courseassoc);
        }

        if (!empty($this->modassoc)) {
            $this->add_association($this->modassoc);
        }
    }
660211
protected function _actionAdd($context)
    {
        $data = $context->data;

        $entity = parent::_actionAdd($context);

        //if a person posting a message on his profile
        //or if a target is not actor then it can't be a private message
        if (get_viewer()->eql($this->actor) || !is_person($this->actor)) {
            unset($data->private);
        }

        //if a private message then
        //set the privacy to subject/target
        if ($data->private) {
            $entity->setAccess(array($this->actor->id, get_viewer()->id));
        }

        //create a notification for the subscribers and
        //the post owner as well
        if ($entity->owner->isSubscribable()) {
            //create a notification and pass the owner
            $notification = $this->createNotification(array(
                'name' => 'note_add',
                'object' => $entity,
                'subscribers' => array($entity->owner->subscriberIds->toArray(), $entity->owner),
            ))->setType('post', array('new_post' => true));
        }

        if (!empty($data['channels'])) {
            $this->shareObject(array(
                'object' => $entity,
                'sharers' => $data['channels']
            ));
        }

        return $entity;
    }
150144
protected function _beforeInsert(DatabaseContext $context)
    {
        if($this->hasProperty('modified_by')) {
            $this->modified_by = (int) $this->getObject('user')->getId();
        }

        if($this->hasProperty('modified_on')) {
            $this->modified_on = gmdate('Y-m-d H:i:s');
        }
    }
778646
public function initializeContext(Context $context)
    {
        if (false === $context instanceof AliceContextInterface) {
            return;
        }

        /* @var AliceContextInterface $context */
        $fixturesBasePath = $this->fixturesBasePath;
        switch (true) {

            case $context instanceof AliceODMContext:
                $fixturesBasePath .= '/ODM';
                break;

            case $context instanceof AliceORMContext:
                $fixturesBasePath .= '/ORM';
                break;

            case $context instanceof AlicePHPCRContext:
                $fixturesBasePath .= '/PHPCR';
                break;
        }

        if (null === $context->getBasePath()) {
            $context->setBasePath($fixturesBasePath);
        }
    }
639737
protected function _setContext($context)
    {
        $this->context = ($context !== null)
            ? $this->_normalizeContainer($context)
            : null;
    }
496443
public function setActiveContext($context)
    {
        $oldLocale = isset($this->activeContext) ? $this->contextLocales[$this->activeContext] : null;
        $this->activeContext = $context;
        if (!isset($this->contextLocales[$context])) {
            $this->setContextLocale($context, static::BASE_LOCALE);
        }
        $newLocale = $this->contextLocales[$context];
        if ($newLocale !== $oldLocale) {
            $this->currentLocaleChanged($newLocale);
        }
    }
971640
public function addUses($args)
    {
        foreach ((array)$args as $key => $value) {
            $value = str_replace('/', '\\', $value);
            if (is_int($key)) {
                // namespace or class import
                if (class_exists($value)) {
                    // class import
                    $this->aliases[StringHelper::basename($value)] = $value;
                } else {
                    // namespace
                    $this->namespaces[] = $value;
                }
            } else {
                // aliased class import
                $this->aliases[$key] = $value;
            }
        }
    }
961067
public function register( $context = null ) {
		if ( null !== $context ) {
			$this->add_context( $context );
		}

		if ( ! $this->is_needed( $this->context ) ) {
			return;
		}

		\add_shortcode( $this->get_tag(), [ $this, 'render' ] );
	}
1191639
public function add_to_context( $context ) {
		$context['foo'] = 'bar';
		$context['stuff'] = 'I am a value set in your functions.php file';
		$context['notes'] = 'These values are available everytime you call Timber::context();';
		$context['menu'] = new Timber\Menu();
		$context['site'] = $this;
		return $context;
	}
1214098
public function addUseStatement(string $qualifiedName, string $alias = null) {
		if (!is_string($alias)) {
			if (false === strpos($qualifiedName, '\\')) {
				$alias = $qualifiedName;
			} else {
				$alias = substr($qualifiedName, strrpos($qualifiedName, '\\') + 1);
			}
		}

		$this->useStatements->set($alias, $qualifiedName);

		return $this;
	}
508321
protected function _actionAdd(AnCommandContext $context)
    {
        $data = $context->data;

        return $this->getRepository()->create($data->toArray());
    }
470553
protected function _addToolbars(KControllerContextInterface $context)
    {
        if($this->getView() instanceof KViewHtml)
        {
            // Add toolbars on authenticated requests only.
            if($this->getObject('user')->isAuthentic())
            {
                foreach($context->toolbars as $toolbar) {
                    $this->addToolbar($toolbar);
                }
            }

            $this->getView()->getTemplate()->addFilter('toolbar', array('toolbars' => $this->getToolbars()));
        }
    }
139398
public function ajaxBroker(array $unused, AjaxRequestHandler $ajax)
    {
        $state = (bool)GeneralUtility::_POST('state');
        $checkbox = GeneralUtility::_POST('checkbox');

        if (in_array($checkbox, $this->validCheckboxKeys, true)) {
            $ajax->setContentFormat('json');
            $this->userSettingsService->set($checkbox, $state);
            $ajax->addContent('success', true);
        } else {
            $ajax->setContentFormat('plain');
            $ajax->setError('Illegal input parameters.');
        }
    }
179037
protected static function cache_add(context $context) {
        if (isset(self::$cache_contextsbyid[$context->id])) {
            // already cached, no need to do anything - this is relatively cheap, we do all this because count() is slow
            return;
        }

        if (self::$cache_count >= CONTEXT_CACHE_MAX_SIZE) {
            $i = 0;
            foreach(self::$cache_contextsbyid as $ctx) {
                $i++;
                if ($i <= 100) {
                    // we want to keep the first contexts to be loaded on this page, hopefully they will be needed again later
                    continue;
                }
                if ($i > (CONTEXT_CACHE_MAX_SIZE / 3)) {
                    // we remove oldest third of the contexts to make room for more contexts
                    break;
                }
                unset(self::$cache_contextsbyid[$ctx->id]);
                unset(self::$cache_contexts[$ctx->contextlevel][$ctx->instanceid]);
                self::$cache_count--;
            }
        }

        self::$cache_contexts[$context->contextlevel][$context->instanceid] = $context;
        self::$cache_contextsbyid[$context->id] = $context;
        self::$cache_count++;
    }
57548
function user_context($data, $merge=true)
    {
        if ($merge && $this->context->user !== null) {
            // bail if data is null
            if (!$data) {
                return;
            }
            $this->context->user = array_merge($this->context->user, $data);
        } else {
            $this->context->user = $data;
        }
    }
515689
public function addReturnTypes(Context $context)
    {
        if ($this->return_vars_in_scope !== null) {
            $this->return_vars_in_scope = TypeAnalyzer::combineKeyedTypes(
                $context->vars_in_scope,
                $this->return_vars_in_scope
            );
        } else {
            $this->return_vars_in_scope = $context->vars_in_scope;
        }

        if ($this->return_vars_possibly_in_scope !== null) {
            $this->return_vars_possibly_in_scope = array_merge(
                $context->vars_possibly_in_scope,
                $this->return_vars_possibly_in_scope
            );
        } else {
            $this->return_vars_possibly_in_scope = $context->vars_possibly_in_scope;
        }
    }
938801
def apply_extra_context(extra_context, context):
    
    for key, value in six.iteritems(extra_context):
        if callable(value):
            context[key] = value()
        else:
            context[key] = value