Skip to content

Commit

Permalink
Release/v0.1.2 (#124)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
pchalupa authored Mar 9, 2021
1 parent ca68280 commit edb524a
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 97 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ composer phpstan // Runs static analysis
```
composer cs // Checks coding standarts
composer cs:fix // Fixes coding standarts
```

### PHP Unit
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "stacha/back-end",
"type": "project",
"description": "Back-end for our applications.",
"version": "0.1.1",
"version": "0.1.2",
"license": "MIT",
"authors": [
{
Expand Down Expand Up @@ -56,6 +56,7 @@
"migrations:diff": "composer orm:clear-cache:metadata && doctrine-migrations migrations:diff",
"migrations:status": "doctrine-migrations migrations:status",
"migrations:migrate": "doctrine-migrations migrations:migrate",
"migrations:generate": "doctrine-migrations migrations:generate",
"phpstan": "phpstan analyse",
"cs": "vendor/bin/php-cs-fixer fix src --dry-run --ansi",
"cs:fix": "vendor/bin/php-cs-fixer fix src --ansi"
Expand Down
53 changes: 26 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/Controller/Gallery.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function getAll(): array
$queryBuilder = $this->entityManager->createQueryBuilder();
$queryBuilder->select('g')
->from('App\Model\Entity\Gallery', 'g')
->orderBy('g.updated', 'DESC');
->orderBy('g.created', 'DESC');
$gallery = $queryBuilder->getQuery()->getArrayResult();

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

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

array_push($response, array('id' => $gallery->getId(), 'title' => $gallery->getTitle(), 'description' => $gallery->getDescription(), 'alias' => $gallery->getAlias(), 'thumbnail' => $thumbnail, 'updated' => $gallery->getUpdated(), 'state' => $gallery->getState()));
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()));
}

$this->view->render($response);
Expand Down
52 changes: 37 additions & 15 deletions src/Model/Entity/Article.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace App\Model\Entity;

use Doctrine\ORM\Mapping as ORM;
use DateTime;

/**
* @ORM\Entity
Expand All @@ -16,38 +17,44 @@ class Article
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue
* @var int
* @var int
*/
protected $id;

/**
* @ORM\Column(type="string", length=512)
* @var string
* @var string
*/
protected $title;

/**
* @ORM\Column(type="string", unique=true, length=191)
* @var string
* @var string
*/
protected $alias;

/**
* @ORM\Column(type="string", nullable=true)
* @var string
* @var string
*/
protected $content;

/**
* @ORM\Column(type="datetime", nullable=false)
* @ORM\Version
* @var \DateTime
* @var DateTime
*/
protected $updated;

/**
* @ORM\Column(type="datetime", nullable=false)
* @var DateTime
*/
protected $created;

/**
* @ORM\Column(type="boolean")
* @var boolean
* @var boolean
*/
protected $state;

Expand All @@ -63,11 +70,10 @@ public function __construct(string $title = "", string $alias = "", string $cont
$this->setTitle($title);
$this->setAlias($alias);
$this->setContent($content);
$this->setCreated(new DateTime("now"));
$this->setState($state);
}



/**
* Sets article title.
*
Expand Down Expand Up @@ -111,10 +117,21 @@ public function setContent(string $content): Self
*/
public function setUpdated(): self
{
$this->updated = new \DateTime("now");
$this->updated = new DateTime("now");
return $this;
}

/**
* Sets article created date
*
* @param DateTime $created
* @return self
*/
public function setCreated(DateTime $created): self
{
$this->created = $created;
return $this;
}

/**
* Sets article state
Expand All @@ -128,7 +145,6 @@ public function setState(bool $state): self
return $this;
}


/**
* Returns article ID.
*
Expand Down Expand Up @@ -159,8 +175,6 @@ public function getAlias(): string
return $this->alias;
}



/**
* Returns article content.
*
Expand All @@ -171,17 +185,25 @@ public function getContent(): string
return $this->content;
}


/**
* Returns article updated date.
*
* @return \DateTime
* @return DateTime
*/
public function getUpdated(): \DateTime
public function getUpdated(): DateTime
{
return $this->updated;
}

/**
* Returns article created date
*
* @return DateTime
*/
public function getCreated(): DateTime
{
return $this->created;
}

/**
* Returns article state
Expand Down
Loading

0 comments on commit edb524a

Please sign in to comment.