Execute an operaction

A successful operation will return result as an array.
An unsuccessful operation will return null.

@param  OperationInterface $op
@return array|null
555704
public function execute(OperationInterface $op)
  {
    try {
      if ($op instanceof DeleteOperationInterface) {
        $response = $this->httpClient->delete($op->getEndpoint(), [
          'headers' => $op->getHeaders(),
        ]);
      } elseif ($op instanceof PostOperationInterface) {
        $response = $this->httpClient->post($op->getEndpoint(), [
          'headers' => $op->getHeaders(),
          'body' => $op->getData(),
        ]);
      } elseif ($op instanceof PatchOperationInterface) {
        $response = $this->httpClient->patch($op->getEndpoint(), [
          'headers' => $op->getHeaders(),
          'body' => $op->getData(),
        ]);
      } elseif ($op instanceof PutOperationInterface) {
        $response = $this->httpClient->put($op->getEndpoint(), [
          'headers' => $op->getHeaders(),
          'body' => $op->getData(),
        ]);
      } else {
        $response = $this->httpClient->get($op->getEndpoint());
      }
    } catch (GuzzleHttp\Exception\ClientException $e) {
      throw new Exception\ClientException('ClientException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
    } catch (GuzzleHttp\Exception\ServerException $e) {
      throw new Exception\ServerException('ServerException occurred in request to Orchestrate: ' . $e->getMessage(), $e->getCode(), $e);
    }

    $refLink = null;
    $location = null;

    if ($response->hasHeader('ETag')) {
      $refLink = str_replace('"', '', $response->getHeaderLine('ETag'));
    } elseif ($response->hasHeader('Link')) {
      $refLink = str_replace(
        ['<', '>; rel="next"'],
        ['', ''],
        $response->getHeaderLine('Link')
      );
    }

    if ($response->hasHeader('Location')) {
      $location = $response->getHeaderLine('Location');
    }
    $rawValue = $response->getBody(true);
    $value = json_decode($rawValue, true);

    return $op->getObjectFromResponse($refLink, $location, $value, $rawValue);
  }
937312
protected function exec($service, $operation, $params, $context)
	{
	    // Perform operation and fetch first result
	    return $this->serviceBroker()
    	    ->service($service)
    	    ->context($context)
    	    ->until(array($this, '_break'))
    	    ->exec($operation, $params)
    	    ->first();
	}
497160
protected function doCall($operation)
    {
        $this->client->send($operation);
        $result = $this->client->recv();
        if(false === $result)
        {
            return false;
        }
        if(null === $result->throwable)
        {
            return $result->result;
        }
        else
        {
            throw $result->throwable;
        }
    }
853403
protected function fireOnOperationException($operation, OperationArguments $args, Exception $exception)
    {
        $returnValue = null;
        $this->getEventManager()->triggerEvent(
            new OperationEvent('onOperationException', $this, $operation, $args, $returnValue, $exception)
        );
    }
863692
protected function returnAccessRelatedObject(EntityInterface $entity, $operation, $account) {
    $related_object = $entity->get('field_activity_entity')->getValue();
    if (!empty($related_object)) {
      $ref_entity_type = $related_object['0']['target_type'];
      $ref_entity_id = $related_object['0']['target_id'];
      $ref_entity = entity_load($ref_entity_type, $ref_entity_id);

      return AccessResult::allowedIf($ref_entity->access($operation, $account));
    }
  }
296038
public function removeOperation(OperationInterface $operation)
    {
        if ($this->operations->contains($operation)) {
            $this->operations->removeElement($operation);
        }

        return $this;
    }
1192489
private function runOperation(Operation $operation)
    {
        try {
            return $this->runner->run($operation);
        } catch (\Throwable $e) {
            // treated below
        } catch (\Exception $e) {
            // treated below
        }

        // @todo keep only inner if once ExceptionCatcher is gone
        if ($this->exceptionCatcherVoter instanceof ThrowableCatcherVoter) {
            if (!$this->exceptionCatcherVoter->shouldCatchThrowable($e)) {
                throw $e;
            }
        } elseif (!$this->exceptionCatcherVoter->shouldCatch($e)) {
            throw $e;
        }

        try {
            $this->waitStrategy->wait();
        } catch (WaiterException $waiterException) {
            throw $e;
        }

        return $this->runOperation($operation);
    }
804161
public function getOperand($i)
    {
        return ($i < count($this->operands)) ? $this->operands[$i] : null;
    }
1050234
public function getOperation($operation)
    {
        $operationId = Utilities::getEntityId(
            $operation,
            'WindowsAzure\MediaServices\Models\Operation'
        );

        return Operation::createFromOptions($this->_getEntity("Operations('{$operationId}')"));
    }
1145909
public function process($src, OperationInterface $operation)
    {
        $argument = $operation->getValue();
        $operator = $operation->getOperator();
        $field = $operation->getField();
        switch ($operator) {
            case FilterOperation::OPERATOR_STR_STARTS_WITH:
                $operator = FilterOperation::OPERATOR_LIKE;
                $argument .= '%';
                break;
            case FilterOperation::OPERATOR_STR_ENDS_WITH:
                $operator = FilterOperation::OPERATOR_LIKE;
                $argument = '%' . $argument;
                break;
            case FilterOperation::OPERATOR_STR_CONTAINS:
                $operator = FilterOperation::OPERATOR_LIKE;
                $argument = '%' . $argument . '%';
                break;
        }
        $src->conditions[]  = "$field $operator :$field";
        $src->bindings[':' . $field] = $argument;
        return $src;
    }
715554
public function after(
        CommandInterface $command,
        RequestInterface $request,
        Operation $operation
    ) {
        $data = $this->formParamsData;
        $this->formParamsData = [];
        $modify = [];

        // Add additional parameters to the form_params array
        $additional = $operation->getAdditionalParameters();
        if ($additional && $additional->getLocation() == $this->locationName) {
            foreach ($command->toArray() as $key => $value) {
                if (!$operation->hasParam($key)) {
                    $data['form_params'][$key] = $this->prepareValue($value, $additional);
                }
            }
        }

        $body = http_build_query($data['form_params'], '', '&');
        $modify['body'] = Psr7\stream_for($body);
        $modify['set_headers']['Content-Type'] = $this->contentType;
        $request = Psr7\modify_request($request, $modify);

        return $request;
    }
149121
public function execute(StorageInterface $storage, Operations $operations)
    {
        foreach ($operations->getOperations() as $operation) {
            if ($operation instanceof AddDocumentOperation) {
                $document = $operation->getDocument();
                $event = new DocumentEvent($document);
                if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_ADD_DOCUMENT, $event)
                    ->isPropagationStopped()
                ) {
                    continue;
                }

                $storage->addDocument($document);

                $event = new DocumentEvent($document);
                $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_ADD_DOCUMENT, $event);
            } elseif ($operation instanceof AddIdentityOperation) {
                throw new InvalidArgumentException('Add identity command not supported by run().');
            } elseif ($operation instanceof UpdateDocumentOperation) {
                $document = $operation->getDocument();
                $event = new DocumentEvent($document);
                if ($this->eventDispatcher->dispatch(IndexerEvents::BEFORE_STORAGE_UPDATE_DOCUMENT, $event)->isPropagationStopped()) {
                    continue;
                }

                $storage->updateDocument($document);

                $event = new DocumentEvent($document);
                $this->eventDispatcher->dispatch(IndexerEvents::STORAGE_UPDATE_DOCUMENT, $event);
            } elseif ($operation instanceof UpdateIdentityOperation) {
                throw new InvalidArgumentException('Update identity command not supported by run().');
            } elseif ($operation instanceof DeleteDocumentOperation) {
                $storage->deleteDocument($operation->getDocument());
            } elseif ($operation instanceof DeleteIdentityOperation) {
                $storage->delete($operation->getIdentity());
            } elseif ($operation instanceof DeleteTypeOperation) {
                $storage->deleteType($operation->getType());
            } elseif ($operation instanceof DeleteAllOperation) {
                $storage->deleteAll();
            } elseif ($operation instanceof FlushOperation) {
                if ($storage instanceof Flushable) {
                    $storage->flush();
                }
            } elseif ($operation instanceof OptimizeOperation) {
                if ($storage instanceof Optimizable) {
                    $storage->optimize();
                }
            } elseif ($operation instanceof CommitOperation) {
                if ($storage instanceof Commitable) {
                    $storage->commit();
                }
            } elseif ($operation instanceof RollbackOperation) {
                if ($storage instanceof Rollbackable) {
                    $storage->rollback();
                }
            }
        }

        return true;
    }
192691
protected function getOperationAsArray(FetcherOperation $operation)
    {
        $filters = array();

        if ($operation instanceof SimpleOperation) {
            $filters = $this->addSimpleOperation($operation);
        } else if ($operation instanceof ListOperation) {
            $operations = $operation->getOperations();

            if ($operation->getOperator() === Fetcher::OPERATOR_OR) {
                $filters['$or'] = array_map(
                    function (FetcherOperation $operation) {
                        return $this->getOperationAsArray($operation);
                    },
                    $operations
                );
            } else {
                foreach ($operations as $currentOperation) {
                    $currentFilters = $this->getOperationAsArray($currentOperation);
                    $filters = array_merge_recursive($filters, $currentFilters);
                }
            }
        } else {
            throw new \InvalidArgumentException('Given operation is not supported');
        }

        return $filters;
    }
54927
public function addOperation(OperationInterface $operation)
    {
        $this->operations[$operation->getName()] = $operation->setServiceDescription($this);

        return $this;
    }
35140
protected function getLogObject(LdapOperationInterface $operation)
    {
        if (!$this->logger) {
            return null;
        }

        return (new LogOperation($operation))->setDomain($this->connection->getConfig()->getDomainName());
    }
924523
private function createOperationOutput(array &$output, OperationInterface $operation)
    {
        $operationHandler = $this->getOperationHandler($operation);

        if (!$operationHandler) {
            return;
        }

        $output[] = '';

        $urlGenerator = $this->getUrlGenerator(
            $operationHandler->extractSourceUrl($operation)
        );

        $output = array_merge(
            $output,
            $operationHandler->getOutput($operation, $urlGenerator)
        );
    }
1045053
public function addOperation(Operation $operation)
    {
        $this->operations[$operation->name] = $operation;
        ksort($this->operations);
    }