Limit an array of submitted data to the allowed keys
@param array $allowed
@return array
176714
public function filterSubmitted(array $allowed)
    {
        $this->submitted = array_intersect_key($this->submitted, array_flip($allowed));
        return $this->submitted;
    }
128526
public function setFilter(array $allowed = array(), $query = null)
    {
        if (!isset($query)) {
            $query = $this->getFilterQuery();
        }

        $this->setFilterData($allowed, $query);
        $this->query_filter = array_filter($query, 'is_string');
    }
619327
public function ifIsOneOf(array $allowedValues)
    {
        if ($this->value->isOneOf($allowedValues)) {
            return $this->value->value();
        }

        $this->paramErrors->append(
                $this->paramName,
                'FIELD_NO_SELECT',
                ['ALLOWED' => join('|', $allowedValues)]
        );
        return null;
    }
517482
protected function checkRole($allowed)
    {
        if (!is_array($allowed)) {
            $allowed = explode('|', $allowed);
        }

        return in_array($this->getCurrentRole(), $allowed);
    }
1004915
public function batchCommand($allowedCommands)
    {
        $request = $this->request->getCurrentRequest();

        if (\is_array($allowedCommands)) {
            $this->command->setAllowedCommands($allowedCommands);
            $this->command->setCommandNames(\array_keys($request->request->all()));
        }

        if (!$this->command->getCommandName()) {
            $this->command->setCommandName($allowedCommands);
        }

        $this->command->addCommandParameters([
            'selected' => $request->request->get('selected', []),
            'selectedAll' => $request->request->get('selectedAll', false),
            'query' => $request->get('query', []),
        ]);

        return $this;
    }
693356
final public function getAllowedDataFromRequest(array $requestParams, $httpMethod)
    {
        if (in_array($httpMethod, ['PATCH', 'PUT'])) {
            $properties = $this->getModifiableProperties();
        } elseif ($httpMethod === 'POST') {
            $properties = $this->getWritableProperties();
        } else {
            return [];
        }

        $data = [];
        if (false === empty($properties)) {
            foreach ($properties as $property) {
                $lcProperty = lcfirst($property);
                if (array_key_exists($lcProperty, $requestParams)) {
                    $data[$property] = $requestParams[$lcProperty];
                }
            }
        }

        return $data;
    }
740624
protected function getValueBlockParameters(Limitation $limitation, array $parameters)
    {
        $values = $this->valueMapperRegistry
            ->getMapper($limitation->getIdentifier())
            ->mapLimitationValue($limitation);

        $parameters += [
            'limitation' => $limitation,
            'values' => $values,
        ];

        return $parameters;
    }
222660
public function getAllowedMethods($token) {
        $token = (string)$token;
        $array = (isset($this->config['tokens'][$token]))?$this->config['tokens'][$token]:array();
        $allowed = array_merge_recursive(
            $this->config['tokens']['*'],
            $array
        );
        $allowed = array_change_key_case($allowed);
        array_walk_recursive($allowed,function(&$value,$key){$value=mb_strtolower($value);});
        return $allowed;
    }
897239
public function setAllowed(array $allowed){
        $this->allowed  = array_unique(
            array_map(
                "strtoupper",
                array_filter(
                    $allowed,
                    "is_string"
                )
            )
        );

        if(empty($this->allowed)){
            $this->allowed  = null;
        }

        return $this;
    }
893003
public function toArray($limit=-1)
    {
        $ar  = array();
        $cnt = 0;

        while ($data=$this->next()) {
            array_push($ar, $data);
            $cnt ++;
            if ($limit != -1 && $cnt >= $limit) {
                break;
            }
        }
        return $ar;
    }
738493
public function getAllDepartments($limit = CAKE_LDAP_SYNC_AD_LIMIT) {
		$fields = [
			$this->alias . '.id',
			$this->alias . '.value',
		];
		$blockExists = $this->hasField('block');
		if ($blockExists) {
			$fields[] = $this->alias . '.block';
		}
		$conditions = [];
		$order = [$this->alias . '.value' => 'asc'];
		$this->recursive = -1;

		return $this->find('all', compact('fields', 'conditions', 'order'));
	}
194427
protected function filterEligibleKeys(array $eligibleKeys)
	{
		$filteredKeys = [];
		foreach ($eligibleKeys as $k => $keys)
		{
			if (count($keys) > 1)
			{
				$filteredKeys[] = $keys;
			}
		}

		return $filteredKeys;
	}
602812
static function validateValue($given, array $allowed)
    {
        if (!in_array($given, $allowed)) {
            $allowed = implode(', ', $allowed);
            throw new ValueException(
                    "Allowed values: $allowed given value: $given"
            );
        }
    }
1173629
private static function getNotAllowedParams($params, $allowedParams)
    {
        $notAllowedParams = array();
        foreach ($params as $key => $value) {
            if (!isset($allowedParams[$key])) {
                $notAllowedParams[$key] = $value;
            }
        }

        return $notAllowedParams;
    }
62234
public function useSiteHashFromAllowedSites($allowedSites): QueryBuilder
    {
        $isAnySiteAllowed = trim($allowedSites) === '*';
        if ($isAnySiteAllowed) {
            // no filter required
            return $this;
        }

        $allowedSites = GeneralUtility::trimExplode(',', $allowedSites);
        $filters = [];
        foreach ($allowedSites as $site) {
            $siteHash = $this->siteHashService->getSiteHashForDomain($site);
            $filters[] = 'siteHash:"' . $siteHash . '"';
        }

        $siteHashFilterString = implode(' OR ', $filters);
        return $this->useFilter($siteHashFilterString, 'siteHash');
    }
117331
public function getLinks(int $limit = 0): array
    {
        if ($this->links === null) {
            $links = $this->attrs['links'] ?? [];
            $this->links = $this->removeInvalidOrHiddenLinks($links);
        }

        return $limit > 0 ? array_slice($this->links, 0, $limit) : $this->links;
    }
583569
protected function getAllowedPublicMethods(): array
    {
        $allowedInterfaces = \array_unique(\array_merge($this->getAllowedInterfaces(), [ImmutabilityBehaviour::class]));
        $allowedMethods = \array_merge(
            ...\array_map(
                function (string $interface): array {
                    return (new \ReflectionClass($interface))->getMethods(\ReflectionMethod::IS_PUBLIC);
                },
                $allowedInterfaces
            )
        );

        return \array_unique(\array_filter(\array_map(
            function (\ReflectionMethod $method): string {
                return !$method->isStatic() ? $method->getName() : '';
            },
            $allowedMethods
        )));
    }