Adds the mailer object to the context

@param \Aimeos\MShop\Context\Item\Iface $context Context object
@return \Aimeos\MShop\Context\Item\Iface Modified context object
777527
protected static function addMailer( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_mailer'] )
			&& is_callable( ( $fcn = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context_mailer'] ) )
		) {
			return $fcn( $context );
		}

		return $context->setMail( new \Aimeos\MW\Mail\Typo3( function() {
			return GeneralUtility::makeInstance( \TYPO3\CMS\Core\Mail\MailMessage::class );
		} ) );
	}
1324871
public function addContext(array $context)
    {
        if ($context) {
            $this->context = array_merge($this->context, $context);
        }

        return $this;
    }
1088416
protected function getProductItems( \Aimeos\MShop\Context\Item\Iface $context, array $prodIds )
	{
		$productManager = \Aimeos\MShop::create( $context, 'product' );

		$search = $productManager->createSearch( true );
		$expr = array(
			$search->compare( '==', 'product.id', $prodIds ),
			$search->getConditions(),
		);
		$search->setConditions( $search->combine( '&&', $expr ) );
		$search->setSlice( 0, count( $prodIds ) );

		return $productManager->searchItems( $search, array( 'text', 'price', 'media' ) );
	}
400917
public function begin( \Aimeos\MShop\Subscription\Item\Iface $subscription )
	{
		if( empty( $this->groupIds ) ) {
			return;
		}

		$context = $this->getContext();

		$manager = \Aimeos\MShop::create( $context, 'customer' );
		$baseManager = \Aimeos\MShop::create( $context, 'order/base' );

		$baseItem = $baseManager->getItem( $subscription->getOrderBaseId() );
		$item = $manager->getItem( $baseItem->getCustomerId(), ['customer/group'] );

		$item->setGroups( array_unique( array_merge( $item->getGroups(), $this->groupIds ) ) );
		$manager->saveItem( $item );
	}
1250021
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
	{
		$manager = \Aimeos\MShop::create( $this->getContext(), 'product/property' );
		$typeManager = \Aimeos\MShop::create( $this->getContext(), 'product/property/type' );

		foreach( $data as $type => $value )
		{
			$propItems = $item->getPropertyItems( $type, false );

			if( ( $value = trim( $value ) ) != '' )
			{
				if( ( $propItem = reset( $propItems ) ) === false ) {
					$propItem = $manager->createItem()->setType( $type );
				}

				$propItem->setLanguageId( null );
				$propItem->setValue( $value );

				$item->addPropertyItem( $propItem );
			}
			else
			{
				$item->deletePropertyItems( $propItems );
			}
		}
	}
11299
protected function addResponse( \Aimeos\MW\View\Iface $view )
	{
		$helper = new \Aimeos\MW\View\Helper\Response\Symfony2( $view );
		$view->addHelper( 'response', $helper );

		return $view;
	}
398098
public static function getContext( \Aimeos\MW\Config\Iface $config )
	{
		$name = 'Aimeos\Aimeos\Base\Context';

		if( isset( $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context'] ) ) {
			if( ( $name = $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['aimeos']['aimeos_context'] ) instanceof \Closure ) {
				return $name( $config );
			}
		}

		return $name::get( $config );
	}
1027282
public function setContext($context)
    {
        if ($context instanceof Context) {
            $context = [$context];
        }

        if ($context instanceof \ArrayObject || is_array($context) || $context instanceof \Iterator) {
            foreach ($context as $key => $value) {
                if (!$value instanceof Context) {
                    if (is_int($key) && is_array($value) && array_key_exists('key', $value) && array_key_exists('value', $value)) {
                        $contextData = ['key' => $value['key'], 'value' => $value['value']];
                        if (isset($value['id'])) {
                            $contextData['id'] = $value['id'];
                        }
                    } else {
                        $contextData = ['key' => $key, 'value' => $value];
                    }
                    $value = new Context($contextData);
                }

                $value->setNotification($this);
                $this->contexts->add($value);
            }
        }

        return $this;
    }
912532
public function set( \Aimeos\MShop\Common\Item\Iface $item )
	{
		$code = $item->getCode();

		if( !isset( $this->attributes[$code] ) || !is_array( $this->attributes[$code] ) ) {
			$this->attributes[$code] = [];
		}

		$this->attributes[$code][$item->getType()] = $item;
	}
878208
public function addContext($context = [])
    {
        if (!$context || empty($context)) {
            return $this;
        }
        $this->nestContext($context);
        $this->sanitizeContext($context);
        $this->context = array_merge($this->context, $context);

        return $this;
    }
1023384
public static function get( \Aimeos\MW\Config\Iface $config )
	{
		if( self::$context === null )
		{
			// TYPO3 specifc context with password hasher
			$context = new \Aimeos\MShop\Context\Item\Typo3();
			$context->setConfig( $config );

			self::addDataBaseManager( $context );
			self::addFilesystemManager( $context );
			self::addMessageQueueManager( $context );
			self::addLogger( $context );
			self::addCache( $context );
			self::addMailer( $context);
			self::addProcess( $context );
			self::addSession( $context );
			self::addHasher( $context);
			self::addUser( $context);
			self::addGroups( $context);

			self::$context = $context;
		}

		// Use local TS configuration from plugins
		self::$context->setConfig( $config );

		return self::$context;
	}
562537
protected function addGroups( \Aimeos\MShop\Context\Item\Iface $context )
	{
		if( ( $userid = Auth::id() ) !== null )
		{
			$context->setGroupIds( function() use ( $context, $userid )
			{
				$manager = \Aimeos\MShop::create( $context, 'customer' );
				return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups();
			} );
		}

		return $context;
	}
157211
protected function _actionAdd($context)
    {
        $entity = parent::_actionAdd($context);

        if ($entity->owner->isSubscribable()) {
            $notification = $this->createNotification(array(
                'name' => 'topic_add',
                'object' => $entity,
                'subscribers' => $entity->owner->subscriberIds->toArray(),
            ))->setType('post', array('new_post' => true));
        }

        return $entity;
    }
1240780
public function setObject( \Aimeos\Client\Html\Iface $object )
	{
		$this->object = $object;
		return $this;
	}
774953
public function mailAdminsNewAdmin(AnCommandContext $context)
    {
        $person = $context->result;

        $this->mailAdmins(array(
            'subject' => AnTranslator::sprintf('COM-PEOPLE-MAIL-SUBJECT-NEW-ADMIN', $person->name),
            'template' => 'new_admin',
        ));
    }
904303
protected function toArray( \Aimeos\MShop\Order\Item\Base\Iface $item, $copy = false )
	{
		$siteId = $this->getContext()->getLocale()->getSiteId();
		$data = $item->toArray( true );

		if( $item->getCustomerId() != '' )
		{
			$manager = \Aimeos\MShop::create( $this->getContext(), 'customer' );

			try {
				$data += $manager->getItem( $item->getCustomerId() )->toArray();
			} catch( \Exception $e ) {};
		}


		if( $copy === true )
		{
			$data['order.base.siteid'] = $siteId;
			$data['order.base.id'] = '';
		}

		foreach( $item->getAddresses() as $type => $addresses )
		{
			foreach( $addresses as $pos => $addrItem )
			{
				$list = $addrItem->toArray( true );

				foreach( $list as $key => $value ) {
					$data['address'][$type][$pos][$key] = $value;
				}

				if( $copy === true )
				{
					$data['address'][$type][$pos]['order.base.address.siteid'] = $siteId;
					$data['address'][$type][$pos]['order.base.address.id'] = '';
				}
			}
		}

		if( $copy !== true )
		{
			foreach( $item->getServices() as $type => $services )
			{
				foreach( $services as $serviceItem )
				{
					$serviceId = $serviceItem->getServiceId();

					foreach( $serviceItem->getAttributeItems() as $attrItem )
					{
						foreach( $attrItem->toArray( true ) as $key => $value ) {
							$data['service'][$type][$serviceId][$key][] = $value;
						}
					}
				}
			}
		}

		foreach( $item->getProducts() as $pos => $productItem ) {
			$data['product'][$pos]['order.base.product.status'] = $productItem->getStatus();
		}

		return $data;
	}
989556
protected function fromArray( \Aimeos\MShop\Product\Item\Iface $item, array $data )
	{
		$context = $this->getContext();

		$attrManager = \Aimeos\MShop::create( $context, 'attribute' );
		$listManager = \Aimeos\MShop::create( $context, 'product/lists' );

		$listItems = $item->getListItems( 'attribute', 'config', 'interval', false );

		foreach( $data as $idx => $entry )
		{
			if( !array_key_exists( 'attribute.id', $entry ) ) {
				continue;
			}

			if( $entry['attribute.id'] == '' || ( $listItem = $item->getListItem( 'attribute', 'config', $entry['attribute.id'], false ) ) === null ) {
				$listItem = $listManager->createItem()->setType( 'config' );
			}

			if( $entry['attribute.id'] == '' || ( $refItem = $listItem->getRefItem() ) === null )
			{
				$refItem = $attrManager->createItem()->setType( 'interval' );
				$refItem->fromArray( $entry, true );
			}

			unset( $listItems[$listItem->getId()] );

			$item->addListItem( 'attribute', $listItem->setPosition( $idx ), $refItem );
		}

		$item->deleteListItems( $listItems );
	}