Normalize by fetching workflow states of each $objects.

@param ModelState|array $objects
@param array            $processes
@param bool             $onlySuccess

@throws \InvalidArgumentException
184974
public function setStates($objects, $processes, $onlySuccess)
    {
        $objects = ( ! is_array($objects) && ! $objects instanceof \ArrayAccess) ? array($objects) : $objects;

        if (0 === count($objects)) {
            return;
        }

        $ordersIndexedByWorkflowIdentifier = array();
        foreach ($objects as $object) {
            if (!$object instanceof ModelStateInterface) {
                throw new \InvalidArgumentException();
            }

            $ordersIndexedByWorkflowIdentifier[$object->getWorkflowIdentifier()] = $object;
        }

        $qb = $this->getEntityManager()->createQueryBuilder();
        $qb->select('ms')
            ->from('Lexik\Bundle\WorkflowBundle\Entity\ModelState', 'ms')
            ->andWhere($qb->expr()->in('ms.workflowIdentifier', array_keys($ordersIndexedByWorkflowIdentifier)))
            ->orderBy('ms.id');

        if (count($processes)) {
            $qb->andWhere($qb->expr()->in('ms.processName', $processes));
        }

        if ($onlySuccess) {
            $qb->andWhere('ms.successful = 1');
        }

        $states = $qb->getQuery()->getResult();

        foreach ($states as $state) {
            $ordersIndexedByWorkflowIdentifier[$state->getWorkflowIdentifier()]->addState($state);
        }
    }
53868
private function setStatusInternal($status)
	{
		if ( $status !== null && ! $status instanceof StatusInterface) {
			throw new WorkflowException('Status instance expected');
		}

		$this->_status = $status;

		$statusId = ($status === null ? null : $status->getId());
		if ($this->getStatusConverter() != null ) {
			$statusId = $this->_statusConverter->toModelAttribute($statusId);
		}

		$this->owner->{$this->statusAttribute} = $statusId;
	}
219099
public function cleanAuthorization($references, WorkflowRightInterface $workflowRight)
    {
        $authorizations = $workflowRight->getAuthorizations();
        $indexAuthorizations = $this->indexList($authorizations, "getReferenceId", "AuthorizationInterface");

        $indexReferences = $this->indexList($references, "getId", "ReferenceInterface");

        $AuthorizationNotInReference = array_diff_key($indexAuthorizations, $indexReferences);
        foreach ($AuthorizationNotInReference as $remove) {
            $workflowRight->removeAuthorization($remove);
        }

        $authorizationClass = $this->authorizationClass;
        $ReferenceNotInAuthorization = array_diff_key($indexReferences, $indexAuthorizations);
        foreach ($ReferenceNotInAuthorization as $add) {
            $authorization = new $authorizationClass();
            $authorization->setReferenceId($add->getId());
            $workflowRight->addAuthorization($authorization);
        }

        return $workflowRight;
    }
879337
protected function normalizeAsArray($objects) : array
    {
        $key = $this->relation;

        if (!is_array($objects) && !$objects instanceof Collection) {
            throw new MappingException("column '$key' should be of type array or collection");
        }

        if ($objects instanceof Collection) {
            $objects = $objects->all();
        }

        $normalizedObjects = [];

        foreach ($objects as $object) {
            $wrapper = $this->factory->make($object);
            $normalizedObjects[] = $wrapper->getEntityAttributes();
        }

        if ($this->asJson) {
            $normalizedObjects = json_encode($normalizedObjects);
        }

        return [$key => $normalizedObjects];
    }
936715
@Override
    public <T> T onlyOne(Class<T> serviceClass) {
        Collection<T> all = all(serviceClass);
        if (all.size() == 1) {
            return all.iterator().next();
        }
        if (all.size() > 1) {
            throw new IllegalStateException(
                "Multiple service implementations found for " + serviceClass + ": " + toClassString(all));
        }
        return null;
    }
152769
public function process($name, array $ids = [])
    {
        $allowActions = $this->getConfig('actions');

        if (!Arr::key($name, $allowActions)) {
            throw new \InvalidArgumentException(__d('core', 'Invalid action to perform'));
        }

        $action = $allowActions[$name];
        if ($action === false) {
            throw new \InvalidArgumentException(__d('core', 'Action "{0}" is disabled', $name));
        }

        if (Arr::in($action, get_class_methods($this->_table))) {
            return $this->_table->{$action}($ids);
        }

        return $this->{$action}($ids);
    }
82637
public function params(array $keys = array(), $onlyExistingParams = false)
    {
        if(count($keys) == 0)
            return $this->params;

        $params = array();

        foreach($keys as $key) {
            $key = trim($key);

            if($onlyExistingParams && isset($this->params[$key]))
                $params[$key] = $this->params[$key];
            else
                $params[$key] = isset($this->params[$key]) ? $this->params[$key] : null;
        }

        return $params;
    }
542026
public function setObjects(array $objects)
    {
        foreach ($objects as $object) {
            $this->checkType(ObjectInFolderDataInterface::class, $object);
        }

        $this->objects = $objects;
    }
4647
public function initializeObject($initializationCause)
    {
        if ($initializationCause === ObjectManagerInterface::INITIALIZATIONCAUSE_CREATED) {
            if ($this->async === false) {
                $this->refresh();
            }
        }
    }
287271
public function update(array $objects) {
        $requests = [];

        foreach ($objects as $object) {
            $requests[] = [
                'method' => 'cmdb.object.update',
                'params' => $object
            ];
        }

        $this->api->batchRequest($requests);

        return $this;
    }
491827
public function only($keys)
    {
        $keys = is_array($keys) ? $keys : func_get_args();

        return array_only($this->parameters, $keys);
    }
1162434
private function createObjectFromRequestAndProcess(
        TransactionData $transactionData,
        callable $process
    ) {
        $object = $this->parseRequestObject($transactionData->getRequest());

        return $process($transactionData, $object);
    }
172873
private function buildObjectStateFilterParameters(ParameterBuilderInterface $builder, array $groups = []): void
    {
        $builder->add(
            'filter_by_object_state',
            ParameterType\Compound\BooleanType::class,
            [
                'groups' => $groups,
            ]
        );

        $builder->get('filter_by_object_state')->add(
            'object_states',
            EzParameterType\ObjectStateType::class,
            [
                'multiple' => true,
                'groups' => $groups,
            ]
        );
    }
1003841
public function setObjects($objects)
    {
        if (!is_array($objects)) {
            $objects = [$objects];
        }

        $this->objects = [];
        foreach ($objects as $object) {
            if (is_string($object) || is_resource($object)) {
                $this->objects[] = Reader::read($object);
            } elseif ($object instanceof Component) {
                $this->objects[] = $object;
            } else {
                throw new \InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component arguments to setObjects');
            }
        }
    }
208735
public function normalize($object, $format = null, array $context = [])
    {
        if (!$object instanceof ResourceCollection) {
            throw new \InvalidArgumentException(sprintf(
                'The normalizer support only "%s" but "%s" given.',
                ResourceCollection::class,
                is_object($object) ? get_class($object) : gettype($object)
            ));
        }

        $data = [];
        $links = [];

        if (count($object->getRelations())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getRelations(), $format, $context));
        }

        if (count($object->getActions())) {
            $links = array_merge($links, $this->normalizer->normalize($object->getActions(), $format, $context));
        }

        foreach ($object as $resource) {
            $data[] = $this->normalizer->normalize($resource, $format, $context);
        }

        if (count($links)) {
            return [
                '_links' => $links,
                '_embedded' => [
                    'items' => $data,
                ],
            ];
        }

        return $data;
    }
958938
public function normalize($object, $format = null, array $context = [])
    {
        /* @var \Apigee\Edge\Structure\CredentialProductInterface $object */
        return (object) [
            'apiproduct' => $object->getApiproduct(),
            'status' => $object->getStatus(),
        ];
    }
131624
public function normalize($object, $format = null, array $context = [])
    {
        foreach ($this->normalizers as $normalizer) {
            // Return the result from the first denormalizer that can
            // denormalize this.
            if ($normalizer->supportsNormalization($object, $format)) {
                return $normalizer->normalize($object, $format, $context);
            }
        }
    }