@param array $components
@param array $keys

@return null|string
1714
protected function guessBestComponent(array $components, array $keys)
    {
        foreach ($keys as $key) {
            if (isset($components[$key]) && !empty($components[$key])) {
                return $components[$key];
            }
        }

        return null;
    }
299158
public function getParams(array $keys = null)
    {
        $params = $this->params;

        if ($keys) {
            $subset = [];
            foreach ($keys as $key) {
                if (array_key_exists($key, $params)) {
                    $subset[$key] = $params[$key];
                }
            }
            return $subset;
        }

        return $params;
    }
661599
public function clear(array $keys=null)
    {
        if ($keys === null) {
            foreach ($this->storages as $storage) {
                $storage->clear();
            }
            return $this;
        }

        if (!$keys) {
            return $this;
        }

        foreach ($keys as $key) {
            $this->offsetUnset($key);
        }

        return $this;
    }
1305632
protected function getAsync(array $keys)
    {
        return sprintf(
'<div id="block-cms-%s" >
    <script>
        /*<![CDATA[*/
            (function() {
                var b = document.createElement("script");
                b.type = "text/javascript";
                b.async = true;
                b.src = "%s";
                var s = document.getElementsByTagName("script")[0];
                s.parentNode.insertBefore(b, s);
            })();

        /*]]>*/
    </script>
</div>', $keys['block_id'], $this->router->generate('sonata_page_js_async_cache', $keys, UrlGeneratorInterface::ABSOLUTE_URL));
    }
790067
public function isEmpty($keys = null)
    {
        if (is_null($keys)) {
            return empty($this->elements);
        }
        $keys = (array) $keys;
        foreach ($keys as $key) {
            if (!empty($this->get($key))) {
                return false;
            }
        }
        return true;
    }
1324728
protected function _loadComponents($components)
    {
        foreach ($components as $component => $definition) {
            if (is_int($component)) {
                $component = lcfirst(($pos = strrpos($definition, '\\')) ? substr($definition, $pos + 1) : $definition);
                $this->_di->setShared($component, $definition);
            } elseif ($definition === null) {
                $this->_di->remove($component);
            } elseif ($component[0] !== '!' || $this->_di->has($component = substr($component, 1))) {
                $this->_di->setShared($component, $definition);
            }
        }
    }
301770
private function getRecord(array $keys)
    {
        $keys['_timeout'] = ['$gt' => time()];

        $results = $this->getCollection()->find($keys);

        if ($results->hasNext()) {
            return $results->getNext();
        }
    }
358655
public function setComponents(array $components)
    {
        foreach ($components as $id => $properties) {
            $this->setComponent($id, $properties);
        }
    }
695440
private function setUpComponents($components)
  {
    if (empty($components)) {
      $this->components = $components;
    // sequential
    } elseif (array_keys($components) === range(0, count($components) - 1)) {
      for ($i = 0; $i < count($components); $i++) {
        $this->components[$components[$i]] = 0;
      }
    // associative
    } else {
      foreach ($components as $component => $value) {
        $this->components[$component] = 0;
      }
    }
  }
965136
public function performPost(array $components)
    {
        $response = $this->httpClient->post('', [
            'json' => ['components' => $components]
        ]);

        return (string) $response->getBody();
    }
37437
private function findKey(string $name, array $keys)
    {
        // 1 level keys > optimization
        if (sizeof($keys) == 1) {
            if (isset($this->translations[$name][$keys[0]])) {
                return $this->translations[$name][$keys[0]];
            } else {
                return null;
            }
        }

        $ref = &$this->translations[$name];
        $leave = false;

        while ($leave == false) {
            $key = array_shift($keys);

            if (is_null($key)) {
                $leave = true;
            } else {
                $ref = &$ref[$key];
            }
        }

        return $ref;
    }
406317
public static function nulls(array $data, $keys = null)
    {
        if ($keys === null) {
            $keys = array_keys($data);
        }

        if (!Arrays::isArray($keys)) {
            $keys = array($keys);
        }

        foreach ($keys as $key) {
            if (array_key_exists($key, $data) && empty($data[$key])) {
                $data[$key] = null;
            }
        }

        return $data;
    }
538895
public function getTextFromArray(array $keys = [])
    {
        $values = [];
        foreach ($keys as $key) {
            $values[$key] = $this->getText($key);
        }
        return $values;
    }
696346
final protected function URLToString(array $components = array(
		'scheme',
		'user',
		'pass',
		'host',
		'port',
		'path',
		'query',
		'fragment'
	))
	{
		$url = '';
		$query = "{$this->query}";
		if (in_array('scheme', $components)) {
			if (is_string($this->_url_data['scheme'])) {
				$url .= rtrim($this->_url_data['scheme'], ':/') . '://';
			} else {
				$url .= 'http://';
			}
		}

		if (@is_string($this->_url_data['user']) and in_array('user', $components)) {
			$url .= urlencode($this->_url_data['user']);
			if (@is_string($this->_url_data['pass']) and in_array('pass', $components)) {
				$url .= ':' . urlencode($this->_url_data['pass']);
			}
			$url .= '@';
		}

		if (in_array('host', $components)) {
			if (@is_string($this->_url_data['host'])) {
				$url .= $this->_url_data['host'];
			} else {
				$url .= 'localhost';
			}
		}
		if (
			is_int($this->_url_data['port'])
			and ! $this->isDefaultPort($this->_url_data['scheme'], $this->_url_data['port'])
		) {
			$url .= ":{$this->_url_data['port']}";
		}
		if (in_array('path', $components)) {
			if (@is_string($this->_url_data['path'])) {
				$url .= '/' . ltrim($this->_url_data['path'], '/');
			} else {
				$url .= '/';
			}
		}

		if(
			strlen($query) !== 0 and in_array('query', $components)
		) {
			$url .= "?$query";
		}
		if (@is_string($this->_url_data['fragment']) and in_array('fragment', $components)) {
			$url .= '#' . ltrim($this->_url_data['fragment'], '#');
		}
		return $url;
	}
882136
public static function GetElementsByKeys (array $array, array $keys) {
		return array_filter(array_combine($keys, array_map(function ($key) use ($array) {
			return isset($array[$key]) ? $array[$key] : null;
		}, $keys)));
	}
1340129
public function setQueryKeys(array $keys)
    {
        $this->queryKeys = [];

        foreach ($keys as $key) {
            if (is_string($key)) {
                $this->addQueryKey($key);
            }
        }

        return $this;
    }
1351114
public function data(array $keys = null)
    {
        if ($keys === null) {
            $keys = $this->keys();
        }

        $data = [];
        foreach ($keys as $key) {
            if (strtolower($key) === 'data') {
                /** @internal Edge Case: Avoid recursive call */
                continue;
            }

            if (isset($this[$key])) {
                $data[$key] = $this[$key];
            }
        }
        return $data;
    }