Exemple #1
0
 public static function setUpBeforeClass()
 {
     parent::setUpBeforeClass();
     $fieldRepository = new FieldRepository(new Field());
     $categoryFieldRepository = new CategoryFieldRepository(new CategoryField());
     $memberFieldRepository = new MemberFieldRepository(new MemberField());
     $channelRepository = new ChannelRepository(new Channel(), $fieldRepository);
     $siteRepository = new SiteRepository(new Site());
     $uploadPrefRepository = new UploadPrefRepository(new UploadPref());
     $hydratorFactory = new HydratorFactory(Model::resolveConnection(Model::getGlobalConnection()), $siteRepository, $uploadPrefRepository, new Asset(), new File(), new GridCol(), new GridRow(), new MatrixCol(), new MatrixRow(), new PlayaEntry(), new RelationshipEntry());
     Category::setCategoryFieldRepository($categoryFieldRepository);
     Category::setChannelRepository($channelRepository);
     Member::setMemberFieldRepository($memberFieldRepository);
     Title::setChannelRepository($channelRepository);
     Title::setSiteRepository($siteRepository);
     Title::setHydratorFactory($hydratorFactory);
 }
Exemple #2
0
 /**
  * Constructor
  *
  * Build all the dependencies
  *
  * @var array $config  an EE config array
  */
 public function __construct($config = array())
 {
     Carbon::setToStringFormat(Carbon::ISO8601);
     $this->singleton('config', function ($app) use($config) {
         return $config;
     });
     $this->bind('db', function ($app) {
         return Model::resolveConnection(Model::getGlobalConnection());
     });
     $this->singleton('Field', function ($app) {
         return new Field();
     });
     $this->singleton('FieldRepository', function ($app) {
         return new FieldRepository($app->make('Field'));
     });
     $this->singleton('Channel', function ($app) {
         $channel = new Channel();
         $channel->setFieldRepository($app->make('FieldRepository'));
         return $channel;
     });
     $this->singleton('Site', function ($app) {
         return new Site();
     });
     $this->singleton('UploadPref', function ($app) {
         return new UploadPref();
     });
     $this->singleton('CategoryField', function ($app) {
         return new CategoryField();
     });
     $this->singleton('MemberField', function ($app) {
         return new MemberField();
     });
     $this->singleton('CategoryFieldRepository', function ($app) {
         return new CategoryFieldRepository($app->make('CategoryField'));
     });
     $this->singleton('MemberFieldRepository', function ($app) {
         return new MemberFieldRepository($app->make('MemberField'));
     });
     $this->singleton('ChannelRepository', function ($app) {
         return new ChannelRepository($app->make('Channel'));
     });
     $this->singleton('SiteRepository', function ($app) {
         return new SiteRepository($app->make('Site'));
     });
     $this->singleton('UploadPrefRepository', function ($app) {
         if (isset($app['config']['upload_prefs'])) {
             return new ConfigUploadPrefRepository($app['config']['upload_prefs']);
         }
         return new UploadPrefRepository($app->make('UploadPref'));
     });
     $this->singleton('Asset', function ($app) {
         return new Asset();
     });
     $this->singleton('File', function ($app) {
         return new File();
     });
     $this->singleton('GridCol', function ($app) {
         return new GridCol();
     });
     $this->singleton('GridRow', function ($app) {
         return new GridRow();
     });
     $this->singleton('MatrixCol', function ($app) {
         return new MatrixCol();
     });
     $this->singleton('MatrixRow', function ($app) {
         return new MatrixRow();
     });
     $this->singleton('PlayaEntry', function ($app) {
         return new PlayaEntry();
     });
     $this->singleton('RelationshipEntry', function ($app) {
         return new RelationshipEntry();
     });
     $this->singleton('HydratorFactory', function ($app) {
         return new HydratorFactory($app->make('db'), $app->make('SiteRepository'), $app->make('UploadPrefRepository'), $app->make('Asset'), $app->make('File'), $app->make('GridCol'), $app->make('GridRow'), $app->make('MatrixCol'), $app->make('MatrixRow'), $app->make('PlayaEntry'), $app->make('RelationshipEntry'));
     });
     $this->singleton('Category', function ($app) {
         $category = new Category();
         $category->setCategoryFieldRepository($app->make('CategoryFieldRepository'));
         $category->setChannelRepository($app->make('ChannelRepository'));
         return $category;
     });
     $this->singleton('Member', function ($app) {
         $member = new Member();
         $member->setMemberFieldRepository($app->make('MemberFieldRepository'));
         return $member;
     });
     $this->singleton('Title', function ($app) {
         $app->make('Category');
         $app->make('Member');
         $title = new Title();
         $title->setChannelRepository($app->make('ChannelRepository'));
         $title->setSiteRepository($app->make('SiteRepository'));
         $title->setHydratorFactory($app->make('HydratorFactory'));
         return $title;
     });
     $this->singleton('Entry', function ($app) {
         $app->make('Title');
         $entry = new Entry();
         $entry->setFieldRepository($app->make('FieldRepository'));
         return $entry;
     });
 }