Exemplo n.º 1
0
 public function getActivities(AggregateRootTypeInterface $aggregate_root_type)
 {
     $workflow_activities = [];
     $state_machine = $this->service_locator->getWorkflowService()->getStateMachine($aggregate_root_type);
     foreach ($state_machine->getStates() as $state) {
         if (preg_match('/_task$/', $state->getName())) {
             continue;
             // final states can't have activities
         }
         $step_activities = new ActivityMap();
         if (!$state->isFinal()) {
             foreach ($state_machine->getTransitions($state->getName()) as $event_name => $transitions) {
                 $step_activities->setItem($event_name, $this->createWorkflowActivity($aggregate_root_type, $event_name));
             }
             $read_only_actions = [];
             if ($state->hasOption('read_only_actions')) {
                 $read_only_actions = $state->getOption('read_only_actions')->toArray();
             }
             foreach ($read_only_actions as $action_name => $read_only_action) {
                 $step_activities->setItem($action_name, $this->createReadOnlyActivity($aggregate_root_type, $action_name, $read_only_action));
             }
         }
         $workflow_activities[$state->getName()] = $step_activities;
     }
     return $workflow_activities;
 }
 protected function renderEmbeddedEntityTypeSelectorMap()
 {
     $embed_type_selector_map = new ActivityMap();
     $selector_td = $this->getDefaultTranslationDomain();
     foreach ($this->attribute->getEmbeddedEntityTypeMap()->getKeys() as $embedded_type_prefix) {
         $embed_type_selector_map->setItem($embedded_type_prefix, new Activity(['name' => $embedded_type_prefix, 'label' => $this->_($embedded_type_prefix, $selector_td), 'url' => Url::createUri('#' . $embedded_type_prefix), 'settings' => new Settings()]));
     }
     $view_scope = $this->getOption('view_scope');
     $default_settings = ['view_scope' => $view_scope];
     $renderer_config = $this->view_config_service->getRendererConfig($view_scope, $this->output_format, $embed_type_selector_map, $default_settings);
     return $this->renderer_service->renderSubject($embed_type_selector_map, $this->output_format, $renderer_config);
 }
 protected function buildActivityContainerMap()
 {
     $activity_container_map = new ActivityContainerMap();
     foreach ($this->loadActivitiesConfig() as $scope => $container_data) {
         $activity_map = new ActivityMap();
         foreach ($container_data['activities'] as $name => $activity) {
             $activity['settings'] = new Settings($activity['settings']);
             $activity['url'] = $this->buildUrl($activity['url']);
             $activity_map->setItem($name, new Activity($activity));
         }
         $container_data['activity_map'] = $activity_map;
         $container_data['scope'] = $scope;
         $activity_container_map->setItem($scope, new ActivityContainer($container_data));
     }
     return $activity_container_map;
 }
 protected function getInnerActivityCustomTemplateActivityMap()
 {
     // create activity map
     $activity_map = new ActivityMap();
     $activities = array_slice($this->sample_activities, -4);
     // default_activity_name activity must be included
     foreach ($activities as $key => $activity_custom_state) {
         $activity_settings = ['form_id' => 'randomId-' . rand()];
         $activity_state = ['name' => $key, 'label' => $activity_custom_state['activity']['label'], 'type' => Activity::TYPE_GENERAL, 'description' => $activity_custom_state['activity']['description'], 'verb' => 'read', 'rels' => $activity_custom_state['activity']['rels'], 'settings' => new Settings($activity_settings), 'url' => new Url(['type' => Url::TYPE_URI, 'value' => $activity_custom_state['link']])];
         $activity = new Activity($activity_state);
         $activity_map->setItem($key, $activity);
     }
     // render map
     // provide custom settings for a specific activity of the map
     $render_settings = ['emphasized' => true, 'default_activity_name' => 'mutating', 'default_activity_rels' => 'promote', 'activity.mutating' => ['template' => 'html/dummy/activity_custom_template.twig'], 'activity.warning' => ['template' => 'html/dummy/activity_custom_template.twig']];
     return $this->renderSubject($activity_map, $render_settings);
 }
Exemplo n.º 5
0
 public function getContainer($scope)
 {
     $this->ensureIsInitialize();
     $scope_key = $this->resolveScopeKey($scope);
     $container = $this->getContainers()->getItem($scope_key->getScopeKey());
     if (!$container) {
         throw new RuntimeError(sprintf('No activity container found for scope key "%s" from given scope: %s', $scope_key->getScopeKey(), is_object($scope) ? get_class($scope) : print_r($scope, true)));
     }
     $activity_map = new ActivityMap();
     $user = $this->environment->getUser();
     foreach ($container->getActivityMap() as $activity_name => $activity) {
         if ($user->isAllowed($scope, $activity_name)) {
             $activity_map->setItem($activity_name, $activity);
         }
     }
     $container_state = ['scope' => $scope_key->getScopeKey(), 'activity_map' => $activity_map];
     return new ActivityContainer($container_state);
 }