Get a subscription instance for an given subscription id.

@param subscription|int $subscriptionorid an instance of subscription class or id.

@return subscription returns a instance of subscription class.
162974
public static function get_subscription($subscriptionorid) {
        global $DB;

        if (is_object($subscriptionorid)) {
            return new subscription($subscriptionorid);
        }

        $sql = self::get_subscription_join_rule_sql();
        $sql .= "WHERE s.id = :id";
        $sub = $DB->get_record_sql($sql, array('id' => $subscriptionorid), MUST_EXIST);
        return new subscription($sub);
    }
1169732
public function get($handlerServiceId)
    {
        $handler = $this->container->get($handlerServiceId);

        if (!$handler instanceof CommandHandlerInterface) {
            throw new \InvalidArgumentException('Handler must be instance if ' . CommandHandlerInterface::class);
        }

        return $handler;
    }
1195517
public function getHeader( $uid = '' )
	{
		$view = $this->getObject()->addData( $this->getView() );

		$content = '';
		foreach( $this->getSubClients() as $subclient ) {
			$content .= $subclient->setView( $view )->getHeader( $uid );
		}
		$view->subscriptionHeader = $content;


		$addr = $view->extAddressItem;

		$msg = $view->mail();
		$msg->addHeader( 'X-MailGenerator', 'Aimeos' );
		$msg->addTo( $addr->getEMail(), $addr->getFirstName() . ' ' . $addr->getLastName() );


		/** client/html/email/from-name
		 * @see client/html/email/subscription/from-email
		 */
		$fromName = $view->config( 'client/html/email/from-name' );

		/** client/html/email/subscription/from-name
		 * Name used when sending subscription e-mails
		 *
		 * The name of the person or e-mail subscription that is used for sending all
		 * shop related subscription e-mails to customers. This configuration option
		 * overwrite the name set in "client/html/email/from-name".
		 *
		 * @param string Name shown in the e-mail
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/from-name
		 * @see client/html/email/from-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/bcc-email
		 */
		$fromNameSubscription = $view->config( 'client/html/email/subscription/from-name', $fromName );

		/** client/html/email/from-email
		 * @see client/html/email/subscription/from-email
		 */
		$fromEmail = $view->config( 'client/html/email/from-email' );

		/** client/html/email/subscription/from-email
		 * E-Mail address used when sending subscription e-mails
		 *
		 * The e-mail address of the person or subscription that is used for sending
		 * all shop related product notification e-mails to customers. This configuration option
		 * overwrites the e-mail address set via "client/html/email/from-email".
		 *
		 * @param string E-mail address
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/subscription/from-name
		 * @see client/html/email/from-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/bcc-email
		 */
		if( ( $fromEmailSubscription = $view->config( 'client/html/email/subscription/from-email', $fromEmail ) ) != null ) {
			$msg->addFrom( $fromEmailSubscription, $fromNameSubscription );
		}


		/** client/html/email/reply-name
		 * @see client/html/email/subscription/reply-email
		 */
		$replyName = $view->config( 'client/html/email/reply-name', $fromName );

		/** client/html/email/subscription/reply-name
		 * Recipient name displayed when the customer replies to subscription e-mails
		 *
		 * The name of the person or e-mail subscription the customer should
		 * reply to in case of subscription related questions or problems. This
		 * configuration option overwrites the name set via
		 * "client/html/email/reply-name".
		 *
		 * @param string Name shown in the e-mail
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/subscription/reply-email
		 * @see client/html/email/reply-name
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 * @see client/html/email/bcc-email
		 */
		$replyNameSubscription = $view->config( 'client/html/email/subscription/reply-name', $replyName );

		/** client/html/email/reply-email
		 * @see client/html/email/subscription/reply-email
		 */
		$replyEmail = $view->config( 'client/html/email/reply-email', $fromEmail );

		/** client/html/email/subscription/reply-email
		 * E-Mail address used by the customer when replying to subscription e-mails
		 *
		 * The e-mail address of the person or e-mail subscription the customer
		 * should reply to in case of subscription related questions or problems.
		 * This configuration option overwrites the e-mail address set via
		 * "client/html/email/reply-email".
		 *
		 * @param string E-mail address
		 * @since 2018.04
		 * @category User
		 * @see client/html/email/subscription/reply-name
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 * @see client/html/email/bcc-email
		 */
		if( ( $replyEmailSubscription = $view->config( 'client/html/email/subscription/reply-email', $replyEmail ) ) != null ) {
			$msg->addReplyTo( $replyEmailSubscription, $replyNameSubscription );
		}


		/** client/html/email/bcc-email
		 * @see client/html/email/subscription/bcc-email
		 */
		$bccEmail = $view->config( 'client/html/email/bcc-email' );

		/** client/html/email/subscription/bcc-email
		 * E-Mail address all subscription e-mails should be also sent to
		 *
		 * Using this option you can send a copy of all subscription related e-mails
		 * to a second e-mail subscription. This can be handy for testing and checking
		 * the e-mails sent to customers.
		 *
		 * It also allows shop owners with a very small volume of orders to be
		 * notified about subscription changes. Be aware that this isn't useful if the
		 * order volumne is high or has peeks!
		 *
		 * This configuration option overwrites the e-mail address set via
		 * "client/html/email/bcc-email".
		 *
		 * @param string|array E-mail address or list of e-mail addresses
		 * @since 2018.04
		 * @category User
		 * @category Developer
		 * @see client/html/email/bcc-email
		 * @see client/html/email/reply-email
		 * @see client/html/email/from-email
		 */
		if( ( $bccEmailSubscription = $view->config( 'client/html/email/subscription/bcc-email', $bccEmail ) ) != null )
		{
			foreach( (array) $bccEmailSubscription as $emailAddr ) {
				$msg->addBcc( $emailAddr );
			}
		}


		/** client/html/email/subscription/standard/template-header
		 * Relative path to the HTML header template of the subscription e-mail client.
		 *
		 * The template file contains the HTML code and processing instructions
		 * to generate the HTML code that is inserted into the HTML page header
		 * of the rendered page in the frontend. The configuration string is the
		 * path to the template file relative to the templates directory (usually
		 * in client/html/templates).
		 *
		 * You can overwrite the template file configuration in extensions and
		 * provide alternative templates. These alternative templates should be
		 * named like the default one but with the string "standard" replaced by
		 * an unique name. You may use the name of your project for this. If
		 * you've implemented an alternative client class as well, "standard"
		 * should be replaced by the name of the new class.
		 *
		 * The product notification e-mail HTML client allows to use a different template for
		 * each subscription status value. You can create a template for each subscription
		 * status and store it in the "email/subscription/<status number>/" directory
		 * below the "templates" directory (usually in client/html/templates). If no
		 * specific layout template is found, the common template in the
		 * "email/subscription/" directory is used.
		 *
		 * @param string Relative path to the template creating code for the HTML page head
		 * @since 2018.04
		 * @category Developer
		 * @see client/html/email/subscription/standard/template-body
		 */
		$tplconf = 'client/html/email/subscription/standard/template-header';

		return $view->render( $view->config( $tplconf, 'email/subscription/header-standard' ) ); ;
	}
270452
public function getInputsFromServiceId($conditionServiceId)
    {
        if (!$this->container->has($conditionServiceId)) {
            return false;
        }

        /** @var ConditionInterface $condition */
        $condition = $this->container->get($conditionServiceId);

        return $this->getInputsFromConditionInterface($condition);
    }
1306500
public function get(
        $page = 1,
        $pageSize = 1000,
        $subscribed = null,
        $onlyGuest = false,
        $websiteId = null,
        $storeId = null
    ) {

        $this
            ->initCollection()
            ->joinWebsite()
            ->filterWebsite($websiteId)
            ->filterStore($storeId)
            ->filterSubscribed($subscribed)
            ->filterCustomers($onlyGuest)
            ->setPage($page, $pageSize);

        return $this->subscriptionsResponseFactory->create()
            ->setCurrentPage($this->subscriptionCollection->getCurPage())
            ->setLastPage($this->subscriptionCollection->getLastPageNumber())
            ->setPageSize($this->subscriptionCollection->getPageSize())
            ->setTotalCount($this->subscriptionCollection->getSize())
            ->setSubscriptions($this->handleSubscriptions());
    }
94276
public void setSubscriberID(String subscriptionID)
    {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "setSubscriberID", subscriptionID);

        this.subscriptionID = subscriptionID;

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "setSubscriberID");
    }
330276
public function readSubscription($subscriptionId, $componentId)
    {
        $service = $this->getService();

        $response      = $service->request('subscriptions/' . (int)$subscriptionId . '/components/' . (int)$componentId, 'GET');
        $responseArray = $this->getResponseArray($response);

        if (!$this->isError()) {
            $this->_data = $responseArray['component'];
        } else {
            $this->_data = array();
        }

        return $this;
    }
412871
static public function isSubscriptionType($subscriptionType) {
    return ((string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_NORMAL ||
        (string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_INFINITE ||
        (string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_ONETIME ||
        (string) $subscriptionType == Connect2PayClient::SUBSCRIPTION_TYPE_LIFETIME);
  }
960178
private function filterSubscribed($subscribed = null)
    {
        if ($subscribed === true) {
            $this->subscriptionCollection->addFieldToFilter('subscriber_status', ['eq' => 1]);
        } elseif ($subscribed === false) {
            $this->subscriptionCollection->addFieldToFilter('subscriber_status', ['neq' => 1]);
        }
        return $this;
    }
910749
public static function fromObservable(ObservableInterface $observable, Deferred $deferred = null): ReactPromise
    {

        $d = $deferred ?: new Deferred(function () use (&$subscription) {
            $subscription->dispose();
        });

        $value = null;

        $subscription = $observable->subscribe(
            function ($v) use (&$value) {
                $value = $v;
            },
            function ($error) use ($d) {
                $d->reject($error);
            },
            function () use ($d, &$value) {
                $d->resolve($value);
            }
        );

        return $d->promise();
    }
985157
public function getSubscription($id)
    {
        $url = $this->accountsEndpoint . 'subscriptions';
        return Subscription::get($id, $url, $this->connector->getClient());
    }
88891
public function subscribed($subscription = 'default', $planId = null)
    {
        $subscription = $this->subscription($subscription);

        if (is_null($subscription)) {
            return false;
        }

        if (is_null($planId)) {
            return $subscription->isActive();
        }

        if ($planId == $subscription->plan_id and $subscription->isActive()) {
            return true;
        }

        return false;
    }
1044276
public function getSubscriber($groupId, $subscriberId)
    {
        $endpoint = $this->endpoint . '/' . $groupId . '/subscribers/' . urlencode($subscriberId);

        $response = $this->restClient->get($endpoint);

        return $response['body'];
    }
1002062
public function renewSubscription($subscriptionId)
    {
        $requestData = new Renew\RequestData($subscriptionId);
        $request = new Renew\Request($requestData);

        return $this->sendRequest($request, Renew\ApiResponse::class);
    }
57597
public function addReadBy($userOrId)
    {
        if ($userOrId instanceof UserInterface) {
            $userOrId = $userOrId->getId();
        }
        if (!in_array($userOrId, $this->readBy)) {
            $this->readBy[] = $userOrId;
        }
        return $this;
    }
1021821
protected function endSubscription($subscriptionId = null)
    {
        if (!$subscriptionId) {
            $subscriptionId = $this->subscriptions->getLast()->getSubscriptionId();
        }
        if (!isset($this->subscriptions[$subscriptionId])) {
            throw new InvalidArgumentException(sprintf('%s is no active subscription!', $subscriptionId));
        }
        $subscription = $this->subscriptions[$subscriptionId];
        $this->getClient()->sendFrame(
            $this->getProtocol()->getUnsubscribeFrame(
                $subscription->getDestination(),
                $subscription->getSubscriptionId()
            )
        );
        IdGenerator::releaseId($subscription->getSubscriptionId());

        unset($this->subscriptions[$subscription->getSubscriptionId()]);

        if ($this->subscriptions->count() == 0) {
            return true;
        }
        return false;
    }
582615
public function participant($summonerId)
	{
		$participant = $this->info['participants'];
		if (isset($participant[$summonerId]))
		{
			return $participant[$summonerId];
		}

		return null;
	}