4.6.3 getRenderOptions

La méthode getRenderOptions() permet de modifier les options de rendu des paramètres de transition.

Dcp\Ui\RenderOptions getRenderOptions(string $transitionId)

Les options de rendu des paramètres de transition se gèrent comme des options de rendu d'attribut.

4.6.3.1 Exemples

  • Modifier le rendu des relations de la transition myFirstTransition

    namespace My;
    class CustomRender extends \Dcp\Ui\TransitionRender {
        /**
           @return \Dcp\Ui\RenderOptions
           @throws \Dcp\Ui\Exception
         */
        public function getRenderOptions($transitionId)
        {
            $options = parent::getRenderOptions($transitionId);
     
            if (transitionId === My_wfl::myFirstTransition)
                $parameters = $this->getTransitionParameters($transitionId);
     
                foreach ($parameters as & $ask) {
                    $attribute = $this->workflow->getAttribute($ask->getId());
                    if ($attribute && $attribute->type === "docid") {
                        $options->docid($attribute->id)
                            ->setPlaceHolder($attribute->getLabel())
                            ->setLabelPosition("none");
                    }
                }
            }
            return $options;
        }
    }
  • Déplacer le label de l'attribut sur celui du cadre si le cadre contient un seul paramètre.

    namespace My;
    class CustomRender extends \Dcp\Ui\TransitionRender {
        /**
           @return \Dcp\Ui\RenderOptions
           @throws \Dcp\Ui\Exception
         */
        public function getRenderOptions($transitionId)
            $options = parent::getRenderOptions($transitionId);
     
            $parameters = $this->getTransitionParameters($transitionId);
     
            if (count($parameters) === 2) { // frame included
                foreach ($parameters as & $ask) {
                    $attribute = $this->workflow->getAttribute($ask->getId());
                    if ($attribute && ($attribute->id !== self::parameterFrameAttribute) {
                        //hide attribute label
                        $options->commonOption($attribute->id)->setLabelPosition(
                            \Dcp\Ui\CommonRenderOptions::nonePosition
                        );
                        // set frame label to attribute label
                        $options->frame(self::parameterFrameAttribute)
                            ->setAttributeLabel($attribute->getLabel());
                    }
                }
            }
            return $options;
        }
    }
×