-
Notifications
You must be signed in to change notification settings - Fork 0
/
CleanURLAbstract.php
192 lines (173 loc) · 4.27 KB
/
CleanURLAbstract.php
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
// vim: set ts=4 sw=4 sts=4 et:
/**
* X-Cart
*
* NOTICE OF LICENSE
*
* This source file is subject to the software license agreement
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://www.x-cart.com/license-agreement.html
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to licensing@x-cart.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not modify this file if you wish to upgrade X-Cart to newer versions
* in the future. If you wish to customize X-Cart for your needs please
* refer to http://www.x-cart.com/ for more information.
*
* @category X-Cart 5
* @author Qualiteam software Ltd <info@x-cart.com>
* @copyright Copyright (c) 2011-2015 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
* @license http://www.x-cart.com/license-agreement.html X-Cart 5 License Agreement
* @link http://www.x-cart.com/
*/
namespace XLite\Model;
/**
* @MappedSuperClass (repositoryClass="\XLite\Model\Repo\CleanURL")
*/
abstract class CleanURLAbstract extends \XLite\Model\AEntity
{
/**
* Unique id
*
* @var integer
*
* @Id
* @GeneratedValue (strategy="AUTO")
* @Column (type="integer", options={"unsigned": true })
*/
protected $id;
/**
* Relation to a product entity
*
* @var \XLite\Model\Product
*
* @ManyToOne (targetEntity="XLite\Model\Product", inversedBy="cleanURLs")
* @JoinColumn (name="product_id", referencedColumnName="product_id")
*/
protected $product;
/**
* Relation to a category entity
*
* @var \XLite\Model\Category
*
* @ManyToOne (targetEntity="XLite\Model\Category", inversedBy="cleanURLs")
* @JoinColumn (name="category_id", referencedColumnName="category_id")
*/
protected $category;
/**
* Clean URL
*
* @var string
*
* @Column (type="string", length=255, nullable=true)
*/
protected $cleanURL;
/**
* Set entity
*
* @param \XLite\Model\AEntity $entity Entity
*
* @return void
*/
public function setEntity($entity)
{
$entityType = \XLite\Model\Repo\CleanURL::getEntityType($entity);
$method = 'set' . \XLite\Core\Converter::convertToCamelCase($entityType);
if (method_exists($this, $method)) {
$this->{$method}($entity);
}
}
/**
* Get entity
*
* @return \XLite\Model\AEntity
*/
public function getEntity()
{
$entity = null;
foreach (\XLite\Model\Repo\CleanURL::getEntityTypes() as $type) {
$method = 'get' . \XLite\Core\Converter::convertToCamelCase($type);
if (method_exists($this, $method)) {
$entity = $this->{$method}();
if ($entity) {
break;
}
}
}
return $entity;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set cleanURL
*
* @param string $cleanURL
* @return CleanURL
*/
public function setCleanURL($cleanURL)
{
$this->cleanURL = $cleanURL;
return $this;
}
/**
* Get cleanURL
*
* @return string
*/
public function getCleanURL()
{
return $this->cleanURL;
}
/**
* Set product
*
* @param XLite\Model\Product $product
* @return CleanURL
*/
public function setProduct(\XLite\Model\Product $product = null)
{
$this->product = $product;
return $this;
}
/**
* Get product
*
* @return XLite\Model\Product
*/
public function getProduct()
{
return $this->product;
}
/**
* Set category
*
* @param XLite\Model\Category $category
* @return CleanURL
*/
public function setCategory(\XLite\Model\Category $category = null)
{
$this->category = $category;
return $this;
}
/**
* Get category
*
* @return XLite\Model\Category
*/
public function getCategory()
{
return $this->category;
}
}