Skip to content

Commit edb524a

Browse files
authored
Release/v0.1.2 (#124)
* fix(BodyData): Added default body data (#118) * Update dependencies * Add default value to body data * feat(Migrations): Implemented db migrations (#119) * Install doctrine migrations package * Add migrations configuration * Add migrations folder * Update usefull commands * Generates initial migration * Load all migrations * Update readme * Update pr template * Add foreign keys * Rename workflow * Move cache up * Move checkout * Release/v0.1.1 (#120) (#121) * fix(BodyData): Added default body data (#118) * Update dependencies * Add default value to body data * feat(Migrations): Implemented db migrations (#119) * Install doctrine migrations package * Add migrations configuration * Add migrations folder * Update usefull commands * Generates initial migration * Load all migrations * Update readme * Update pr template * Add foreign keys * Rename workflow * Move cache up * Move checkout * Bump version * Remove empty line * feat(Created): Added created column (#122) * Add created column * Generate migration * Add created column * Generate migration * Update dependencies * Sort by created date * Fix/rename users table (#123) * Add migrations generate command * Rename table * Generate migration * Fix migration * Fix migration * Bump version * Fix lock file
1 parent ca68280 commit edb524a

File tree

11 files changed

+300
-97
lines changed

11 files changed

+300
-97
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ composer phpstan // Runs static analysis
5959
```
6060
composer cs // Checks coding standarts
6161
composer cs:fix // Fixes coding standarts
62-
6362
```
6463

6564
### PHP Unit

composer.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "stacha/back-end",
33
"type": "project",
44
"description": "Back-end for our applications.",
5-
"version": "0.1.1",
5+
"version": "0.1.2",
66
"license": "MIT",
77
"authors": [
88
{
@@ -56,6 +56,7 @@
5656
"migrations:diff": "composer orm:clear-cache:metadata && doctrine-migrations migrations:diff",
5757
"migrations:status": "doctrine-migrations migrations:status",
5858
"migrations:migrate": "doctrine-migrations migrations:migrate",
59+
"migrations:generate": "doctrine-migrations migrations:generate",
5960
"phpstan": "phpstan analyse",
6061
"cs": "vendor/bin/php-cs-fixer fix src --dry-run --ansi",
6162
"cs:fix": "vendor/bin/php-cs-fixer fix src --ansi"

composer.lock

Lines changed: 26 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Controller/Gallery.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getAll(): array
4040
$queryBuilder = $this->entityManager->createQueryBuilder();
4141
$queryBuilder->select('g')
4242
->from('App\Model\Entity\Gallery', 'g')
43-
->orderBy('g.updated', 'DESC');
43+
->orderBy('g.created', 'DESC');
4444
$gallery = $queryBuilder->getQuery()->getArrayResult();
4545

4646
foreach ($gallery as &$item) {
@@ -114,7 +114,7 @@ public function find(string $key, string $value): array
114114
$queryBuilder->select('g')
115115
->from('App\Model\Entity\Gallery', 'g')
116116
->where('g.' . $key . ' = ' . $value)
117-
->orderBy('g.updated', 'DESC');
117+
->orderBy('g.created', 'DESC');
118118
$galleries = $queryBuilder->getQuery()->getResult();
119119

120120
$response = array();
@@ -127,7 +127,7 @@ public function find(string $key, string $value): array
127127
$thumbnail->source = $image->getSource();
128128
}
129129

130-
array_push($response, array('id' => $gallery->getId(), 'title' => $gallery->getTitle(), 'description' => $gallery->getDescription(), 'alias' => $gallery->getAlias(), 'thumbnail' => $thumbnail, 'updated' => $gallery->getUpdated(), 'state' => $gallery->getState()));
130+
array_push($response, array('id' => $gallery->getId(), 'title' => $gallery->getTitle(), 'description' => $gallery->getDescription(), 'alias' => $gallery->getAlias(), 'thumbnail' => $thumbnail, 'updated' => $gallery->getUpdated(), 'created' => $gallery->getCreated(), 'state' => $gallery->getState()));
131131
}
132132

133133
$this->view->render($response);

src/Model/Entity/Article.php

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace App\Model\Entity;
66

77
use Doctrine\ORM\Mapping as ORM;
8+
use DateTime;
89

910
/**
1011
* @ORM\Entity
@@ -16,38 +17,44 @@ class Article
1617
* @ORM\Id
1718
* @ORM\Column(type="integer")
1819
* @ORM\GeneratedValue
19-
* @var int
20+
* @var int
2021
*/
2122
protected $id;
2223

2324
/**
2425
* @ORM\Column(type="string", length=512)
25-
* @var string
26+
* @var string
2627
*/
2728
protected $title;
2829

2930
/**
3031
* @ORM\Column(type="string", unique=true, length=191)
31-
* @var string
32+
* @var string
3233
*/
3334
protected $alias;
3435

3536
/**
3637
* @ORM\Column(type="string", nullable=true)
37-
* @var string
38+
* @var string
3839
*/
3940
protected $content;
4041

4142
/**
4243
* @ORM\Column(type="datetime", nullable=false)
4344
* @ORM\Version
44-
* @var \DateTime
45+
* @var DateTime
4546
*/
4647
protected $updated;
4748

49+
/**
50+
* @ORM\Column(type="datetime", nullable=false)
51+
* @var DateTime
52+
*/
53+
protected $created;
54+
4855
/**
4956
* @ORM\Column(type="boolean")
50-
* @var boolean
57+
* @var boolean
5158
*/
5259
protected $state;
5360

@@ -63,11 +70,10 @@ public function __construct(string $title = "", string $alias = "", string $cont
6370
$this->setTitle($title);
6471
$this->setAlias($alias);
6572
$this->setContent($content);
73+
$this->setCreated(new DateTime("now"));
6674
$this->setState($state);
6775
}
6876

69-
70-
7177
/**
7278
* Sets article title.
7379
*
@@ -111,10 +117,21 @@ public function setContent(string $content): Self
111117
*/
112118
public function setUpdated(): self
113119
{
114-
$this->updated = new \DateTime("now");
120+
$this->updated = new DateTime("now");
115121
return $this;
116122
}
117123

124+
/**
125+
* Sets article created date
126+
*
127+
* @param DateTime $created
128+
* @return self
129+
*/
130+
public function setCreated(DateTime $created): self
131+
{
132+
$this->created = $created;
133+
return $this;
134+
}
118135

119136
/**
120137
* Sets article state
@@ -128,7 +145,6 @@ public function setState(bool $state): self
128145
return $this;
129146
}
130147

131-
132148
/**
133149
* Returns article ID.
134150
*
@@ -159,8 +175,6 @@ public function getAlias(): string
159175
return $this->alias;
160176
}
161177

162-
163-
164178
/**
165179
* Returns article content.
166180
*
@@ -171,17 +185,25 @@ public function getContent(): string
171185
return $this->content;
172186
}
173187

174-
175188
/**
176189
* Returns article updated date.
177190
*
178-
* @return \DateTime
191+
* @return DateTime
179192
*/
180-
public function getUpdated(): \DateTime
193+
public function getUpdated(): DateTime
181194
{
182195
return $this->updated;
183196
}
184197

198+
/**
199+
* Returns article created date
200+
*
201+
* @return DateTime
202+
*/
203+
public function getCreated(): DateTime
204+
{
205+
return $this->created;
206+
}
185207

186208
/**
187209
* Returns article state

0 commit comments

Comments
 (0)