public function testHasAliasCacheForDisabledAlias() { $this->metadataFactory->expects($this->any())->method('getAllMetadata')->willReturn([new ClassMetadata('Test\\Entity1')]); $entityAliasProvider = $this->getMock('Oro\\Bundle\\EntityBundle\\Provider\\EntityAliasProviderInterface'); $entityAliasProvider->expects($this->once())->method('getEntityAlias')->with('Test\\Entity1')->willReturn(false); $this->entityAliasResolver->addProvider($entityAliasProvider); $this->assertFalse($this->entityAliasResolver->hasAlias('Test\\Entity1')); // test that the result is cached $this->assertFalse($this->entityAliasResolver->hasAlias('Test\\Entity1')); }
/** * @param string $entityClass * * @return string|null */ protected function getEntityResourceUri($entityClass) { $uri = null; if ($this->entityAliasResolver->hasAlias($entityClass)) { try { $uri = $this->router->generate('oro_rest_api_cget', ['entity' => $this->entityAliasResolver->getPluralAlias($entityClass)]); } catch (RoutingException $e) { // ignore any exceptions } } if ($uri) { $baseUrl = $this->router->getContext()->getBaseUrl(); if ($baseUrl) { $uri = substr($uri, strlen($baseUrl)); } } return $uri; }
/** * {@inheritdoc} */ public function isIgnoredEntity($className) { return !$this->entityAliasResolver->hasAlias($className); }