Created
March 4, 2015 17:40
-
-
Save jschroed91/82be8891204583183b50 to your computer and use it in GitHub Desktop.
canReattach
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
public function canReattach() | |
{ | |
$filterFunction = function ($collaborator) { | |
return in_array($collaborator->getRole()->getName(), array(Role::PROPONENT, coproponent)) && $collaborator->getStatus()->getName() == CollaboratorStatus::ACCEPTED; | |
}); | |
$parentCollaborators = $this->getParentProposal()->getCollaborators()->filter($filterFunction); | |
$childCollaborators = $this->getProposal()->getCollaborators()->filter($filterFunction); | |
if ($parentCollaborators->count() !== $childCollaborators->count()) { | |
return false; | |
} | |
foreach ($parentCollaborators as $collaborator) { | |
$found = false; | |
foreach ($childCollaborators as $childCollab) { | |
if ($childCollab->getUser()->getId() === $collaborator->getUser()->getId()) { | |
if ($collaborator->getRole()->getId() === $childCollab->getRole()->getId()) { | |
$found = true; | |
} | |
} | |
} | |
if (!$found) { | |
return false; | |
} | |
} | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment