Takes an account-entity and the id of a media and adds the media as the logo of the account.
TODO: handle logo adding differently and remove this method (or make it private).

@param Account $account
@param int $mediaId
966194
public function setLogo($account, $mediaId)
    {
        $media = $this->mediaManager->getEntityById($mediaId);
        $account->setLogo($media);
    }
1096037
private function setParent($parentData, AccountInterface $account)
    {
        if (null != $parentData && isset($parentData['id']) && 'null' != $parentData['id'] && '' != $parentData['id']) {
            $parent = $this->getRepository()->findAccountById($parentData['id']);
            if (!$parent) {
                throw new EntityNotFoundException($this->getAccountEntityName(), $parentData['id']);
            }
            $account->setParent($parent);
        } else {
            $account->setParent(null);
        }
    }
432289
public function postAction($id, Request $request)
    {
        return $this->addMediaToEntity($this->getContactEntityName(), $id, $request->get('mediaId', ''));
    }
876674
public function fetchPermanentImage ($mediaID, $into = null)
    {
        return new Downloaded\Image($mediaID, $this->doPermanentFetchToStream($mediaID, $into));
    }
1340389
public function setAccountId($id)
    {
        if (!empty($id) && ctype_print($id)) {
            $this->account_id = $id;
        }

        return $this;
    }
624324
public function assignMedia($mediaId)
    {
        $this->getLogger()->info('Assigning media ID ' . json_encode($mediaId) . ' To display Group ID ' . $this->displayGroupId);
        $this->doPost('/displaygroup/' . $this->displayGroupId . '/media/assign', [
            'mediaId' => $mediaId
            ]);

        return $this;
    }
1029401
function(service, service_id, auth_token) {
      Account.create({service: service, service_id: service_id, auth_token: auth_token})
      .then(function(account) {
        // cool beans
        Switchboard.delegateAccount('add', account.condensed());
        return true;
      })
      .fail(function(error) {
        hb.errors.emit('error', whatError(error.originalError));
        return false;
      });
    }
241307
private function addLogos($accounts, $locale)
    {
        $ids = array_filter(array_column($accounts, 'logo'));
        $logos = $this->get('sulu_media.media_manager')->getFormatUrls($ids, $locale);
        foreach ($accounts as $key => $account) {
            if (array_key_exists('logo', $account) && $account['logo'] && array_key_exists($account['logo'], $logos)) {
                $accounts[$key]['logo'] = $logos[$account['logo']];
            }
        }

        return $accounts;
    }
63548
public function create($account_id)
    {
        return $this->createResource(sprintf('/%s/%s/%s/%s', MoipResource::VERSION, self::PATH_ACCOUNT, $account_id, self::PATH));
    }
365538
public function setAccountID($accountID)
    {
        if (trim($accountID) == null)
        {
            throw new InvalidArgumentException("You must supply an account ID.");
        }

        if (!is_numeric($accountID))
        {
            throw new InvalidArgumentException("Account ID must be numeric.");
        }
        $this->accountID = intval($accountID);
    }
1139983
public function addConnectToken($account = null, $params = array())
    {
        $params = $this->checkFilterParams($params, array(
            'callback_url',
            'email',
            'first_name',
            'last_name',
            'source_callback_url',
            'source_expunge_on_deleted_flag',
            'source_sync_all_folders',
            'source_sync_folders',
            'source_raw_file_list',
            'status_callback_url'
        ), array('callback_url'));
        if ($params === false) {
            throw new \InvalidArgumentException("params array contains invalid parameters or misses required parameters");
        }

        return $this->lastRequest->post(
            $account,
            'connect_tokens',
            $params,
            null,
            array('Content-Type: application/x-www-form-urlencoded')
        );
    }
1327611
public function formAction(Request $request, $mediaId)
    {
        $media = $this->get('open_orchestra_media.repository.media')->find($mediaId);
        $this->denyAccessUnlessGranted(ContributionActionInterface::EDIT, $media);

        $formTypeAlias = $this->get('open_orchestra_media_admin.media_form.manager')->getFormType($media);

        $form = $this->createForm($formTypeAlias, $media, array(
            'action' => $this->generateUrl('open_orchestra_media_admin_media_form', array(
                'mediaId' => $mediaId,
            )),
            'enable_delete_button' => $this->get('open_orchestra_backoffice.business_rules_manager')->isGranted(ContributionActionInterface::DELETE, $media),
            'delete_button' => $this->isGranted(ContributionActionInterface::DELETE, $media)
        ));

        $form->handleRequest($request);
        if ($form->isValid()) {
            $this->get('open_orchestra_media_admin.media_form.manager')->runAdditionalProcess($media, $form);
            $this->dispatchEvent(MediaEvents::MEDIA_UPDATE, new MediaEvent($media));
            $this->get('session')->getFlashBag()->add(
                'success',
                $this->get('translator')->trans('open_orchestra_media_admin.form.media.success')
            );
        }

        return $this->renderAdminForm($form);
    }
496833
public function delete($account, $action = '', $parameters = null)
    {
        return $this->sendRequest('DELETE', $account, $action, $parameters);
    }
1217165
public function watchlist($accountId, $mediaId, $isOnWatchlist = true, $mediaType = 'movie')
    {
        return $this->postJson('account/' . $accountId . '/watchlist', [
            'media_id'   => $mediaId,
            'media_type' => $mediaType,
            'watchlist'  => $isOnWatchlist
        ]);
    }
1254712
public function addAccount(ChartAccountsAccount $account) {
        foreach ($this->accounts as $current) {
            if ($current->getNumber() === $account->getNumber()) {
                throw new AccountAlreadyExistsException($account);
            }
        }
        $this->accounts[] = $account;
        return $this;
    }
1314182
protected function addMediaToEntity($entityName, $id, $mediaId)
    {
        try {
            $em = $this->getDoctrine()->getManager();
            $entity = $em->getRepository($entityName)->find($id);
            $media = $this->container->get('sulu.repository.media')->find($mediaId);

            if (!$entity) {
                throw new EntityNotFoundException($entityName, $id);
            }

            if (!$media) {
                throw new EntityNotFoundException($this->getParameter('sulu.model.media.class'), $mediaId);
            }

            if ($entity->getMedias()->contains($media)) {
                throw new RestException('Relation already exists');
            }

            $entity->addMedia($media);
            $em->flush();

            $view = $this->view(
                new Media(
                    $media,
                    $this->getUser()->getLocale(),
                    null
                ),
                200
            );
        } catch (EntityNotFoundException $enfe) {
            $view = $this->view($enfe->toArray(), 404);
        } catch (RestException $exc) {
            $view = $this->view($exc->toArray(), 400);
        } catch (\Exception $e) {
            $view = $this->view($e->getMessage(), 400);
        }

        return $this->handleView($view);
    }
1258086
public function setAccountId($value)
    {
        if ($value === null || $value === '') {
            $this->_accountId = null;
        } elseif (TypeCast::canCastToString($value)) {
            $this->_accountId = (string)$value;
        } else {
            throw new \InvalidArgumentException('Invalid account_id value type "' . gettype($value) . '"');
        }
    }