forked from doctrine/doctrine2-orm-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_bug.php
More file actions
36 lines (29 loc) · 941 Bytes
/
create_bug.php
File metadata and controls
36 lines (29 loc) · 941 Bytes
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
<?php
// create_bug.php
require_once "bootstrap.php";
$theReporterId = $argv[1];
$theDefaultEngineerId = (isset($argv[2])) ? $argv[2] : 1;
$productIds = explode(",", $argv[3]);
$reporter = $entityManager->find("User", $theReporterId);
$engineer = $entityManager->find("User", $theDefaultEngineerId);
if (!$reporter || !$engineer) {
echo "No reporter and/or engineer found for the input.\n";
exit(1);
}
$bug = new Bug();
$bug->setDescription("Something does not work!");
$bug->setCreated(new DateTime("now"));
$bug->setStatus("OPEN");
foreach ($productIds AS $productId) {
$product = $entityManager->find("Product", $productId);
if (!$product) {
echo "No product found for the input.\n";
exit(1);
}
$bug->assignToProduct($product);
}
$bug->setReporter($reporter);
$bug->setEngineer($engineer);
$entityManager->persist($bug);
$entityManager->flush();
echo "Your new Bug Id: ".$bug->getId()."\n";