Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Albert Montolio committed May 8, 2018
2 parents 3af784e + d27e25f commit c03d363
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 21 deletions.
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
language: php
sudo: false
php:
- 5.5
- 5.6
- 7.0
- 7.1

matrix:
fast_finish: true
exclude:
- php: 5.5
- php: 7.0
env: DOCTRINE_COMMON_VERSION="dev-master" DB=mysql DB_USER=root PREFER=latest
- php: 5.5
- php: 7.0
env: DOCTRINE_COMMON_VERSION="dev-master" DB=pgsql PREFER=latest
- php: 5.5
- php: 7.0
env: DOCTRINE_COMMON_VERSION="dev-master" DB=mysql DB_USER=root PREFER=lowest
- php: 5.5
- php: 7.0
env: DOCTRINE_COMMON_VERSION="dev-master" DB=pgsql PREFER=lowest

env:
Expand Down Expand Up @@ -43,7 +42,6 @@ cache:

before_script:
- composer self-update
- composer config -g github-oauth.github.com $GITHUB_COMPOSER_AUTH

- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database orm_behaviors_test' -U postgres; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql orm_behaviors_test -c 'create extension cube' -U postgres; fi"
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@


This PHP `>=5.4` library is a collection of traits and interfaces
that add behaviors to Doctrine2 entites and repositories.
that add behaviors to Doctrine2 entities and repositories.

It currently handles:

Expand All @@ -20,13 +20,21 @@ It currently handles:
* [translatable](#translatable)
* [tree](#tree)

## This project is looking for maintainers

We realize we don't have so much time anymore to maintain this project as it should be maintained.
Therefore we are looking for maintainers. Open an issue if you want to keep working on this.

## Notice:

Some behaviors (translatable, timestampable, softDeletable, blameable, geocodable) need Doctrine subscribers in order to work.
Make sure to activate them by reading the [Subscribers](#subscribers) section.

##Installation
```composer require knplabs/doctrine-behaviors:~1.1```
## Installation

```
composer require knplabs/doctrine-behaviors:~1.1
```

## Configuration
By default, when integrated with Symfony, all subscribers are enabled (if you don't specify any configuration for the bundle).
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
}
],
"require": {
"php": ">=5.4",
"php": "~7.0",
"doctrine/common": ">=2.2",
"behat/transliterator": "~1.0"
},
"require-dev": {
"ext-pdo_sqlite": "*",
"ext-pdo_mysql": "*",
"ext-pdo_pgsql": "*",
"doctrine/orm": ">=2.2",
"doctrine/orm": ">=2.4.5",
"phpunit/phpunit": "~4.8",
"jakub-onderka/php-parallel-lint": "~0.8",
"hexmedia/yaml-linter": "~0.1"
Expand All @@ -47,7 +47,7 @@
},
"extra": {
"branch-alias": {
"dev-master": "1.4.x-dev"
"dev-master": "1.5.x-dev"
}
}
}
4 changes: 4 additions & 0 deletions src/Bundle/DependencyInjection/DoctrineBehaviorsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public function load(array $configs, ContainerBuilder $container)
$configuration = new Configuration();
$config = $this->processConfiguration($configuration, $configs);

// Don't rename in Configuration for BC reasons
$config['softdeletable'] = $config['soft_deletable'];
unset($config['soft_deletable']);

foreach ($config as $behavior => $enabled) {
if (!$enabled) {
$container->removeDefinition(sprintf('knp.doctrine_behaviors.%s_subscriber', $behavior));
Expand Down
15 changes: 12 additions & 3 deletions src/Model/Sortable/Sortable.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,20 @@

trait Sortable
{
/**
* @var int
*/
protected $sort = 1;

/**
* @var bool
*/
private $reordered = false;

/**
* Get sort.
*
* @return sort.
* @return int
*/
public function getSort()
{
Expand All @@ -21,18 +27,21 @@ public function getSort()
/**
* Set sort.
*
* @param sort the value to set.
* @param int $sort Sort the value to set
*
* @return $this
*/
public function setSort($sort)
{
$this->reordered = $this->sort !== $sort;
$this->sort = $sort;
$this->sort = $sort;

return $this;
}

/**
* @return bool
*/
public function isReordered()
{
return $this->reordered;
Expand Down
12 changes: 9 additions & 3 deletions src/Model/Tree/Node.php
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,28 @@ public function isChildNodeOf(NodeInterface $node)
/**
* {@inheritdoc}
**/
public function setChildNodeOf(NodeInterface $node)
public function setChildNodeOf(NodeInterface $node = null)
{
$id = $this->getNodeId();
if (empty($id)) {
throw new \LogicException('You must provide an id for this node if you want it to be part of a tree.');
}

$path = rtrim($node->getRealMaterializedPath(), static::getMaterializedPathSeparator());
$path = null !== $node
? rtrim($node->getRealMaterializedPath(), static::getMaterializedPathSeparator())
: static::getMaterializedPathSeparator()
;
$this->setMaterializedPath($path);

if (null !== $this->parentNode) {
$this->parentNode->getChildNodes()->removeElement($this);
}

$this->parentNode = $node;
$this->parentNode->addChildNode($this);

if (null !== $node) {
$this->parentNode->addChildNode($this);
}

foreach ($this->getChildNodes() as $child) {
$child->setChildNodeOf($this);
Expand Down
4 changes: 2 additions & 2 deletions src/Model/Tree/NodeInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,11 @@ public function setMaterializedPath($path);
* - Remove the this node from the children of the old parent
* - Modify the materialized path of this node and all its children, recursively
*
* @param NodeInterface $node The node to use as a parent
* @param NodeInterface | null $node The node to use as a parent
*
* @return NodeInterface $this Fluent interface
**/
public function setChildNodeOf(NodeInterface $node);
public function setChildNodeOf(NodeInterface $node = null);

/**
* @param NodeInterface $node the node to append to the children collection
Expand Down

0 comments on commit c03d363

Please sign in to comment.