Exemplo n.º 1
0
 /**
  * Get FQCN of specified entity
  *
  * @param object $object
  * @param bool   $escape Set TRUE to escape the class name for insertion into a route,
  *                       replacing \ with _ characters
  *
  * @return string
  */
 public function getClassName($object, $escape = false)
 {
     if (!is_object($object)) {
         return null;
     }
     $className = ClassUtils::getRealClass($object);
     return $escape ? $this->entityRoutingHelper->getUrlSafeClassName($className) : $className;
 }
Exemplo n.º 2
0
 /**
  * Gets definition for tag column.
  *
  * @param DatagridConfiguration $config
  *
  * @return array
  */
 protected function getColumnDefinition(DatagridConfiguration $config)
 {
     $className = $this->getEntityClassName($config);
     $urlSafeClassName = $this->entityRoutingHelper->getUrlSafeClassName($className);
     $permissions = ['oro_tag_create' => $this->securityFacade->isGranted(TagManager::ACL_RESOURCE_CREATE_ID_KEY), 'oro_tag_unassign_global' => $this->securityFacade->isGranted(TagManager::ACL_RESOURCE_REMOVE_ID_KEY)];
     return ['label' => 'oro.tag.tags_label', 'type' => 'callback', 'frontend_type' => 'tags', 'callable' => function (ResultRecordInterface $record) {
         return $record->getValue(self::COLUMN_NAME);
     }, 'editable' => false, 'translatable' => true, 'renderable' => $this->taggableHelper->isEnableGridColumn($className), 'inline_editing' => ['enable' => $this->securityFacade->isGranted(TagManager::ACL_RESOURCE_ASSIGN_ID_KEY), 'editor' => ['view' => 'orotag/js/app/views/editor/tags-editor-view', 'view_options' => ['permissions' => $permissions]], 'save_api_accessor' => ['route' => 'oro_api_post_taggable', 'http_method' => 'POST', 'default_route_parameters' => ['entity' => $urlSafeClassName], 'route_parameters_rename_map' => ['id' => 'entityId']], 'autocomplete_api_accessor' => ['class' => 'oroui/js/tools/search-api-accessor', 'search_handler_name' => 'tags', 'label_field_name' => 'name']]];
 }
Exemplo n.º 3
0
 /**
  * @param object $entity
  * @return array
  */
 public function getSupportedTargets($entity)
 {
     $targetEntities = $this->entityProvider->getEntities();
     $entityTargets = [];
     if (!is_object($entity) || !method_exists($entity, 'supportActivityTarget')) {
         return $entityTargets;
     }
     $count = count($targetEntities);
     for ($i = 0; $i < $count; $i++) {
         $targetEntity = $targetEntities[$i];
         $className = $targetEntity['name'];
         if (!empty($className) && $entity->supportActivityTarget($className)) {
             $entityTargets[] = ['label' => $targetEntity['label'], 'className' => $this->routingHelper->getUrlSafeClassName($targetEntity['name']), 'first' => !(bool) $i, 'gridName' => $this->getContextGridByEntity($className)];
             $i++;
         }
     }
     return $entityTargets;
 }
 /**
  * @param Config $config
  *
  * @return array
  */
 public function getActivityListOption(Config $config)
 {
     $entityConfigProvider = $this->configManager->getProvider('entity');
     $templates = [];
     foreach ($this->providers as $provider) {
         $hasComment = false;
         if ($provider instanceof CommentProviderInterface) {
             $hasComment = $provider->hasComments($this->configManager, $provider->getActivityClass());
         }
         $template = $provider->getTemplate();
         if ($provider instanceof ActivityListGroupProviderInterface && $config->get('oro_activity_list.grouping')) {
             $template = $provider->getGroupedTemplate();
         }
         $entityConfig = $entityConfigProvider->getConfig($provider->getActivityClass());
         $templates[$this->routingHelper->getUrlSafeClassName($provider->getActivityClass())] = ['icon' => $entityConfig->get('icon'), 'label' => $this->translator->trans($entityConfig->get('label')), 'template' => $template, 'routes' => $provider->getRoutes(), 'has_comments' => $hasComment];
     }
     return $templates;
 }
Exemplo n.º 5
0
 /**
  * @dataProvider getUrlSafeClassNameProvider
  */
 public function testGetUrlSafeClassName($src, $expected)
 {
     $this->assertEquals($expected, $this->entityRoutingHelper->getUrlSafeClassName($src));
 }