| @@ 35-136 (lines=102) @@ | ||
| 32 | * @link https://github.com/techdivision/import |
|
| 33 | * @link http://www.techdivision.com |
|
| 34 | */ |
|
| 35 | abstract class AbstractProcessor implements ProcessorInterface |
|
| 36 | { |
|
| 37 | ||
| 38 | /** |
|
| 39 | * The connection instance. |
|
| 40 | * . |
|
| 41 | * @var \TechDivision\Import\Connection\ConnectionInterface; |
|
| 42 | */ |
|
| 43 | protected $connection; |
|
| 44 | ||
| 45 | /** |
|
| 46 | * The respository instance with the SQL statements to use. |
|
| 47 | * |
|
| 48 | * @var \TechDivision\Import\Repositories\SqlStatementRepositoryInterface |
|
| 49 | */ |
|
| 50 | protected $sqlStatementRepository; |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Initialize the processor with the passed connection and utility class name. |
|
| 54 | * . |
|
| 55 | * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection instance |
|
| 56 | * @param \TechDivision\Import\Repositories\SqlStatementRepositoryInterface $sqlStatementRepository The repository instance |
|
| 57 | */ |
|
| 58 | public function __construct( |
|
| 59 | ConnectionInterface $connection, |
|
| 60 | SqlStatementRepositoryInterface $sqlStatementRepository |
|
| 61 | ) { |
|
| 62 | ||
| 63 | // set the passed instances |
|
| 64 | $this->setConnection($connection); |
|
| 65 | $this->setSqlStatementRepository($sqlStatementRepository); |
|
| 66 | ||
| 67 | // initialize the instance |
|
| 68 | $this->init(); |
|
| 69 | } |
|
| 70 | ||
| 71 | /** |
|
| 72 | * Set's the connection to use. |
|
| 73 | * . |
|
| 74 | * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection instance |
|
| 75 | * |
|
| 76 | * @return void |
|
| 77 | */ |
|
| 78 | public function setConnection(ConnectionInterface $connection) |
|
| 79 | { |
|
| 80 | $this->connection = $connection; |
|
| 81 | } |
|
| 82 | ||
| 83 | /** |
|
| 84 | * Return's the connection to use. |
|
| 85 | * |
|
| 86 | * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance |
|
| 87 | */ |
|
| 88 | public function getConnection() |
|
| 89 | { |
|
| 90 | return $this->connection; |
|
| 91 | } |
|
| 92 | ||
| 93 | /** |
|
| 94 | * Set's the repository instance with the SQL statements to use. |
|
| 95 | * |
|
| 96 | * @param \TechDivision\Import\Repositories\SqlStatementRepositoryInterface $sqlStatementRepository The repository instance |
|
| 97 | * |
|
| 98 | * @return void |
|
| 99 | */ |
|
| 100 | public function setSqlStatementRepository(SqlStatementRepositoryInterface $sqlStatementRepository) |
|
| 101 | { |
|
| 102 | $this->sqlStatementRepository = $sqlStatementRepository; |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * Return's the repository instance with the SQL statements to use. |
|
| 107 | * |
|
| 108 | * @return \TechDivision\Import\Repositories\SqlStatementRepositoryInterface The repository instance |
|
| 109 | */ |
|
| 110 | public function getSqlStatementRepository() |
|
| 111 | { |
|
| 112 | return $this->sqlStatementRepository; |
|
| 113 | } |
|
| 114 | ||
| 115 | /** |
|
| 116 | * Return's the class name of the SQL repository instance with the SQL statements to use. |
|
| 117 | * |
|
| 118 | * @return string The SQL repository instance class name |
|
| 119 | */ |
|
| 120 | public function getSqlStatementRepositoryClassName() |
|
| 121 | { |
|
| 122 | return get_class($this->getSqlStatementRepository()); |
|
| 123 | } |
|
| 124 | ||
| 125 | /** |
|
| 126 | * Load's the SQL statement with the passed ID from the SQL repository. |
|
| 127 | * |
|
| 128 | * @param string $id The ID of the SQL statement to load |
|
| 129 | * |
|
| 130 | * @return string The SQL statement with the passed ID |
|
| 131 | */ |
|
| 132 | public function loadStatement($id) |
|
| 133 | { |
|
| 134 | return $this->getSqlStatementRepository()->load($id); |
|
| 135 | } |
|
| 136 | } |
|
| 137 | ||
| @@ 34-125 (lines=92) @@ | ||
| 31 | * @link https://github.com/techdivision/import |
|
| 32 | * @link http://www.techdivision.com |
|
| 33 | */ |
|
| 34 | abstract class AbstractRepository implements RepositoryInterface |
|
| 35 | { |
|
| 36 | ||
| 37 | /** |
|
| 38 | * The connection instance. |
|
| 39 | * . |
|
| 40 | * @var \TechDivision\Import\Connection\ConnectionInterface; |
|
| 41 | */ |
|
| 42 | protected $connection; |
|
| 43 | ||
| 44 | /** |
|
| 45 | * The repository instance with the SQL statements to use. |
|
| 46 | * |
|
| 47 | * @var \TechDivision\Import\Repositories\SqlStatementRepositoryInterface |
|
| 48 | */ |
|
| 49 | protected $sqlStatementRepository; |
|
| 50 | ||
| 51 | /** |
|
| 52 | * Initialize the repository with the passed connection and utility class name. |
|
| 53 | * . |
|
| 54 | * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection instance |
|
| 55 | * @param \TechDivision\Import\Repositories\SqlStatementRepositoryInterface $sqlStatementRepository The SQL repository instance |
|
| 56 | */ |
|
| 57 | public function __construct( |
|
| 58 | ConnectionInterface $connection, |
|
| 59 | SqlStatementRepositoryInterface $sqlStatementRepository |
|
| 60 | ) { |
|
| 61 | ||
| 62 | // set the passed instances |
|
| 63 | $this->setConnection($connection); |
|
| 64 | $this->setSqlStatementRepository($sqlStatementRepository); |
|
| 65 | ||
| 66 | // initialize the instance |
|
| 67 | $this->init(); |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * Set's the connection to use. |
|
| 72 | * . |
|
| 73 | * @param \TechDivision\Import\Connection\ConnectionInterface $connection The connection instance |
|
| 74 | * |
|
| 75 | * @return void |
|
| 76 | */ |
|
| 77 | public function setConnection(ConnectionInterface $connection) |
|
| 78 | { |
|
| 79 | $this->connection = $connection; |
|
| 80 | } |
|
| 81 | ||
| 82 | /** |
|
| 83 | * Return's the connection to use. |
|
| 84 | * |
|
| 85 | * @return \TechDivision\Import\Connection\ConnectionInterface The connection instance |
|
| 86 | */ |
|
| 87 | public function getConnection() |
|
| 88 | { |
|
| 89 | return $this->connection; |
|
| 90 | } |
|
| 91 | ||
| 92 | /** |
|
| 93 | * Set's the repository instance with the SQL statements to use. |
|
| 94 | * |
|
| 95 | * @param \TechDivision\Import\Repositories\SqlStatementRepositoryInterface $sqlStatementRepository The repository instance |
|
| 96 | * |
|
| 97 | * @return void |
|
| 98 | */ |
|
| 99 | public function setSqlStatementRepository(SqlStatementRepositoryInterface $sqlStatementRepository) |
|
| 100 | { |
|
| 101 | $this->sqlStatementRepository = $sqlStatementRepository; |
|
| 102 | } |
|
| 103 | ||
| 104 | /** |
|
| 105 | * Return's the repository instance with the SQL statements to use. |
|
| 106 | * |
|
| 107 | * @return \TechDivision\Import\Repositories\SqlStatementRepositoryInterface The repository instance |
|
| 108 | */ |
|
| 109 | public function getSqlStatementRepository() |
|
| 110 | { |
|
| 111 | return $this->sqlStatementRepository; |
|
| 112 | } |
|
| 113 | ||
| 114 | /** |
|
| 115 | * Load's the SQL statement with the passed ID from the SQL repository. |
|
| 116 | * |
|
| 117 | * @param string $id The ID of the SQL statement to load |
|
| 118 | * |
|
| 119 | * @return string The SQL statement with the passed ID |
|
| 120 | */ |
|
| 121 | public function loadStatement($id) |
|
| 122 | { |
|
| 123 | return $this->getSqlStatementRepository()->load($id); |
|
| 124 | } |
|
| 125 | } |
|
| 126 | ||