View file upload/src/addons/AddonsLab/Core/Xf2/AppTrait.php

File size: 2.61Kb
<?php
/** 
This software is furnished under a license and may be used and copied
only  in  accordance  with  the  terms  of such  license and with the
inclusion of the above copyright notice.  This software  or any other
copies thereof may not be provided or otherwise made available to any
other person.  No title to and  ownership of the  software is  hereby
transferred.                                                         
                                                                     
You may not reverse  engineer, decompile, defeat  license  encryption
mechanisms, or  disassemble this software product or software product
license.  AddonsLab may terminate this license if you don't comply with
any of these terms and conditions.  In such event,  licensee  agrees 
to return licensor  or destroy  all copies of software  upon termination 
of the license.
*/

namespace AddonsLab\Core\Xf2;

use AddonsLab\Core\Container;
use AddonsLab\Core\Xf2\Service\ContentCreator;
use AddonsLab\Core\Xf2\Service\CrudEntity;
use AddonsLab\Core\Xf2\Service\OptionBuilder;

trait AppTrait
{
    /**
     * @param Container $container
     */
    protected function _setupContainer($container)
    {
        $container->set('option.provider', function ($c) {
            return new Xf2OptionProvider();
        });
        $container->set('phrase.provider', function ($c) {
            return new Xf2PhraseProvider();
        });
        $container->set('cookie.provider', function ($c) {
            return new Xf2CookieProvider();
        });
        $container->set('session.provider', function ($c) {
            return new Xf2SessionProvider();
        });
        $container->set('db.provider', function ($c) {
            return new DbProvider();
        });
        $container->set('RegistryProvider', function () {
            return new Xf2RegistryProvider();
        });
        $container->set('AccountDeleter', function () {
            return new AccountDeleter();
        });
        $container['option.builder'] = function ($c) {
            return new OptionBuilder();
        };
        $this->container->set('CrudEntity', function () {
            return new CrudEntity();
        });
        $this->container->set('ContentCreator', function ()
        {
            return new ContentCreator();
        });
    }
    
    /**
     * @return ContentCreator
     * @testable
     */
    public static function getContentCreator()
    {
        return static::get('ContentCreator');
    }
    
    /**
     * @return CrudEntity
     * @testable
     */
    public static function getCrudEntityService()
    {
        return static::get('CrudEntity');
    }
}