Skip to content

Commit

Permalink
add order number to category
Browse files Browse the repository at this point in the history
  • Loading branch information
rserry committed Oct 11, 2023
1 parent c2bc726 commit 0235964
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
32 changes: 32 additions & 0 deletions migrations/Version20231011121343.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php
declare(strict_types=1);

namespace Migrations;

use Doctrine\DBAL\Schema\Schema;

/**
* Version 20231011121343
*/
class Version20231011121343 extends \Doctrine\Migrations\AbstractMigration
{
/**
* @param \Doctrine\DBAL\Schema\Schema $schema
* @return void
*/
public function up(Schema $schema) : void
{
$this->abortIf($this->connection->getDatabasePlatform()->getName() !== 'postgresql', 'Migration can only be executed safely on \'postgresql\'.');

$this->addSql('ALTER TABLE nodes_pages_categories ADD order_number INT DEFAULT NULL');
}

/**
* @param \Doctrine\DBAL\Schema\Schema $schema
* @return void
*/
public function down(Schema $schema) : void
{
$this->throwIrreversibleMigrationException();
}
}
30 changes: 30 additions & 0 deletions module/PageBundle/Entity/Category.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ class Category
*/
private $active;

/**
* @var integer|null The ordering number for the category
*
* @ORM\Column(name="order_number", type="integer", nullable=true)
*/
private $orderNumber;

public function __construct()
{
$this->active = true;
Expand Down Expand Up @@ -136,4 +143,27 @@ public function deactivate()
{
$this->active = false;
}

/**
* @return integer
*/
public function getOrderNumber()
{
return $this->orderNumber;
}

/**
* @param $orderNumber
* @return self
*/
public function setOrderNumber($orderNumber)
{
$orderNumber = intval($orderNumber);
if ($orderNumber === null || $orderNumber === 0) {
$this->orderNumber = null;
} else {
$this->orderNumber = $orderNumber;
}
return $this;
}
}

0 comments on commit 0235964

Please sign in to comment.