1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Product\Repositories\UrlRewriteRepository |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Product\Repositories; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Repositories\AbstractRepository; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Repository implementation to load URL rewrite data. |
27
|
|
|
* |
28
|
|
|
* @author Tim Wagner <[email protected]> |
29
|
|
|
* @copyright 2016 TechDivision GmbH <[email protected]> |
30
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
31
|
|
|
* @link https://github.com/techdivision/import |
32
|
|
|
* @link http://www.techdivision.com |
33
|
|
|
*/ |
34
|
|
|
class UrlRewriteRepository extends AbstractRepository |
35
|
|
|
{ |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Initializes the repository's prepared statements. |
39
|
|
|
* |
40
|
|
|
* @return void |
41
|
|
|
*/ |
42
|
|
|
public function init() |
43
|
|
|
{ |
44
|
|
|
|
45
|
|
|
// load the utility class name |
46
|
|
|
$utilityClassName = $this->getUtilityClassName(); |
47
|
|
|
|
48
|
|
|
// initialize the prepared statements |
49
|
|
|
$this->urlRewritesStmt = $this->getConnection() |
|
|
|
|
50
|
|
|
->prepare( |
51
|
|
|
$this->myStmt = $utilityClassName::URL_REWRITES_BY_ENTITY_TYPE_AND_ENTITY_ID |
|
|
|
|
52
|
|
|
); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* Return's an array with the URL rewrites for the passed entity type and ID. |
57
|
|
|
* |
58
|
|
|
* @param string $entityType The entity type to load the URL rewrites for |
59
|
|
|
* @param integer $entityId The entity ID to load the URL rewrites for |
60
|
|
|
* |
61
|
|
|
* @return array The URL rewrites |
62
|
|
|
*/ |
63
|
|
|
public function findAllByEntityTypeAndEntityId($entityType, $entityId) |
64
|
|
|
{ |
65
|
|
|
// load and return the URL rewrites |
66
|
|
|
$this->urlRewritesStmt->execute(array($entityType, $entityId)); |
67
|
|
|
return $this->urlRewritesStmt->fetchAll(); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: