Returns associations for controllers models.

@param array $whitelist Whitelist of associations to return.
@return array Associations for model
510051
protected function _associations(array $whitelist = [])
    {
        $table = $this->_table();

        $associationConfiguration = [];

        $associations = $table->associations();

        $keys = $associations->keys();
        if (!empty($whitelist)) {
            $keys = array_intersect($keys, array_map('strtolower', $whitelist));
        }
        foreach ($keys as $associationName) {
            $association = $associations->get($associationName);
            $type = $association->type();

            if (!isset($associationConfiguration[$type])) {
                $associationConfiguration[$type] = [];
            }

            $assocKey = $association->getName();
            $associationConfiguration[$type][$assocKey]['model'] = $assocKey;
            $associationConfiguration[$type][$assocKey]['type'] = $type;
            $associationConfiguration[$type][$assocKey]['primaryKey'] = $association->getTarget()->getPrimaryKey();
            $associationConfiguration[$type][$assocKey]['displayField'] = $association->getTarget()->getDisplayField();
            $associationConfiguration[$type][$assocKey]['foreignKey'] = $association->getForeignKey();
            $associationConfiguration[$type][$assocKey]['propertyName'] = $association->getProperty();
            $associationConfiguration[$type][$assocKey]['plugin'] = pluginSplit($association->getClassName())[0];
            $associationConfiguration[$type][$assocKey]['controller'] = $assocKey;
            $associationConfiguration[$type][$assocKey]['entity'] = Inflector::singularize(Inflector::underscore($assocKey));
            $associationConfiguration[$type][$assocKey]['entities'] = Inflector::underscore($assocKey);

            $associationConfiguration[$type][$assocKey] = array_merge($associationConfiguration[$type][$assocKey], $this->_action()->getConfig('association.' . $assocKey) ?: []);
        }

        return $associationConfiguration;
    }
452672
protected function getAttributeKeysAndControllers()
    {
        if ($this->attributeKeysAndControllers === null) {
            $list = [];
            foreach ($this->category->getList() as $attributeKey) {
                $list[] = [$attributeKey, $attributeKey->getController()];
            }
            $this->attributeKeysAndControllers = $list;
        }

        return $this->attributeKeysAndControllers;
    }
61
public function getAssociationLabels(RepositoryInterface $table) : array
    {
        /** @var \Cake\ORM\Table */
        $table = $table;

        $result = [];
        foreach ($table->associations() as $association) {
            if (!in_array($association->type(), $this->searchableAssociations)) {
                continue;
            }

            $result[$association->getName()] = Inflector::humanize(current((array)$association->getForeignKey()));
        }

        return $result;
    }
718417
public static function in($data, $whiteList)
    {
        if ($data) {
            if (is_object($data)) {
                $data = get_object_vars($data);
            }
            $whiteList = array_flip($whiteList);

            //Filter
            foreach ($data as $key => $value) {
                if (is_object($value)) {
                    $value = get_object_vars($value);
                }
                $data[$key] = array_intersect_key($value, $whiteList);
            }
        }
        return $data;
    }
948103
protected function _getControllerActions()
    {
        $table = $entity = [];

        $actions = $this->_getAllowedActions();
        foreach ($actions as $actionName => $config) {
            list($scope, $actionConfig) = $this->_getControllerActionConfiguration($actionName, $config);
            ${$scope}[$actionName] = $actionConfig;
        }

        $actionBlacklist = [];
        $groups = $this->_action()->getConfig('scaffold.action_groups') ?: [];
        foreach ($groups as $group) {
            $group = Hash::normalize($group);
            foreach ($group as $actionName => $config) {
                if (isset($table[$actionName]) || isset($entity[$actionName])) {
                    continue;
                }
                if ($config === null) {
                    $config = [];
                }
                list($scope, $actionConfig) = $this->_getControllerActionConfiguration($actionName, $config);
                $realAction = Hash::get($actionConfig, 'url.action', $actionName);
                if (!isset(${$scope}[$realAction])) {
                    continue;
                }

                $actionBlacklist[] = $realAction;
                ${$scope}[$actionName] = $actionConfig;
            }
        }

        foreach ($actionBlacklist as $actionName) {
            unset($table[$actionName]);
            unset($entity[$actionName]);
        }

        return compact('table', 'entity');
    }
480014
public function getAssignedMembers()
    {
        $members = $this->Users();
        $groups  = $this->Groups();

        // Can't merge instances of DataList so convert to something where we can
        $_members = ArrayList::create();
        $members->each(function ($item) use ($_members) {
            $_members->push($item);
        });

        $_groups = ArrayList::create();
        $groups->each(function ($item) use ($_groups) {
            $_groups->push($item);
        });

        foreach ($_groups as $group) {
            $_members->merge($group->Members());
        }

        $_members->removeDuplicates();
        return $_members;
    }
948033
private function getAssociations() : array
    {
        $result = [];
        foreach ($this->getQueryFields() as $field) {
            $association = $this->getAssociationByField($field);
            if (null === $association) {
                continue;
            }

            if (array_key_exists($association->getName(), $result)) {
                continue;
            }

            $result[$association->getName()] = $association;
        }

        return $result;
    }
314102
public static function getControllerPublicMethods(string $controllerName): array
    {
        $actions = [];

        if (!class_exists($controllerName)) {
            return $actions;
        }

        $refClass = new \ReflectionClass($controllerName);
        foreach ($refClass->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
            $actions[] = $method->name;
        }

        return $actions;
    }
1255231
public static function filterKeys($unfiltered, $whitelist)
	{
		$filtered = array_filter($unfiltered, function($key) use ($whitelist) {
			return in_array($key, $whitelist);
		}, ARRAY_FILTER_USE_KEY);

		return $filtered;
	}
461177
private function addToWhiteList(array $whiteList) {
        $current = $this->getWhiteList();
        $current = array_merge($current, $whiteList);
        $this->setWhiteList($current);
    }
1013812
public function enablePrimaryKeyAccess() : array
    {
        $result = [];
        foreach ($this->associations() as $association) {
            $accessibleFields = [];
            foreach ((array)$association->getTarget()->getPrimaryKey() as $primaryKey) {
                $accessibleFields[$primaryKey] = true;
            }

            $result['associated'][$association->getName()] = [
                'accessibleFields' => $accessibleFields
            ];
        }

        return $result;
    }
756731
public function setWhitelist($whitelist)
    {
        if (is_array($whitelist)) {
            $this->whitelist = array_map('strval', $whitelist);
        } elseif ($whitelist instanceof \ArrayObject && true) {
            $this->whitelist = array_map('strval', $whitelist->getArrayCopy());
        } elseif (is_string($whitelist)) {
            $this->whitelist = [];
            for ($i = 0; $i < strlen($whitelist); $i++) {
                $this->whitelist[] = $whitelist[$i];
            }
        } else {
            throw new \Exception('Incorrect whitelist given. Allowed whitelist are: string, array or ArrayObject.');
        }
    }
776415
final public function getRelationships($model, $isPrimary, array $includeRelationships)
    {
        $includables = array();
        foreach ($includeRelationships as $key => $relation) {
            $relationship = $this->loadRelation($model, $relation, $includeRelationships);
            $includables[$this->changeKeyToDashed($key)] = [self::DATA => $relationship ];
        }
        return $includables;
    }
1143452
public function whitelist() {
        $args = func_get_args();

        if (isset($args[0]) && is_array($args[0])) {
            $args = $args[0];
        }

        $this->_whitelist += $args;
        $this->_whitelist = array_filter($this->_whitelist);

        return $this;
    }
889930
private function getTypeNames(array $typeList)
    {
        $translatedList = [];
        foreach ($typeList as $type) {
            $translatedList[] = $this->translator->translate(HolidayType::$NAME[$type]);
        }

        return $translatedList;
    }
338449
public function controllerMiddleware()
    {
        if (! $this->isControllerAction()) {
            return [];
        }

        return $this->controllerDispatcher()->getMiddleware(
            $this->getController(), $this->getControllerMethod()
        );
    }
1010050
public function assign($data, $whiteList = null)
    {
        if ($whiteList === null) {
            $whiteList = $this->getSafeFields();
        }

        if ($whiteList === null) {
            throw new PreconditionException(['`:model` model do not define accessible fields.', 'model' => static::class]);
        }

        foreach ($whiteList ?: $this->getFields() as $field) {
            if (isset($data[$field])) {
                $value = $data[$field];
                $this->{$field} = is_string($value) ? trim($value) : $value;
            }
        }

        return $this;
    }