Completed
Push — master ( 0c2dcd...3f964a )
by Tim
22s queued 16s
created

ProductBundleProcessor   B

Complexity

Total Complexity 30

Size/Duplication

Total Lines 446
Duplicated Lines 0 %

Coupling/Cohesion

Components 9
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 30
lcom 9
cbo 4
dl 0
loc 446
ccs 0
cts 137
cp 0
rs 7.1428
c 0
b 0
f 0

30 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 1
A setConnection() 0 4 1
A getConnection() 0 4 1
A beginTransaction() 0 4 1
A commit() 0 4 1
A rollBack() 0 4 1
A setProductBundleOptionAction() 0 4 1
A getProductBundleOptionAction() 0 4 1
A setProductBundleOptionValueAction() 0 4 1
A getProductBundleOptionValueAction() 0 4 1
A setProductBundleSelectionAction() 0 4 1
A getProductBundleSelectionAction() 0 4 1
A setProductBundleSelectionPriceAction() 0 4 1
A getProductBundleSelectionPriceAction() 0 4 1
A setBundleOptionRepository() 0 4 1
A getBundleOptionRepository() 0 4 1
A setBundleOptionValueRepository() 0 4 1
A getBundleOptionValueRepository() 0 4 1
A setBundleSelectionRepository() 0 4 1
A getBundleSelectionRepository() 0 4 1
A setBundleSelectionPriceRepository() 0 4 1
A getBundleSelectionPriceRepository() 0 4 1
A loadBundleOption() 0 4 1
A loadBundleOptionValue() 0 4 1
A loadBundleSelection() 0 4 1
A loadBundleSelectionPrice() 0 4 1
A persistProductBundleOption() 0 4 1
A persistProductBundleOptionValue() 0 4 1
A persistProductBundleSelection() 0 4 1
A persistProductBundleSelectionPrice() 0 4 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Product\Bundle\Services\ProductProcessor
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-product-bundle
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Product\Bundle\Services;
22
23
use TechDivision\Import\Product\Bundle\Repositories\BundleOptionRepository;
24
use TechDivision\Import\Product\Bundle\Repositories\BundleOptionValueRepository;
25
use TechDivision\Import\Product\Bundle\Repositories\BundleSelectionRepository;
26
use TechDivision\Import\Product\Bundle\Repositories\BundleSelectionPriceRepository;
27
use TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionAction;
28
use TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionValueAction;
29
use TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionAction;
30
use TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionPriceAction;
31
32
/**
33
 * A SLSB providing methods to load product data using a PDO connection.
34
 *
35
 * @author    Tim Wagner <[email protected]>
36
 * @copyright 2016 TechDivision GmbH <[email protected]>
37
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
38
 * @link      https://github.com/techdivision/import-product-bundle
39
 * @link      http://www.techdivision.com
40
 */
41
class ProductBundleProcessor implements ProductBundleProcessorInterface
42
{
43
44
    /**
45
     * A PDO connection initialized with the values from the Doctrine EntityManager.
46
     *
47
     * @var \PDO
48
     */
49
    protected $connection;
50
51
    /**
52
     * The action for product bundle option CRUD methods.
53
     *
54
     * @var \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionAction
55
     */
56
    protected $productBundleOptionAction;
57
58
    /**
59
     * The action for product bundle option value CRUD methods.
60
     *
61
     * @var \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionValueAction
62
     */
63
    protected $productBundleOptionValueAction;
64
65
    /**
66
     * The action for product bundle selection CRUD methods.
67
     *
68
     * @var \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionAction
69
     */
70
    protected $productBundleSelectionAction;
71
72
    /**
73
     * The action for product bundle selection price CRUD methods.
74
     *
75
     * @var \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionPriceAction
76
     */
77
    protected $productBundleSelectionPriceAction;
78
79
    /**
80
     * The repository to load bundle option data.
81
     *
82
     * @var \TechDivision\Import\Product\Bundle\Respository\BundleOptionRepository
83
     */
84
    protected $bundleOptionRespository;
85
86
    /**
87
     * The repository to load bundle option value data.
88
     *
89
     * @var \TechDivision\Import\Product\Bundle\Respository\BundleOptionValueRepository
90
     */
91
    protected $bundleOptionValueRespository;
92
93
    /**
94
     * The repository to load bundle selection data.
95
     *
96
     * @var \TechDivision\Import\Product\Bundle\Respository\BundleSelectionRepository
97
     */
98
    protected $bundleSelectionRespository;
99
100
    /**
101
     * The repository to load bundle selection price data.
102
     *
103
     * @var \TechDivision\Import\Product\Bundle\Respository\BundleSelectionPriceRepository
104
     */
105
    protected $bundleSelectionPriceRespository;
106
107
    /**
108
     * Initialize the processor with the necessary assembler and repository instances.
109
     *
110
     * @param \PDO                                                                           $connection                        The PDO connection to use
111
     * @param \TechDivision\Import\Product\Bundle\Respository\BundleOptionRepository         $bundleOptionRepository            The bundle option repository to use
112
     * @param \TechDivision\Import\Product\Bundle\Respository\BundleOptionValueRepository    $bundleOptionValueRepository       The bundle option value repository to use
113
     * @param \TechDivision\Import\Product\Bundle\Respository\BundleSelectionRepository      $bundleSelectionRepository         The bundle selection repository to use
114
     * @param \TechDivision\Import\Product\Bundle\Respository\BundleSelectionPriceRepository $bundleSelectionPriceRepository    The bundle selection price repository to use
115
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionAction          $productBundleOptionAction         The product bundle option action to use
116
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionValueAction     $productBundleOptionValueAction    The product bundle option value action to use
117
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionAction       $productBundleSelectionAction      The product bundle selection action to use
118
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionPriceAction  $productBundleSelectionPriceAction The product bundle selection price action to use
119
     */
120
    public function __construct(
121
        \PDO $connection,
122
        BundleOptionRepository $bundleOptionRepository,
123
        BundleOptionValueRepository $bundleOptionValueRepository,
124
        BundleSelectionRepository $bundleSelectionRepository,
125
        BundleSelectionPriceRepository $bundleSelectionPriceRepository,
126
        ProductBundleOptionAction $productBundleOptionAction,
127
        ProductBundleOptionValueAction $productBundleOptionValueAction,
128
        ProductBundleSelectionAction $productBundleSelectionAction,
129
        ProductBundleSelectionPriceAction $productBundleSelectionPriceAction
130
    ) {
131
        $this->setConnection($connection);
132
        $this->setBundleOptionRepository($bundleOptionRepository);
0 ignored issues
show
Documentation introduced by
$bundleOptionRepository is of type object<TechDivision\Impo...BundleOptionRepository>, but the function expects a object<TechDivision\Impo...undleOptionRespository>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
133
        $this->setBundleOptionValueRepository($bundleOptionValueRepository);
0 ignored issues
show
Documentation introduced by
$bundleOptionValueRepository is of type object<TechDivision\Impo...eOptionValueRepository>, but the function expects a object<TechDivision\Impo...OptionValueRespository>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
134
        $this->setBundleSelectionRepository($bundleSelectionRepository);
0 ignored issues
show
Documentation introduced by
$bundleSelectionRepository is of type object<TechDivision\Impo...dleSelectionRepository>, but the function expects a object<TechDivision\Impo...leSelectionRespository>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
135
        $this->setBundleSelectionPriceRepository($bundleSelectionPriceRepository);
0 ignored issues
show
Documentation introduced by
$bundleSelectionPriceRepository is of type object<TechDivision\Impo...lectionPriceRepository>, but the function expects a object<TechDivision\Impo...ectionPriceRespository>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
136
        $this->setProductBundleOptionAction($productBundleOptionAction);
137
        $this->setProductBundleOptionValueAction($productBundleOptionValueAction);
138
        $this->setProductBundleSelectionAction($productBundleSelectionAction);
139
        $this->setProductBundleSelectionPriceAction($productBundleSelectionPriceAction);
140
    }
141
142
    /**
143
     * Set's the passed connection.
144
     *
145
     * @param \PDO $connection The connection to set
146
     *
147
     * @return void
148
     */
149
    public function setConnection(\PDO $connection)
150
    {
151
        $this->connection = $connection;
152
    }
153
154
    /**
155
     * Return's the connection.
156
     *
157
     * @return \PDO The connection instance
158
     */
159
    public function getConnection()
160
    {
161
        return $this->connection;
162
    }
163
164
    /**
165
     * Turns off autocommit mode. While autocommit mode is turned off, changes made to the database via the PDO
166
     * object instance are not committed until you end the transaction by calling ProductProcessor::commit().
167
     * Calling ProductProcessor::rollBack() will roll back all changes to the database and return the connection
168
     * to autocommit mode.
169
     *
170
     * @return boolean Returns TRUE on success or FALSE on failure
171
     * @link http://php.net/manual/en/pdo.begintransaction.php
172
     */
173
    public function beginTransaction()
174
    {
175
        return $this->connection->beginTransaction();
176
    }
177
178
    /**
179
     * Commits a transaction, returning the database connection to autocommit mode until the next call to
180
     * ProductProcessor::beginTransaction() starts a new transaction.
181
     *
182
     * @return boolean Returns TRUE on success or FALSE on failure
183
     * @link http://php.net/manual/en/pdo.commit.php
184
     */
185
    public function commit()
186
    {
187
        return $this->connection->commit();
188
    }
189
190
    /**
191
     * Rolls back the current transaction, as initiated by ProductProcessor::beginTransaction().
192
     *
193
     * If the database was set to autocommit mode, this function will restore autocommit mode after it has
194
     * rolled back the transaction.
195
     *
196
     * Some databases, including MySQL, automatically issue an implicit COMMIT when a database definition
197
     * language (DDL) statement such as DROP TABLE or CREATE TABLE is issued within a transaction. The implicit
198
     * COMMIT will prevent you from rolling back any other changes within the transaction boundary.
199
     *
200
     * @return boolean Returns TRUE on success or FALSE on failure
201
     * @link http://php.net/manual/en/pdo.rollback.php
202
     */
203
    public function rollBack()
204
    {
205
        return $this->connection->rollBack();
206
    }
207
208
    /**
209
     * Set's the action with the product bundle option CRUD methods.
210
     *
211
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionAction $productBundleOptionAction The action with the product bundle option CRUD methods
212
     *
213
     * @return void
214
     */
215
    public function setProductBundleOptionAction($productBundleOptionAction)
216
    {
217
        $this->productBundleOptionAction = $productBundleOptionAction;
218
    }
219
220
    /**
221
     * Return's the action with the product bundle option CRUD methods.
222
     *
223
     * @return \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionAction The action instance
224
     */
225
    public function getProductBundleOptionAction()
226
    {
227
        return $this->productBundleOptionAction;
228
    }
229
230
    /**
231
     * Set's the action with the product bundle option value CRUD methods.
232
     *
233
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionValueAction $productBundleOptionValueAction The action with the product bundle option value CRUD methods
234
     *
235
     * @return void
236
     */
237
    public function setProductBundleOptionValueAction($productBundleOptionValueAction)
238
    {
239
        $this->productBundleOptionValueAction = $productBundleOptionValueAction;
240
    }
241
242
    /**
243
     * Return's the action with the product bundle option value CRUD methods.
244
     *
245
     * @return \TechDivision\Import\Product\Bundle\Actions\ProductBundleOptionValueAction The action instance
246
     */
247
    public function getProductBundleOptionValueAction()
248
    {
249
        return $this->productBundleOptionValueAction;
250
    }
251
252
    /**
253
     * Set's the action with the product bundle selection CRUD methods.
254
     *
255
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionAction $productBundleSelectionAction The action with the product bundle selection CRUD methods
256
     *
257
     * @return void
258
     */
259
    public function setProductBundleSelectionAction($productBundleSelectionAction)
260
    {
261
        $this->productBundleSelectionAction = $productBundleSelectionAction;
262
    }
263
264
    /**
265
     * Return's the action with the product bundle selection CRUD methods.
266
     *
267
     * @return \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionAction The action instance
268
     */
269
    public function getProductBundleSelectionAction()
270
    {
271
        return $this->productBundleSelectionAction;
272
    }
273
274
    /**
275
     * Set's the action with the product bundle selection price CRUD methods.
276
     *
277
     * @param \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionPriceAction $productBundleSelectionPriceAction The action with the product bundle selection price CRUD methods
278
     *
279
     * @return void
280
     */
281
    public function setProductBundleSelectionPriceAction($productBundleSelectionPriceAction)
282
    {
283
        $this->productBundleSelectionPriceAction = $productBundleSelectionPriceAction;
284
    }
285
286
    /**
287
     * Return's the action with the product bundle selection price CRUD methods.
288
     *
289
     * @return \TechDivision\Import\Product\Bundle\Actions\ProductBundleSelectionPriceAction The action instance
290
     */
291
    public function getProductBundleSelectionPriceAction()
292
    {
293
        return $this->productBundleSelectionPriceAction;
294
    }
295
296
    /**
297
     * Set's the repository to load bundle option data.
298
     *
299
     * @param \TechDivision\Import\Product\Bundle\Repository\BundleOptionRespository $bundleOptionRespository The repository instance
300
     *
301
     * @return void
302
     */
303
    public function setBundleOptionRepository($bundleOptionRespository)
304
    {
305
        $this->bundleOptionRespository = $bundleOptionRespository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $bundleOptionRespository of type object<TechDivision\Impo...undleOptionRespository> is incompatible with the declared type object<TechDivision\Impo...BundleOptionRepository> of property $bundleOptionRespository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
306
    }
307
308
    /**
309
     * Return's the respository to load bundle option data.
310
     *
311
     * @return \TechDivision\Import\Product\Bundle\Repository\BundleOptionRespository The repository instance
312
     */
313
    public function getBundleOptionRepository()
314
    {
315
        return $this->bundleOptionRespository;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->bundleOptionRespository; (TechDivision\Import\Prod...\BundleOptionRepository) is incompatible with the return type declared by the interface TechDivision\Import\Prod...tBundleOptionRepository of type TechDivision\Import\Prod...BundleOptionRespository.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
316
    }
317
318
    /**
319
     * Set's the repository to load bundle option value data.
320
     *
321
     * @param \TechDivision\Import\Product\Bundle\Repository\BundleOptionValueRespository $bundleOptionValueRespository The repository instance
322
     *
323
     * @return void
324
     */
325
    public function setBundleOptionValueRepository($bundleOptionValueRespository)
326
    {
327
        $this->bundleOptionValueRespository = $bundleOptionValueRespository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $bundleOptionValueRespository of type object<TechDivision\Impo...OptionValueRespository> is incompatible with the declared type object<TechDivision\Impo...eOptionValueRepository> of property $bundleOptionValueRespository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
328
    }
329
330
    /**
331
     * Return's the respository to load bundle option value data.
332
     *
333
     * @return \TechDivision\Import\Product\Bundle\Repository\BundleOptionValueRespository The repository instance
334
     */
335
    public function getBundleOptionValueRepository()
336
    {
337
        return $this->bundleOptionValueRespository;
0 ignored issues
show
Bug Best Practice introduced by
The return type of return $this->bundleOptionValueRespository; (TechDivision\Import\Prod...leOptionValueRepository) is incompatible with the return type declared by the interface TechDivision\Import\Prod...leOptionValueRepository of type TechDivision\Import\Prod...eOptionValueRespository.

If you return a value from a function or method, it should be a sub-type of the type that is given by the parent type f.e. an interface, or abstract method. This is more formally defined by the Lizkov substitution principle, and guarantees that classes that depend on the parent type can use any instance of a child type interchangably. This principle also belongs to the SOLID principles for object oriented design.

Let’s take a look at an example:

class Author {
    private $name;

    public function __construct($name) {
        $this->name = $name;
    }

    public function getName() {
        return $this->name;
    }
}

abstract class Post {
    public function getAuthor() {
        return 'Johannes';
    }
}

class BlogPost extends Post {
    public function getAuthor() {
        return new Author('Johannes');
    }
}

class ForumPost extends Post { /* ... */ }

function my_function(Post $post) {
    echo strtoupper($post->getAuthor());
}

Our function my_function expects a Post object, and outputs the author of the post. The base class Post returns a simple string and outputting a simple string will work just fine. However, the child class BlogPost which is a sub-type of Post instead decided to return an object, and is therefore violating the SOLID principles. If a BlogPost were passed to my_function, PHP would not complain, but ultimately fail when executing the strtoupper call in its body.

Loading history...
338
    }
339
340
    /**
341
     * Set's the repository to load bundle selection data.
342
     *
343
     * @param \TechDivision\Import\Product\Bundle\Repository\BundleSelectionRespository $bundleSelectionRespository The repository instance
344
     *
345
     * @return void
346
     */
347
    public function setBundleSelectionRepository($bundleSelectionRespository)
348
    {
349
        $this->bundleSelectionRespository = $bundleSelectionRespository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $bundleSelectionRespository of type object<TechDivision\Impo...leSelectionRespository> is incompatible with the declared type object<TechDivision\Impo...dleSelectionRepository> of property $bundleSelectionRespository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
350
    }
351
352
    /**
353
     * Return's the respository to load bundle selection data.
354
     *
355
     * @return \TechDivision\Import\Product\Bundle\Repository\BundleSelectionRespository The repository instance
356
     */
357
    public function getBundleSelectionRepository()
358
    {
359
        return $this->bundleSelectionRespository;
360
    }
361
362
    /**
363
     * Set's the repository to load bundle selection price data.
364
     *
365
     * @param \TechDivision\Import\Product\Bundle\Repository\BundleSelectionPriceRespository $bundleSelectionPriceRespository The repository instance
366
     *
367
     * @return void
368
     */
369
    public function setBundleSelectionPriceRepository($bundleSelectionPriceRespository)
370
    {
371
        $this->bundleSelectionPriceRespository = $bundleSelectionPriceRespository;
0 ignored issues
show
Documentation Bug introduced by
It seems like $bundleSelectionPriceRespository of type object<TechDivision\Impo...ectionPriceRespository> is incompatible with the declared type object<TechDivision\Impo...lectionPriceRepository> of property $bundleSelectionPriceRespository.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
372
    }
373
374
    /**
375
     * Return's the respository to load bundle selection price data.
376
     *
377
     * @return \TechDivision\Import\Product\Bundle\Repository\BundleSelectionPriceRespository The repository instance
378
     */
379
    public function getBundleSelectionPriceRepository()
380
    {
381
        return $this->bundleSelectionPriceRespository;
382
    }
383
384
    /**
385
     * Load's the bundle option with the passed name, store + parent ID.
386
     *
387
     * @param string  $title    The title of the bundle option to be returned
388
     * @param integer $storeId  The store ID of the bundle option to be returned
389
     * @param integer $parentId The entity of the product the bundle option is related with
390
     *
391
     * @return array The bundle option
392
     */
393
    public function loadBundleOption($title, $storeId, $parentId)
394
    {
395
        return $this->getBundleOptionRepository()->findOneByNameAndStoreIdAndParentId($title, $storeId, $parentId);
396
    }
397
398
    /**
399
     * Load's the bundle option value with the passed name, store + parent ID.
400
     *
401
     * @param string  $title    The title of the bundle option value to be returned
402
     * @param integer $storeId  The store ID of the bundle option value to be returned
403
     * @param integer $parentId The entity of the product the bundle option value is related with
404
     *
405
     * @return array The bundle option
406
     */
407
    public function loadBundleOptionValue($title, $storeId, $parentId)
408
    {
409
        return $this->getBundleOptionValueRepository()->findOneByNameAndStoreIdAndParentId($title, $storeId, $parentId);
410
    }
411
412
    /**
413
     * Load's the bundle selection value with the passed option/product/parent product ID.
414
     *
415
     * @param integer $optionId        The option ID of the bundle selection to be returned
416
     * @param integer $productId       The product ID of the bundle selection to be returned
417
     * @param integer $parentProductId The parent product ID of the bundle selection to be returned
418
     *
419
     * @return array The bundle selection
420
     */
421
    public function loadBundleSelection($optionId, $productId, $parentProductId)
422
    {
423
        return $this->getBundleSelectionRepository()->findOneByOptionIdAndProductIdAndParentProductId($optionId, $productId, $parentProductId);
424
    }
425
426
    /**
427
     * Load's the bundle selection price with the passed selection/website ID.
428
     *
429
     * @param integer $selectionId The selection ID of the bundle selection price to be returned
430
     * @param integer $websiteId   The website ID of the bundle selection price to be returned
431
     *
432
     * @return array The bundle selection price
433
     */
434
    public function loadBundleSelectionPrice($selectionId, $websiteId)
435
    {
436
        return $this->getBundleSelectionPriceRepository()->findOneByOptionIdAndProductIdAndParentProductId($selectionId, $websiteId);
437
    }
438
439
    /**
440
     * Persist's the passed product bundle option data and return's the ID.
441
     *
442
     * @param array $productBundleOption The product bundle option data to persist
443
     *
444
     * @return string The ID of the persisted entity
445
     */
446
    public function persistProductBundleOption($productBundleOption)
447
    {
448
        return $this->getProductBundleOptionAction()->persist($productBundleOption);
449
    }
450
451
    /**
452
     * Persist's the passed product bundle option value data.
453
     *
454
     * @param array $productBundleOptionValue The product bundle option value data to persist
455
     *
456
     * @return void
457
     */
458
    public function persistProductBundleOptionValue($productBundleOptionValue)
459
    {
460
        $this->getProductBundleOptionValueAction()->persist($productBundleOptionValue);
461
    }
462
463
    /**
464
     * Persist's the passed product bundle selection data and return's the ID.
465
     *
466
     * @param array $productBundleSelection The product bundle selection data to persist
467
     *
468
     * @return string The ID of the persisted entity
469
     */
470
    public function persistProductBundleSelection($productBundleSelection)
471
    {
472
        return $this->getProductBundleSelectionAction()->persist($productBundleSelection);
473
    }
474
475
    /**
476
     * Persist's the passed product bundle selection price data and return's the ID.
477
     *
478
     * @param array $productBundleSelectionPrice The product bundle selection price data to persist
479
     *
480
     * @return void
481
     */
482
    public function persistProductBundleSelectionPrice($productBundleSelectionPrice)
483
    {
484
        return $this->getProductBundleSelectionPriceAction()->persist($productBundleSelectionPrice);
485
    }
486
}
487