/**
  * Create workflows for a manager.
  *
  * @param Manager $manager      The workflow manager.
  * @param string  $providerName The provider name.
  * @param string  $workflowType THe workflow type.
  *
  * @return void
  */
 private function createWorkflows(Manager $manager, $providerName, $workflowType)
 {
     if ($workflowType) {
         $collection = WorkflowModel::findByProviderAndType($providerName, $workflowType);
     } else {
         $collection = WorkflowModel::findByProvider($providerName);
     }
     while ($collection && $collection->next()) {
         $workflow = new Workflow($collection->name, $collection->providerName, $collection->label, array_merge($collection->row(), array(Definition::SOURCE => Definition::SOURCE_DATABASE)));
         $event = new CreateWorkflowEvent($workflow);
         $this->getServiceContainer()->getEventDispatcher()->dispatch($event::NAME, $event);
         $manager->addWorkflow($workflow);
     }
 }
 /**
  * Get all permissions of a specific workflow.
  *
  * @param \DataContainer $dataContainer The data container driver.
  *
  * @return array
  */
 public function getWorkflowPermissions($dataContainer)
 {
     if (!$dataContainer->activeRecord || !$dataContainer->activeRecord->pid) {
         return array();
     }
     $workflow = WorkflowModel::findBy('id', $dataContainer->activeRecord->pid);
     $options = array();
     if ($workflow) {
         $permissions = deserialize($workflow->permissions, true);
         foreach ($permissions as $config) {
             $permission = WorkflowPermission::forWorkflowName($workflow->name, $config['name']);
             $options[(string) $permission] = $config['label'] ?: $config['name'];
         }
     }
     return $options;
 }
Beispiel #3
0
 /**
  * Adjust the input mask.
  *
  * @param \DataContainer $dataContainer Data container.
  *
  * @return void
  */
 public function adjustEditMask($dataContainer)
 {
     $workflow = WorkflowModel::findByPk(CURRENT_ID);
     $typeProvider = $this->getServiceProvider()->getTypeProvider();
     if (!$workflow || !$typeProvider->hasType($workflow->type)) {
         return;
     }
     $workflowType = $typeProvider->getType($workflow->type);
     if ($workflowType->hasFixedSteps()) {
         $GLOBALS['TL_DCA']['tl_workflow_step']['fields']['name']['inputType'] = 'select';
         $GLOBALS['TL_DCA']['tl_workflow_step']['fields']['name']['options'] = $workflowType->getStepNames();
         $GLOBALS['TL_DCA']['tl_workflow_step']['fields']['name']['eval']['includeBlankOption'] = true;
     } else {
         $GLOBALS['TL_DCA']['tl_workflow_step']['fields']['name']['save_callback'][] = array('Netzmacht\\Workflow\\Contao\\Backend\\Common', 'createName');
     }
 }
Beispiel #4
0
 /**
  * Initialize role translations.
  *
  * @return void
  *
  * @SuppressWarnings(PHPMD.Superglobals)
  */
 private function initializePermissionTranslations()
 {
     $workflows = WorkflowModel::findAll();
     if (!$workflows) {
         return;
     }
     while ($workflows->next()) {
         $permissions = deserialize($workflows->permissions, true);
         foreach ($permissions as $permission) {
             $name = $workflows->name . ':' . $permission['name'];
             // only set if not already set. allow to customize permission labels by language files
             if (!isset($GLOBALS['TL_LANG']['workflow_permissions'][$name])) {
                 $GLOBALS['TL_LANG']['workflow_permissions'][$name] = $permission['label'] ?: $permission['name'];
             }
         }
         $GLOBALS['TL_LANG']['workflow_permissions'][$workflows->name . ':be_admin'] = $GLOBALS['TL_LANG']['workflow_permissions']['be_admin'];
         $GLOBALS['TL_LANG']['workflow_permissions'][$workflows->name . ':fe_guest'] = $GLOBALS['TL_LANG']['workflow_permissions']['fe_guest'];
     }
 }
 /**
  * Get entity properties.
  *
  * @param \DataContainer $dataContainer Data container driver.
  *
  * @return array
  */
 public function getEntityProperties($dataContainer)
 {
     if ($dataContainer->activeRecord) {
         $workflow = WorkflowModel::findByPk($dataContainer->activeRecord->pid);
         if ($workflow) {
             return array_map(function ($info) {
                 return $info['name'];
             }, array_filter($this->database->listFields($workflow->providerName), function ($info) {
                 return $info['type'] !== 'index';
             }));
         }
     }
     return array();
 }