Programming Language PHP

Namespace Oro\Component\ChainProcessor

Class ContextInterface

Method/Function set

Total Examples 6

6 code examples of PHP Oro\Component\ChainProcessor\ContextInterface::set extracted from open source projects

Was this example useful?
0
                                                    /**
     * @param ContextInterface|TransitionContext $context
     */
    public function process(ContextInterface $context)
    {
        if (!$this->isApplicable($context)) {
            return;
        }

        $transitionForm = $context->getForm();

        $context->set(
            'template_parameters',
            [
                'transition' => $context->getTransition(),
                'workflowItem' => $context->getWorkflowItem(),
                'saved' => false,
                'form' => $transitionForm->createView(),
                'formErrors' => $transitionForm->getErrors(true),
            ]
        );
    }
                                            
Was this example useful?
0
                                                    /**
     * @param ContextInterface|TransitionContext $context
     */
    public function process(ContextInterface $context)
    {
        if ($context->getTransition()->isEmptyInitOptions()) {
            return;
        }

        $initData = $context->get(TransitionContext::INIT_DATA);
        $attribute = $context->getTransition()->getInitContextAttribute();

        $initData[$attribute] = $this->buttonSearchContextProvider->getButtonSearchContext();

        $context->set(TransitionContext::INIT_DATA, $initData);
        $context->set(TransitionContext::ENTITY_ID, null);
    }
                                            
Was this example useful?
0
                                                    /**
     * @param ContextInterface|TransitionContext $context
     */
    public function process(ContextInterface $context)
    {
        if (!$context->isStartTransition()) {
            return;
        }
        $context->set(TransitionContext::ENTITY_ID, $context->getRequest()->get('entityId', null));
        $context->set(TransitionContext::INIT_DATA, []);
    }
                                            
Was this example useful?
0
                                                    /**
     * @param ContextInterface|TransitionContext $context
     */
    public function process(ContextInterface $context)
    {
        //skip if custom failure handling were performed already or no failures met
        if (!$this->isApplicable($context)) {
            return;
        }

        try {
            throw $context->getError();
        } catch (HttpException $e) {
            $responseCode = $e->getStatusCode();
        } catch (WorkflowNotFoundException $e) {
            $responseCode = Response::HTTP_NOT_FOUND;
        } catch (UnknownAttributeException $e) {
            $responseCode = Response::HTTP_BAD_REQUEST;
        } catch (InvalidTransitionException $e) {
            $responseCode = Response::HTTP_BAD_REQUEST;
        } catch (ForbiddenTransitionException $e) {
            $responseCode = Response::HTTP_FORBIDDEN;
        } catch (\Throwable $e) {
            $responseCode = Response::HTTP_INTERNAL_SERVER_ERROR;
        } finally {
            $responseMessage = $e->getMessage();
        }

        $this->logger->error(
            '[TransitionHandler] Could not perform transition.',
            [
                'exception' => $context->getError(),
                'transition' => $context->getTransition(),
                'workflowItem' => $context->getWorkflowItem(),
            ]
        );

        $context->set('responseCode', $responseCode);
        $context->set('responseMessage', $responseMessage);
    }
                                            
Was this example useful?
0
                                                    /**
     * @param ContextInterface|TransitionContext $context
     */
    public function process(ContextInterface $context)
    {
        $transition = $context->getTransition();
        $attributeNames = array_keys($transition->getFormOptions()['attribute_fields']);

        $data = $context->getForm()->getData()->getValues($attributeNames);
        $initData = $context->get(TransitionContext::INIT_DATA) ?: [];

        $context->set(
            TransitionContext::INIT_DATA,
            array_merge(
                $data,
                $initData
            )
        );
    }
                                            
Was this example useful?
0
                                                    /**
     * @inheritdoc
     */
    public function process(ContextInterface $context)
    {
        /** @var CollectResourcesContext $context */
        $actionsConfig = [];
        $version = $context->getVersion();

        $resources = $context->getResult();
        $requestType = $context->getRequestType();
        /** @var ApiResource $resource */
        foreach ($resources as $resource) {
            $entityClass = $resource->getEntityClass();
            $actions = $this->getActionsConfig($entityClass, $version, $requestType);
            if (null !== $actions) {
                $actionsConfig[$entityClass] = $actions;
                $excludedActions = $this->getExcludedActions($actions);
                if (!empty($excludedActions)) {
                    $resource->setExcludedActions($excludedActions);
                }
            }
        }
        $context->set(self::ACTIONS_CONFIG_KEY, $actionsConfig);
    }