This repository has been archived by the owner on Sep 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 51
[VERY][WIP] Introduce collaborators #457
Open
akovalyov
wants to merge
4
commits into
master
Choose a base branch
from
feature/introduce-collaborators
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Application\Migrations; | ||
|
||
use Doctrine\DBAL\Migrations\AbstractMigration; | ||
use Doctrine\DBAL\Schema\Schema; | ||
|
||
/** | ||
* Auto-generated Migration: Please modify to your needs! | ||
*/ | ||
class Version20150320230132 extends AbstractMigration | ||
{ | ||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function up(Schema $schema) | ||
{ | ||
// this up() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('CREATE TABLE collaboration (bundle_id INT NOT NULL, developer_id INT NOT NULL, INDEX IDX_DA3AE323F1FAD9D3 (bundle_id), INDEX IDX_DA3AE32364DD9267 (developer_id), PRIMARY KEY(bundle_id, developer_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'); | ||
$this->addSql('ALTER TABLE collaboration ADD CONSTRAINT FK_DA3AE323F1FAD9D3 FOREIGN KEY (bundle_id) REFERENCES bundle (id) ON DELETE CASCADE'); | ||
$this->addSql('ALTER TABLE collaboration ADD CONSTRAINT FK_DA3AE32364DD9267 FOREIGN KEY (developer_id) REFERENCES owner (id) ON DELETE CASCADE'); | ||
} | ||
|
||
/** | ||
* @param Schema $schema | ||
*/ | ||
public function down(Schema $schema) | ||
{ | ||
// this down() migration is auto-generated, please modify it to your needs | ||
$this->abortIf($this->connection->getDatabasePlatform()->getName() != 'mysql', 'Migration can only be executed safely on \'mysql\'.'); | ||
|
||
$this->addSql('DROP TABLE collaboration'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
namespace Knp\Bundle\KnpBundlesBundle\Entity; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Doctrine\Common\Collections\Collection; | ||
use Doctrine\Common\Collections\ArrayCollection; | ||
use Symfony\Component\Security\Core\User\UserInterface; | ||
|
||
|
@@ -57,6 +58,15 @@ class Developer extends Owner implements UserInterface | |
*/ | ||
private $contributionBundles; | ||
|
||
/** | ||
* Bundles this User is collaborating | ||
* | ||
* @ORM\ManyToMany(targetEntity="Bundle", mappedBy="collaborators") | ||
* | ||
* @var Collection | ||
*/ | ||
private $collaboratedBundles; | ||
|
||
/** | ||
* @ORM\OneToMany(targetEntity="Activity", mappedBy="developer", fetch="EXTRA_LAZY", cascade={"persist"}) | ||
* | ||
|
@@ -79,6 +89,7 @@ public function __construct() | |
$this->organizations = new ArrayCollection(); | ||
$this->recommendedBundles = new ArrayCollection(); | ||
$this->contributionBundles = new ArrayCollection(); | ||
$this->collaboratedBundles = new ArrayCollection(); | ||
$this->favoriteBundles = new ArrayCollection(); | ||
|
||
parent::__construct(); | ||
|
@@ -252,6 +263,37 @@ public function getContributionBundles($page = null, $limit = 15) | |
return $paginator->getCurrentPageResults(); | ||
} | ||
|
||
/** | ||
* Add collaborated Bundle | ||
* | ||
* @param Bundle $collaboratedBundle | ||
*/ | ||
public function addCollaboratedBundle(Bundle $collaboratedBundle) | ||
{ | ||
$this->collaboratedBundles[] = $collaboratedBundle; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This implementation is broken: you only update the inverse side of the relation, which means that Doctrine will not persist this change. And does the relation actually need to be bidirectional ? Unidirectional relations are much easier to reason about and to handle. |
||
} | ||
|
||
/** | ||
* Remove collaborated Bundle | ||
* | ||
* @param Bundle $collaboratedBundle | ||
*/ | ||
public function removeCollaboratedBundle(Bundle $collaboratedBundle) | ||
{ | ||
$this->collaboratedBundles->removeElement($collaboratedBundle); | ||
} | ||
|
||
/** | ||
* Get collaborated bundles | ||
|
||
* | ||
* @return \Traversable | ||
*/ | ||
public function getCollaboratedBundles() | ||
{ | ||
return $this->collaboratedBundles; | ||
} | ||
|
||
/** | ||
* @param Activity $activity | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ | |
/** | ||
* @author Leszek Prabucki <leszek.prabucki@knplabs.com> | ||
*/ | ||
class RepoTest extends \PHPUnit_Framework_TestCase | ||
class TravisTest extends \PHPUnit_Framework_TestCase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you should probably submit this separately |
||
{ | ||
/** | ||
* @test | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should be reverted