Esempio n. 1
0
 public function testGetEntity()
 {
     $entityName = 'Acme:Test';
     $entityClassName = 'Acme\\Entity\\Test';
     $entityConfig = $this->getEntityConfig($entityClassName, ['label' => 'Test Label', 'plural_label' => 'Test Plural Label', 'icon' => 'icon-test']);
     $this->entityConfigProvider->expects($this->any())->method('getConfig')->with($entityClassName)->will($this->returnValue($entityConfig));
     $result = $this->provider->getEntity($entityName);
     $expected = ['name' => $entityClassName, 'label' => 'Test Label', 'plural_label' => 'Test Plural Label', 'icon' => 'icon-test'];
     $this->assertEquals($expected, $result);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function getEntitiesMetadata()
 {
     $result = [];
     foreach ($this->getChannelEntities() as $entityName) {
         $entityConfig = $this->entityProvider->getEntity($entityName, true);
         $extendConfig = $this->configManager->getProvider('extend')->getConfig($entityName);
         $configEntityModel = $this->configManager->getConfigEntityModel($entityName);
         if ($configEntityModel instanceof EntityConfigModel) {
             $entityConfig = array_merge($entityConfig, $this->getEntityLinks($configEntityModel));
         }
         $result[$entityName] = array_merge($entityConfig, ['type' => $extendConfig->get('owner')]);
     }
     return $result;
 }
 /**
  * @param string $relatedEntityName
  * @param array  $relation
  * @param bool   $translate
  *
  * @return array
  */
 protected function addEntityDetails($relatedEntityName, array &$relation, $translate)
 {
     $entity = $this->entityProvider->getEntity($relatedEntityName, $translate);
     foreach ($entity as $key => $val) {
         if (!in_array($key, ['name'])) {
             $relation['related_entity_' . $key] = $val;
         }
     }
     return $relation;
 }
 /**
  * Adds a relation to $result
  *
  * @param array  $result
  * @param string $name
  * @param string $type
  * @param string $label
  * @param string $relationType
  * @param string $relatedEntityName
  * @param bool   $withEntityDetails
  * @param int    $relationDeepLevel
  * @param bool   $lastDeepLevelRelations
  */
 protected function addRelation(array &$result, $name, $type, $label, $relationType, $relatedEntityName, $withEntityDetails, $relationDeepLevel, $lastDeepLevelRelations)
 {
     $relation = array('name' => $name, 'type' => $type, 'label' => $label, 'relation_type' => $relationType, 'related_entity_name' => $relatedEntityName);
     if ($withEntityDetails) {
         $entity = $this->entityProvider->getEntity($relatedEntityName);
         foreach ($entity as $key => $val) {
             if (!in_array($key, ['name'])) {
                 $relation['related_entity_' . $key] = $val;
             }
         }
     }
     if ($relationDeepLevel >= 0) {
         // set some exceptions
         // todo: we need to find more proper way to do this
         if ($relationDeepLevel > 0 && ($name === 'owner' || $name === 'createdBy' || $name === 'updatedBy')) {
             $relationDeepLevel = 0;
         }
         $relation['related_entity_fields'] = $this->getFields($relatedEntityName, $withEntityDetails && ($relationDeepLevel > 0 || $lastDeepLevelRelations), $withEntityDetails, $relationDeepLevel, $lastDeepLevelRelations);
     }
     $result[] = $relation;
 }