summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/src/Services/ImporterServiceFactory.php
blob: cc9b71bfecd1a8848df8bb27d1743c3d7be459a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php

namespace SMW\Services;

use ImportSource;
use Onoi\CallbackContainer\ContainerBuilder;
use SMW\Importer\ContentIterator;

/**
 * @private
 *
 * This class provides service and factory functions for Import objects.
 *
 * @license GNU GPL v2+
 * @since 3.0
 *
 * @author mwjames
 */
class ImporterServiceFactory {

	/**
	 * @var ContainerBuilder
	 */
	private $containerBuilder;

	/**
	 * @since 3.0
	 */
	public function __construct( ContainerBuilder $containerBuilder ) {
		$this->containerBuilder = $containerBuilder;
	}

	/**
	 * @since 3.0
	 *
	 * @param string $source
	 *
	 * @return ImportStringSource
	 */
	public function newImportStringSource( $source ) {
		return $this->containerBuilder->create( 'ImportStringSource', $source );
	}

	/**
	 * @since 3.0
	 *
	 * @param string $source
	 *
	 * @return ImportStreamSource
	 */
	public function newImportStreamSource( $source ) {
		return $this->containerBuilder->create( 'ImportStreamSource', $source );
	}

	/**
	 * @since 3.0
	 *
	 * @param ImportSource $importSource
	 *
	 * @return WikiImporter
	 */
	public function newWikiImporter( ImportSource $importSource ) {
		return $this->containerBuilder->create( 'WikiImporter', $importSource );
	}

	/**
	 * @since 3.0
	 *
	 * @param ContentIterator $contentIterator
	 *
	 * @return Importer
	 */
	public function newImporter( ContentIterator $contentIterator ) {
		return $this->containerBuilder->create( 'Importer', $contentIterator );
	}

	/**
	 * @since 3.0
	 *
	 * @return JsonContentIterator
	 */
	public function newJsonContentIterator( $importFileDir ) {
		return $this->containerBuilder->create( 'JsonContentIterator', $importFileDir );
	}

}