Store a binding between models.
@param String $subjectModel
@param String $alias
@param Garp_Util_Configuration $options
@return Void
558973
public static function storeBinding($subjectModel, $alias, Garp_Util_Configuration $options = null) {
        static::$_bindings[$subjectModel][$alias] = self::_setRelationDefaultOptions($alias, $options);
    }
249905
public function bindComponent($instanceName, $paramName, $paramValue) {
		if ($paramValue == null) {
			unset($this->declaredInstances[$instanceName]["fieldBinds"][$paramName]);
		} else {
			$this->declaredInstances[$instanceName]["fieldBinds"][$paramName] = $paramValue;
		}
	}
160587
public function set($alias, $value, $config = array())
	{
		$ttl = isset($config['ttl']) ? $config['ttl'] : 0;
		return apcu_store($alias,$value,$ttl);
	}
488297
public function render(Subject $subject)
    {
        $this->injectViewClasses();
        $this->_ensureSuccess($subject);
        $this->_ensureData($subject);
        $this->_ensureSerialize();

        return $this->_controller()->render();
    }
659271
public function injectSubject(\PHPCraft\Subject\Subject $subject)
    {
        $this->subjects[$subject->name] = $subject;
    }
1258002
protected function _ensureData(Subject $subject)
    {
        $controller = $this->_controller();
        $action = $this->_action();

        if (method_exists($action, 'viewVar')) {
            $viewVar = $action->viewVar();
        } else {
            $viewVar = 'data';
        }

        if (isset($controller->viewVars[$viewVar])) {
            return;
        }

        $key = $subject->success ? 'success' : 'error';

        $config = $action->getConfig('api.' . $key);

        $data = [];

        if (isset($config['data']['subject'])) {
            $config['data']['subject'] = Hash::normalize((array)$config['data']['subject']);

            $subjectArray = (array)$subject;
            foreach ($config['data']['subject'] as $keyPath => $valuePath) {
                if ($valuePath === null) {
                    $valuePath = $keyPath;
                }

                $keyPath = $this->_expandPath($subject, $keyPath);
                $valuePath = $this->_expandPath($subject, $valuePath);

                $data = Hash::insert($data, $keyPath, Hash::get($subjectArray, $valuePath));
            }
        }

        if (isset($config['data']['entity'])) {
            $config['data']['entity'] = Hash::normalize((array)$config['data']['entity']);

            foreach ($config['data']['entity'] as $keyPath => $valuePath) {
                if ($valuePath === null) {
                    $valuePath = $keyPath;
                }

                if (method_exists($subject->entity, $valuePath)) {
                    $data = Hash::insert($data, $keyPath, call_user_func([$subject->entity, $valuePath]));
                } elseif (isset($subject->entity->{$valuePath})) {
                    $data = Hash::insert($data, $keyPath, $subject->entity->{$valuePath});
                }
            }
        }

        if (isset($config['data']['raw'])) {
            foreach ($config['data']['raw'] as $path => $value) {
                $path = $this->_expandPath($subject, $path);
                $data = Hash::insert($data, $path, $value);
            }
        }

        if (method_exists($action, 'viewVar')) {
            $viewVar = $action->viewVar();
        } else {
            $viewVar = 'data';
        }

        $controller->set($viewVar, $data);
    }
331199
public static function getStoreKey($subjectModel, $alias) {
        if ($subjectModel == $alias) {
            $subjectModel .= '1';
            $alias .= '2';
        }
        $models = array($subjectModel, $alias);
        sort($models);
        $key = implode('.', $models);
        return $key;
    }
614976
public function addChildObject($alias, $parent_id, $model, $foreignKey) {
        $query = array(
            'alias' => $alias,
            'parent_id' => $parent_id,
            'model' => $model,
            'foreign_key' => $foreignKey
        );

        $result = $this->find('first', array(
            'conditions' => $query
        ));

        if ($result) {
            return $result;
        }

        $this->create();

        if ($this->save($query)) {
            $this->deleteCache(array('RequestObject::hasAlias', $alias));

            return $this->getByAlias($alias);
        }

        return null;
    }
343853
protected function _saveToSession($subject)
    {
        $this->mergePrincipals($subject);
        $this->mergeAuthenticationState($subject);
        $this->mergeAuthorizationState($subject);

    }
692908
public function addSubjectPrefix($subjectPrefix, $roles)
    {
        if (!is_array($roles)) {
            $roles = array($roles);
        }
        if (is_array($subjectPrefix)) {
            foreach ($subjectPrefix as $oneSubjectPrefix) {
                $this->addSubjectPrefix($oneSubjectPrefix, $roles);
            }
        } else {
            if (isset($this->subjectPrefixes[$subjectPrefix])) {
                $this->subjectPrefixes[$subjectPrefix] = array_values(array_unique(array_merge(
                            $this->subjectPrefixes[$subjectPrefix], $roles)));
            } else {
                $this->subjectPrefixes[$subjectPrefix] = $roles;
            }
        }
        return $this;
    }
1290679
protected function mergePrincipals($subject)
    {
        $currentPrincipals = $subject->getPrincipals();
        $session = $subject->getSession(false);

        if ($session === null) {
            if (!empty($currentPrincipals)) {
                $session = $subject->getSession();
                $session->setAttribute(DefaultSubjectContext::PRINCIPALS_SESSION_KEY, $currentPrincipals);
            }
        } else {    //otherwise no session and no principals - nothing to save
            $existingPrincipals =
                    $session->getAttribute(DefaultSubjectContext::PRINCIPALS_SESSION_KEY);

            if (empty($currentPrincipals)) {
                if (!empty($existingPrincipals)) {
                    $session->removeAttribute(DefaultSubjectContext::PRINCIPALS_SESSION_KEY);
                }
            } else {    //otherwise both are null or empty - no need to update the session
                if ($currentPrincipals !== $existingPrincipals) {
                    $session->setAttribute(DefaultSubjectContext::PRINCIPALS_SESSION_KEY, $currentPrincipals);
                }
            }
        }
    
    }
934106
public function storeSubscriber(Subscriber $subscriber, string $topic): void
    {
        $topicKey = self::TOPIC_KEY.".{$topic}";
        $subscriberKey = self::SUBSCRIBER_KEY.".{$subscriber->channel}";

        $topic = $this->cache->has($topicKey)
            ? json_decode($this->cache->get($topicKey), true)
            : [];

        $topic[] = $subscriber->channel;

        $this->cache->forever($topicKey, json_encode($topic));
        $this->cache->forever($subscriberKey, $subscriber);
    }
113721
public static function resetRecursion($subjectModel, $alias = false) {
        if ($alias) {
            $key = self::getStoreKey($subjectModel, $alias);
            unset(static::$_recursion[$key]);
            return;
        }
        $_store = array();
        foreach (static::$_recursion as $key => $value) {
            $keyBits = explode('.', $key);
            // Strip off the integer from the end in the case of homophyllic relationships.
            array_walk($keyBits, function(&$kb) {
                $kb = preg_replace('/\d$/', '', $kb);
            });

            if (!in_array($subjectModel, $keyBits)) {
                $_store[$key] = $value;
            }
        }
        static::$_recursion = $_store;
    }
354825
public function bindComponentViaSetter($instanceName, $setterName, $paramValue) {
		if ($paramValue == null) {
			unset($this->declaredInstances[$instanceName]["setterBinds"][$setterName]);
		} else {
			$this->declaredInstances[$instanceName]["setterBinds"][$setterName] = $paramValue;
		}
	}
1079995
public static function add($content, $option = array() , $alias = null)
	{
		$object = self::getInstance($alias);
		if($object)
		{
			$object->add($content, $option);
			if(IS_CLI && Config::get('@.LOG_CLI_AUTOSAVE'))
			{
				$object->save();
				$object->data = array();
			}
		}
	}
51927
public function process(MetadataInterface $metadata, $subject): void
    {
        $analysis = [
            'filter' => [],
            'tokenizer' => [],
            'analyzer' => [],
        ];

        foreach ($subject->filters ?? [] as $filter) {
            $setting = ['type' => $filter->type];
            $analysis['filter'][$filter->name] = array_merge($setting, $filter->options);
        }

        foreach ($subject->tokenizers ?? [] as $tokenizer) {
            $setting = ['type' => $tokenizer->type];
            $analysis['tokenizer'][$tokenizer->name] = array_merge($setting, $tokenizer->options);
        }

        foreach ($subject->analyzers ?? [] as $analyzer) {
            $analysis['analyzer'][$analyzer->name] = array_filter([
                'tokenizer' => $analyzer->tokenizer,
                'char_filter' => $analyzer->charFilters,
                'filter' => $analyzer->filters,
            ]);
        }

        $metadata->indexParams['settings']['analysis'] = array_filter($analysis);
        $metadata->indexParams['settings'] = array_filter($metadata->indexParams['settings']);
        $metadata->indexParams = array_filter($metadata->indexParams);
    }
1294579
public function onResolveSubject(SubjectEvent $event)
    {
        $params = $event->getParameters();

        if (array_key_exists('type', $params)) {
            if ($params['type'] == 'page') {
                $event->setSubject($this->createPageSubject());
                $event->stopPropagation();
            } elseif ($params['type'] == 'global') {
                $event->setSubject($this->createGlobalSubject());
                $event->stopPropagation();
            }
        }
    }