Skip to content

Commit

Permalink
Merge pull request #3 from ipublikuj/dropnette2
Browse files Browse the repository at this point in the history
Drop Nette 2 support
  • Loading branch information
akadlec authored Feb 13, 2020
2 parents eae84d1 + 8ff8bd9 commit 07ed60d
Show file tree
Hide file tree
Showing 16 changed files with 119 additions and 114 deletions.
7 changes: 4 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
composer.lock
vendor
tests/temp
.idea
/vendor
/composer.lock
tests/*/output
6 changes: 2 additions & 4 deletions .scrutinizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ checks:
build:
environment:
php:
version: 7.2
variables:
NETTE: default
version: 7.3

dependencies:
before:
Expand All @@ -16,7 +14,7 @@ build:
tests:
override:
-
command: 'vendor/bin/tester tests -p php -c ./tests/php.ini-unix --coverage build/logs/clover.xml --coverage-src src'
command: 'vendor/bin/tester -s -p php -c ./tests/php.ini-unix tests --coverage build/logs/clover.xml --coverage-src src'
coverage:
file: build/logs/clover.xml
format: php-clover
Expand Down
21 changes: 0 additions & 21 deletions .travis.composer.php

This file was deleted.

14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
language: php

env:
- NETTE=default
- NETTE=~2.4.0

php:
- 7.2
- 7.3

before_install:
# turn off XDebug
- phpenv config-rm xdebug.ini || return 0
- composer self-update

before_script:
- php .travis.composer.php
- composer install --no-interaction --prefer-source --dev
- travis_retry composer install --no-progress --prefer-dist

script:
- vendor/bin/tester -s -p php -c ./tests/php.ini-unix tests

after_failure:
- 'for i in $(find ./tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done'
# Print *.actual content
- for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done
21 changes: 10 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,34 @@
"extra" : {
"ipub" : {
"configuration" : {
"extensions" : {
"doctrineTimestampable" : "IPub\\DoctrineTimestampable\\DI\\DoctrineTimestampableExtension"
}
"extension" : "IPub\\DoctrineTimestampable\\DI\\DoctrineTimestampableExtension"
}
}
},

"require" : {
"php" : ">=7.2.0",
"php" : ">=7.3.0",

"doctrine/orm" : "~2.5",

"nette/di" : "~2.4 || ~3.0",
"nette/utils" : "~2.5 || ~3.0",
"nette/reflection" : "~2.4"
"nette/di" : "~3.0",
"nette/utils" : "~3.0"
},

"require-dev" : {
"nette/bootstrap" : "~2.4 || ~3.0",
"nette/mail" : "~2.4 || ~3.0",
"nette/robot-loader" : "~2.4 || ~3.0",
"nette/bootstrap" : "~3.0",
"nette/http" : "~3.0",
"nette/mail" : "~3.0",
"nette/robot-loader" : "~3.0",
"nette/safe-stream" : "~2.3",
"nette/tester" : "~2.3",

"tracy/tracy" : "~2.4",

"pds/skeleton" : "~1.0",

"nettrine/orm" : "~0.3"
"nettrine/orm" : "~0.3",
"contributte/console" : "~0.7"
},

"autoload" : {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
use Nette;
use Nette\DI;
use Nette\PhpGenerator as Code;
use Nette\Utils;
use Nette\Schema;

use IPub\DoctrineTimestampable;
use IPub\DoctrineTimestampable\Events;
Expand All @@ -39,40 +39,31 @@
final class DoctrineTimestampableExtension extends DI\CompilerExtension
{
/**
* @var array
* {@inheritdoc}
*/
private $defaults = [
'lazyAssociation' => FALSE,
'autoMapField' => TRUE,
'dbFieldType' => 'datetime',
];
public function getConfigSchema() : Schema\Schema
{
return Schema\Expect::structure([
'lazyAssociation' => Schema\Expect::bool(FALSE),
'autoMapField' => Schema\Expect::bool(TRUE),
'dbFieldType' => Schema\Expect::string('datetime'),
]);
}

/**
* @return void
*
* @throws Utils\AssertionException
* {@inheritdoc}
*/
public function loadConfiguration() : void
{
// Get container builder
$builder = $this->getContainerBuilder();
/** @var array $configuration */
if (method_exists($this, 'validateConfig')) {
$configuration = $this->validateConfig($this->defaults);
} else {
$configuration = $this->getConfig($this->defaults);
}

Utils\Validators::assert($configuration['lazyAssociation'], 'bool', 'lazyAssociation');
Utils\Validators::assert($configuration['autoMapField'], 'bool', 'autoMapField');
Utils\Validators::assert($configuration['dbFieldType'], 'string', 'dbFieldType');
$configuration = $this->getConfig();

$builder->addDefinition($this->prefix('configuration'))
->setType(DoctrineTimestampable\Configuration::class)
->setArguments([
$configuration['lazyAssociation'],
$configuration['autoMapField'],
$configuration['dbFieldType'],
$configuration->lazyAssociation,
$configuration->autoMapField,
$configuration->dbFieldType,
]);

$builder->addDefinition($this->prefix('driver'))
Expand Down Expand Up @@ -104,15 +95,23 @@ public function afterCompile(Code\ClassType $class) : void

/** @var Code\Method $initialize */
$initialize = $class->methods['initialize'];
$initialize->addBody('Doctrine\DBAL\Types\Type::addType(\'' . Types\UTCDateTime::UTC_DATETIME . '\', \'' . Types\UTCDateTime::class . '\');');
$initialize->addBody(
'Doctrine\DBAL\Types\Type::addType(?, ?);',
[
Types\UTCDateTime::UTC_DATETIME,
Types\UTCDateTime::class,
]
);
}

/**
* @param Nette\Configurator $config
* @param string $extensionName
*/
public static function register(Nette\Configurator $config, string $extensionName = 'doctrineTimestampable') : void
{
public static function register(
Nette\Configurator $config,
string $extensionName = 'doctrineTimestampable'
) : void {
$config->onCompile[] = function (Nette\Configurator $config, Nette\DI\Compiler $compiler) use ($extensionName) {
$compiler->addExtension($extensionName, new DoctrineTimestampableExtension);
};
Expand Down
10 changes: 6 additions & 4 deletions src/IPub/DoctrineTimestampable/Entities/IEntityCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace IPub\DoctrineTimestampable\Entities;

use DateTimeInterface;

/**
* Doctrine timestampable creating entity interface
*
Expand All @@ -27,14 +29,14 @@
interface IEntityCreated
{
/**
* @param \DateTimeInterface $createdAt
* @param DateTimeInterface $createdAt
*
* @return void
*/
public function setCreatedAt(\DateTimeInterface $createdAt) : void;
public function setCreatedAt(DateTimeInterface $createdAt) : void;

/**
* @return \DateTimeInterface|NULL
* @return DateTimeInterface|NULL
*/
public function getCreatedAt() : ?\DateTimeInterface;
public function getCreatedAt() : ?DateTimeInterface;
}
10 changes: 6 additions & 4 deletions src/IPub/DoctrineTimestampable/Entities/IEntityRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace IPub\DoctrineTimestampable\Entities;

use DateTimeInterface;

/**
* Doctrine timestampable removing entity interface
*
Expand All @@ -27,14 +29,14 @@
interface IEntityRemoved
{
/**
* @param \DateTimeInterface $deletedAt
* @param DateTimeInterface $deletedAt
*
* @return void
*/
public function setDeletedAt(\DateTimeInterface $deletedAt) : void;
public function setDeletedAt(DateTimeInterface $deletedAt) : void;

/**
* @return \DateTimeInterface|NULL
* @return DateTimeInterface|NULL
*/
public function getDeletedAt() : ?\DateTimeInterface;
public function getDeletedAt() : ?DateTimeInterface;
}
10 changes: 6 additions & 4 deletions src/IPub/DoctrineTimestampable/Entities/IEntityUpdated.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace IPub\DoctrineTimestampable\Entities;

use DateTimeInterface;

/**
* Doctrine timestampable modifying entity interface
*
Expand All @@ -27,14 +29,14 @@
interface IEntityUpdated
{
/**
* @param \DateTimeInterface $updatedAt
* @param DateTimeInterface $updatedAt
*
* @return void
*/
public function setUpdatedAt(\DateTimeInterface $updatedAt) : void;
public function setUpdatedAt(DateTimeInterface $updatedAt) : void;

/**
* @return \DateTimeInterface|NULL
* @return DateTimeInterface|NULL
*/
public function getUpdatedAt() : ?\DateTimeInterface;
public function getUpdatedAt() : ?DateTimeInterface;
}
12 changes: 7 additions & 5 deletions src/IPub/DoctrineTimestampable/Entities/TEntityCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace IPub\DoctrineTimestampable\Entities;

use DateTimeInterface;

use IPub\DoctrineTimestampable\Mapping\Annotation as IPub;

/**
Expand All @@ -29,26 +31,26 @@
trait TEntityCreated
{
/**
* @var \DateTimeInterface|NULL
* @var DateTimeInterface|NULL
*
* @IPub\Timestampable(on="create")
*/
protected $createdAt;

/**
* @param \DateTimeInterface $createdAt
* @param DateTimeInterface $createdAt
*
* @return void
*/
public function setCreatedAt(\DateTimeInterface $createdAt) : void
public function setCreatedAt(DateTimeInterface $createdAt) : void
{
$this->createdAt = $createdAt;
}

/**
* @return \DateTimeInterface|NULL
* @return DateTimeInterface|NULL
*/
public function getCreatedAt() : ?\DateTimeInterface
public function getCreatedAt() : ?DateTimeInterface
{
return $this->createdAt;
}
Expand Down
12 changes: 7 additions & 5 deletions src/IPub/DoctrineTimestampable/Entities/TEntityRemoved.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

namespace IPub\DoctrineTimestampable\Entities;

use DateTimeInterface;

use IPub\DoctrineTimestampable\Mapping\Annotation as IPub;

/**
Expand All @@ -29,26 +31,26 @@
trait TEntityRemoved
{
/**
* @var \DateTimeInterface|NULL
* @var DateTimeInterface|NULL
*
* @IPub\Timestampable(on="delete")
*/
protected $deletedAt;

/**
* @param \DateTimeInterface $deletedAt
* @param DateTimeInterface $deletedAt
*
* @return void
*/
public function setDeletedAt(\DateTimeInterface $deletedAt) : void
public function setDeletedAt(DateTimeInterface $deletedAt) : void
{
$this->deletedAt = $deletedAt;
}

/**
* @return \DateTimeInterface|NULL
* @return DateTimeInterface|NULL
*/
public function getDeletedAt() : ?\DateTimeInterface
public function getDeletedAt() : ?DateTimeInterface
{
return $this->deletedAt;
}
Expand Down
Loading

0 comments on commit 07ed60d

Please sign in to comment.