Ejemplo n.º 1
0
 /**
  * Get class alias of specified entity
  *
  * @param object $object
  * @param bool   $isPlural
  *
  * @return null|string
  */
 public function getClassAlias($object, $isPlural = false)
 {
     if (!is_object($object)) {
         return null;
     }
     $className = ClassUtils::getRealClass($object);
     return $isPlural ? $this->entityAliasResolver->getPluralAlias($className) : $this->entityAliasResolver->getAlias($className);
 }
Ejemplo n.º 2
0
 /**
  * @param Tag $tag
  *
  * @return array ['' => [count], $alias => [count, icon, label, class => true]]
  */
 public function getTagEntitiesStatistic(Tag $tag)
 {
     $groupedResult = $this->getGroupedTagEntities($tag);
     return array_reduce($groupedResult, function ($result, array $entityResult) {
         $result['']['count'] += $entityResult['cnt'];
         $entityClass = $entityResult['entityClass'];
         $alias = $this->entityAliasResolver->getAlias($entityClass);
         $result[$alias] = ['count' => $entityResult['cnt'], 'icon' => $this->entityConfigProvider->getConfig($entityClass)->get('icon'), 'label' => $this->entityConfigProvider->getConfig($entityClass)->get('plural_label'), 'class' => true];
         return $result;
     }, ['' => ['count' => 0]]);
 }
Ejemplo n.º 3
0
 public function testGetAliasCache()
 {
     $entityAliasProvider = $this->getMock('Oro\\Bundle\\EntityBundle\\Provider\\EntityAliasProviderInterface');
     $entityAliasProvider->expects($this->once())->method('getEntityAlias')->with('Test\\Entity1')->willReturn(new EntityAlias('entity1_alias', 'entity1_plural_alias'));
     $this->entityAliasResolver->addProvider($entityAliasProvider);
     $this->assertEquals('entity1_alias', $this->entityAliasResolver->getAlias('Test\\Entity1'));
     // test that the result is cached
     $this->assertEquals('entity1_alias', $this->entityAliasResolver->getAlias('Test\\Entity1'));
 }