Completed
Push — 2016.04 ( 690368...e61816 )
by Aimeos
04:37
created

TablesAddTypo3TestData   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 55
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPreDependencies() 0 4 1
A getPostDependencies() 0 4 1
A mysql() 0 8 1
A process() 0 11 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2014
7
 */
8
9
10
namespace Aimeos\MW\Setup\Task;
11
12
13
/**
14
 * Adds default records to tables.
15
 */
16
class TablesAddTypo3TestData extends \Aimeos\MW\Setup\Task\Base
17
{
18
	/**
19
	 * Returns the list of task names which this task depends on.
20
	 *
21
	 * @return array List of task names
22
	 */
23
	public function getPreDependencies()
24
	{
25
		return array( 'TablesCreateTypo3' );
26
	}
27
28
29
	/**
30
	 * Returns the list of task names which depends on this task.
31
	 *
32
	 * @return array List of task names
33
	 */
34
	public function getPostDependencies()
35
	{
36
		return array();
37
	}
38
39
40
	/**
41
	 * Executes the task for MySQL databases.
42
	 */
43
	protected function mysql()
44
	{
45
		$this->msg('Setting up Aimeos TYPO3 test data', 0);
46
		$this->status('');
47
48
		$file = __DIR__ . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'mysql.sql';
49
		$this->process( $file );
50
	}
51
52
53
	/**
54
	 * Insert records from file containing the SQL records.
55
	 *
56
	 * @param string $filename Name of the file
57
	 */
58
	protected function process( $filename )
59
	{
60
		$this->msg(sprintf('Adding records from "%1$s"', basename($filename)), 1);
61
62
		if( ( $content = file_get_contents( $filename ) ) === false ) {
63
			throw new \Aimeos\MW\Setup\Exception( sprintf( 'Unable to get content from file "%1$s"', $filename ) );
64
		}
65
66
		$this->execute( $content );
67
		$this->status( 'done' );
68
	}
69
70
}