Retrieves summoner spell by its unique numeric key.

@param int    $summoner_spell_id
@param string $locale
@param string $version

@return StaticData\StaticSummonerSpellDto
@throws RequestException
@throws ServerException
@throws SettingsException
17362
public function getStaticSummonerSpell( int $summoner_spell_id, string $locale = 'en_US', string $version = null ): StaticData\StaticSummonerSpellDto
	{
		$result = false;
		try
		{
			// Fetch StaticData from JSON files
			$result = DataDragonAPI::getStaticSummonerSpellById($summoner_spell_id, $locale, $version);
			if (!$result) throw new ServerException("StaticData failed to be loaded.");

			$this->result_data = $result;
		}
		catch (DataDragonExceptions\SettingsException $ex)
		{
			throw new SettingsException("DataDragon API was not initialized properly! StaticData endpoints cannot be used.");
		}
		catch (DataDragonExceptions\ArgumentException $ex)
		{
			throw new RequestException($ex->getMessage(), $ex->getCode());
		}
		finally
		{
			// Parse array and create instances
			return new StaticData\StaticSummonerSpellDto($result, $this);
		}
	}
650408
public static function getStaticMasteries( string $locale = 'en_US', string $version = null ) : array
	{
		$url = self::getStaticDataFileUrl(self::STATIC_MASTERIES, null, $locale, $version);
		return self::loadStaticData($url);
	}
566969
public static function with_locale($locale, $callback)
    {
        $oldLocale = self::$current_locale;
        static::set_locale($locale);
        try {
            return $callback();
        } finally {
            static::set_locale($oldLocale);
        }
    }
804916
public function getStaticMaps( string $locale = 'en_US', string $version = null ): StaticData\StaticMapDataDto
	{
		$result = false;
		try
		{
			// Fetch StaticData from JSON files
			$result = DataDragonAPI::getStaticMaps($locale, $version);
			if (!$result) throw new ServerException("StaticData failed to be loaded.");

			$this->result_data = $result;
		}
		catch (DataDragonExceptions\SettingsException $ex)
		{
			throw new SettingsException("DataDragon API was not initialized properly! StaticData endpoints cannot be used.");
		}
		catch (DataDragonExceptions\ArgumentException $ex)
		{
			throw new RequestException($ex->getMessage(), $ex->getCode());
		}
		finally
		{
			// Parse array and create instances
			return new StaticData\StaticMapDataDto($result, $this);
		}
	}
910125
public static function getStaticChampions( string $locale = 'en_US', string $version = null ) : array
	{
		$url = self::getStaticDataFileUrl(self::STATIC_CHAMPIONS, null, $locale, $version);
		return self::loadStaticData($url, [DataDragonAPI::class, "_champion"]);
	}
291409
public function getStaticItems( string $locale = 'en_US', string $version = null ): StaticData\StaticItemListDto
	{
		$result = false;
		try
		{
			// Fetch StaticData from JSON files
			$result = DataDragonAPI::getStaticItems($locale, $version);
			if (!$result) throw new ServerException("StaticData failed to be loaded.");

			// Create missing data
			array_walk($result['data'], function (&$d, $k) {
				$d['id'] = $k;
			});

			$this->result_data = $result;
		}
		catch (DataDragonExceptions\SettingsException $ex)
		{
			throw new SettingsException("DataDragon API was not initialized properly! StaticData endpoints cannot be used.");
		}
		catch (DataDragonExceptions\ArgumentException $ex)
		{
			throw new RequestException($ex->getMessage(), $ex->getCode());
		}
		finally
		{
			// Parse array and create instances
			return new StaticData\StaticItemListDto($result, $this);
		}
	}
787615
protected function unserialize(\Asgard\Entity\Entity $entity, array $data, $locale=null) {
		foreach($this->dataMapper->getEntityDefinition($entity)->properties() as $k=>$prop) {
			$v = isset($data[$k]) ? $data[$k]:null;

			if($prop->get('type') === 'entity') {
				if($prop->get('many'))
					$data[$k] = new PersistentCollection($entity, $k, $this->dataMapper);
				else {
					$entity_id = $k.'_id';
					$id = $data[$entity_id];
					if($id) {
						if($prop->get('entity'))
							$class = $prop->get('entity');
						else {
							$entity_class = $k.'_type';
							$class = $data[$entity_class];
						}
						$data[$k] = $this->dataMapper->createEntityProxy($class, $id);
					}
					else
						$data[$k] = null;
				}
			}
			else {
				$class = get_class($prop);
				if($prop->get('many'))
					$data[$k] = $this->dataMapper->getEntityDefinition($entity)->property($k)->unserialize($v, $entity, $k);
				elseif($v === null)
					$data[$k] = null;
				elseif(method_exists($prop, 'fromSQL'))
					$data[$k] = $prop->fromSQL($v);
				elseif($transformer = $this->dataMapper->getSqlInput($class))
					return $transformer->fromSQL($v);
				else
					$data[$k] = $this->dataMapper->getEntityDefinition($entity)->property($k)->unserialize($v, $entity, $k);
			}
		}

		return $entity->_set($data, $locale, null, false);
	}
304928
public static function getStaticRune( int $rune_id, string $locale = 'en_US', string $version = null) : array
	{
		$data = self::getStaticRunes($locale, $version);
		if (isset($data['data'][$rune_id]) == false)
			throw new ArgumentException('Rune with given ID was not found.', 404);

		return $data['data'][$rune_id];
	}
1328378
public function load($eid, $version, $language)
    {
        $id = $eid.'_'.$language.'_'.$version;

        if (!isset($this->elements[$id])) {
            $this->elements[$id] = $this->loader->load($eid, $version, $language);
        }

        return $this->elements[$id];
    }
285256
public static function getStaticMastery( int $mastery_id, string $locale = 'en_US', string $version = null ) : array
	{
		$data = self::getStaticMasteries($locale, $version);
		if (isset($data['data'][$mastery_id]) == false)
			throw new ArgumentException('Mastery with given ID was not found.', 404);

		return $data['data'][$mastery_id];
	}
395029
public static function getStaticSummonerSpell( string $summonerspell_key, string $locale = 'en_US', string $version = null ) : array
	{
		$data = self::getStaticSummonerSpells($locale, $version);
		if (isset($data['data'][$summonerspell_key]) == false)
			throw new ArgumentException('Summoner spell with given key was not found.', 404);

		return $data['data'][$summonerspell_key];
	}
293033
public function fetch($identifier, $version=null)
    {
        $portableElements = $this->getAllVersions($identifier);

        // No version, return latest version
        if (is_null($version)) {
            $this->krsortByVersion($portableElements);
            return $this->getModel()->createDataObject(reset($portableElements));
        }

        // Version is set, return associated record
        if (isset($portableElements[$version])) {
            return $this->getModel()->createDataObject($portableElements[$version]);
        }

        // Version is set, no record found
        throw new PortableElementNotFoundException(
            $this->getModel()->getId() . ' with identifier ' . $identifier. ' found, '
            . 'but version "' . $version . '" does not exist.'
        );
    }
298338
public function findByIdAndLocale($id, $locale)
    {
        $item = $this->itemRepository->findByIdAndLocale($id, $locale);

        if ($item) {
            return $this->itemFactory->createApiEntity($item, $locale);
        } else {
            return null;
        }
    }
778561
public function index($version = null)
    {
        try {
            $request = new ServiceRequest();
            if (!empty($version)) {
                $request->setApiVersion($version);
            }

            Log::info('[REQUEST]', [
                'API Version' => $request->getApiVersion(),
                'Method'      => $request->getMethod(),
                'Service'     => null,
                'Resource'    => null
            ]);

            Log::debug('[REQUEST]', [
                'Parameters' => json_encode($request->getParameters(), JSON_UNESCAPED_SLASHES),
                'API Key'    => $request->getHeader('X_DREAMFACTORY_API_KEY'),
                'JWT'        => $request->getHeader('X_DREAMFACTORY_SESSION_TOKEN')
            ]);

            $limitedFields = ['id', 'name', 'label', 'description', 'type'];
            $fields = \Request::query(ApiOptions::FIELDS);
            if (!empty($fields) && !is_array($fields)) {
                $fields = array_map('trim', explode(',', trim($fields, ',')));
            } elseif (empty($fields)) {
                $fields = $limitedFields;
            }
            $fields = array_intersect($fields, $limitedFields);

            $group = \Request::query('group');
            $type = \Request::query('type');
            if (!empty($group)) {
                $results = ServiceManager::getServiceListByGroup($group, $fields, true);
            } elseif (!empty($type)) {
                $results = ServiceManager::getServiceListByType($type, $fields, true);
            } else {
                $results = ServiceManager::getServiceList($fields, true);
            }
            $services = [];
            foreach ($results as $info) {
                // only allowed services by role here
                if (Session::allowsServiceAccess(array_get($info, 'name'))) {
                    $services[] = $info;
                }
            }

            if (!empty($group)) {
                $results = ServiceManager::getServiceTypes($group);
            } elseif (!empty($type)) {
                $results = [ServiceManager::getServiceType($type)];
            } else {
                $results = ServiceManager::getServiceTypes();
            }
            $types = [];
            foreach ($results as $type) {
                $types[] = [
                    'name'        => $type->getName(),
                    'label'       => $type->getLabel(),
                    'group'       => $type->getGroup(),
                    'description' => $type->getDescription()
                ];
            }
            $response = ResponseFactory::create(['services' => $services, 'service_types' => $types]);
            Log::info('[RESPONSE]', ['Status Code' => $response->getStatusCode(), 'Content-Type' => $response->getContentType()]);

            return ResponseFactory::sendResponse($response, $request);
        } catch (\Exception $e) {
            return ResponseFactory::sendException($e, (isset($request) ? $request : null));
        }
    }
488555
public function getClosureByLocale($locale)
    {
        return $queryBuilder = function (EntityRepository $er) use ($locale) {
            $queryBuilder = $er->createQueryBuilder('p');
            $queryBuilder->andWhere('p.locale = :locale');
            $queryBuilder->setParameter('locale', $locale);

            return $queryBuilder;
        };
    }
130405
public static function get($number, $locale/*, bool $triggerDeprecation = true*/)
    {
        if (3 > \func_num_args() || \func_get_arg(2)) {
            @trigger_error(sprintf('The "%s" class is deprecated since Symfony 4.2.', __CLASS__), E_USER_DEPRECATED);
        }

        if ('pt_BR' === $locale) {
            // temporary set a locale for brazilian
            $locale = 'xbr';
        }

        if (\strlen($locale) > 3) {
            $locale = substr($locale, 0, -\strlen(strrchr($locale, '_')));
        }

        if (isset(self::$rules[$locale])) {
            $return = self::$rules[$locale]($number);

            if (!\is_int($return) || $return < 0) {
                return 0;
            }

            return $return;
        }

        /*
         * The plural rules are derived from code of the Zend Framework (2010-09-25),
         * which is subject to the new BSD license (http://framework.zend.com/license/new-bsd).
         * Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
         */
        switch ($locale) {
            case 'az':
            case 'bo':
            case 'dz':
            case 'id':
            case 'ja':
            case 'jv':
            case 'ka':
            case 'km':
            case 'kn':
            case 'ko':
            case 'ms':
            case 'th':
            case 'tr':
            case 'vi':
            case 'zh':
                return 0;

            case 'af':
            case 'bn':
            case 'bg':
            case 'ca':
            case 'da':
            case 'de':
            case 'el':
            case 'en':
            case 'eo':
            case 'es':
            case 'et':
            case 'eu':
            case 'fa':
            case 'fi':
            case 'fo':
            case 'fur':
            case 'fy':
            case 'gl':
            case 'gu':
            case 'ha':
            case 'he':
            case 'hu':
            case 'is':
            case 'it':
            case 'ku':
            case 'lb':
            case 'ml':
            case 'mn':
            case 'mr':
            case 'nah':
            case 'nb':
            case 'ne':
            case 'nl':
            case 'nn':
            case 'no':
            case 'oc':
            case 'om':
            case 'or':
            case 'pa':
            case 'pap':
            case 'ps':
            case 'pt':
            case 'so':
            case 'sq':
            case 'sv':
            case 'sw':
            case 'ta':
            case 'te':
            case 'tk':
            case 'ur':
            case 'zu':
                return (1 == $number) ? 0 : 1;

            case 'am':
            case 'bh':
            case 'fil':
            case 'fr':
            case 'gun':
            case 'hi':
            case 'hy':
            case 'ln':
            case 'mg':
            case 'nso':
            case 'xbr':
            case 'ti':
            case 'wa':
                return ((0 == $number) || (1 == $number)) ? 0 : 1;

            case 'be':
            case 'bs':
            case 'hr':
            case 'ru':
            case 'sh':
            case 'sr':
            case 'uk':
                return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);

            case 'cs':
            case 'sk':
                return (1 == $number) ? 0 : ((($number >= 2) && ($number <= 4)) ? 1 : 2);

            case 'ga':
                return (1 == $number) ? 0 : ((2 == $number) ? 1 : 2);

            case 'lt':
                return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);

            case 'sl':
                return (1 == $number % 100) ? 0 : ((2 == $number % 100) ? 1 : (((3 == $number % 100) || (4 == $number % 100)) ? 2 : 3));

            case 'mk':
                return (1 == $number % 10) ? 0 : 1;

            case 'mt':
                return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 1) && ($number % 100 < 11))) ? 1 : ((($number % 100 > 10) && ($number % 100 < 20)) ? 2 : 3));

            case 'lv':
                return (0 == $number) ? 0 : (((1 == $number % 10) && (11 != $number % 100)) ? 1 : 2);

            case 'pl':
                return (1 == $number) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 12) || ($number % 100 > 14))) ? 1 : 2);

            case 'cy':
                return (1 == $number) ? 0 : ((2 == $number) ? 1 : (((8 == $number) || (11 == $number)) ? 2 : 3));

            case 'ro':
                return (1 == $number) ? 0 : (((0 == $number) || (($number % 100 > 0) && ($number % 100 < 20))) ? 1 : 2);

            case 'ar':
                return (0 == $number) ? 0 : ((1 == $number) ? 1 : ((2 == $number) ? 2 : ((($number % 100 >= 3) && ($number % 100 <= 10)) ? 3 : ((($number % 100 >= 11) && ($number % 100 <= 99)) ? 4 : 5))));

            default:
                return 0;
        }
    }
247055
public function getByLocale(LocaleEntity $locale)
    {
        $app = Application::getFacadeApplication();
        $result = $this->find($locale);
        if ($result === null) {
            $em = $this->getEntityManager();
            try {
                $numTranslatable = (int) $app->make(TranslatableRepository::class)
                    ->createQueryBuilder('t')
                        ->select('count(t.id)')
                        ->getQuery()->getSingleScalarResult();
            } catch (NoResultException $x) {
                $numTranslatable = 0;
            }
            if ($numTranslatable === 0) {
                $numApprovedTranslations = 0;
            } else {
                try {
                    $numApprovedTranslations = (int) $app->make(TranslationRepository::class)
                    ->createQueryBuilder('t')
                        ->select('count(t.id)')
                        ->where('t.locale = :locale')->setParameter('locale', $locale)
                        ->andWhere('t.current = 1')
                        ->getQuery()->getSingleScalarResult();
                } catch (NoResultException $x) {
                    $numApprovedTranslations = 0;
                }
            }
            $result = LocaleStatsEntity::create($locale, $numTranslatable, $numApprovedTranslations);
            $em->persist($result);
            $em->flush($result);
        }

        return $result;
    }