mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fixed: voter and permissions in accompanying course document
This commit is contained in:
parent
3bb8b713d1
commit
ab08dab88a
@ -11,6 +11,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\DocStoreBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\HasScopesInterface;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@ -18,7 +19,7 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
* @ORM\Entity
|
||||
* @ORM\Table("chill_doc.accompanyingcourse_document")
|
||||
*/
|
||||
class AccompanyingCourseDocument extends Document
|
||||
class AccompanyingCourseDocument extends Document implements HasScopesInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity=AccompanyingPeriod::class)
|
||||
@ -31,6 +32,15 @@ class AccompanyingCourseDocument extends Document
|
||||
return $this->course;
|
||||
}
|
||||
|
||||
public function getScopes(): iterable
|
||||
{
|
||||
if (null !== $this->course) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return $this->course->getScopes();
|
||||
}
|
||||
|
||||
public function setCourse(?AccompanyingPeriod $course): self
|
||||
{
|
||||
$this->course = $course;
|
||||
|
@ -16,8 +16,6 @@ use Chill\MainBundle\Doctrine\Model\TrackCreationInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackCreationTrait;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateInterface;
|
||||
use Chill\MainBundle\Doctrine\Model\TrackUpdateTrait;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use DateTimeInterface;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
@ -26,7 +24,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
||||
/**
|
||||
* @ORM\MappedSuperclass
|
||||
*/
|
||||
class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdateInterface
|
||||
class Document implements TrackCreationInterface, TrackUpdateInterface
|
||||
{
|
||||
use TrackCreationTrait;
|
||||
|
||||
@ -70,13 +68,6 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
*/
|
||||
private $object;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
||||
*
|
||||
* @var \Chill\MainBundle\Entity\Scope The document's center
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\DocGeneratorBundle\Entity\DocGeneratorTemplate")
|
||||
*/
|
||||
@ -122,16 +113,6 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
return $this->object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get scope.
|
||||
*
|
||||
* @return \Chill\MainBundle\Entity\Scope
|
||||
*/
|
||||
public function getScope(): ?Scope
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
public function getTemplate(): ?DocGeneratorTemplate
|
||||
{
|
||||
return $this->template;
|
||||
@ -175,13 +156,6 @@ class Document implements HasScopeInterface, TrackCreationInterface, TrackUpdate
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setScope($scope): self
|
||||
{
|
||||
$this->scope = $scope;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setTemplate(?DocGeneratorTemplate $template): self
|
||||
{
|
||||
$this->template = $template;
|
||||
|
@ -13,6 +13,7 @@ namespace Chill\DocStoreBundle\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\HasCenterInterface;
|
||||
use Chill\MainBundle\Entity\HasScopeInterface;
|
||||
use Chill\MainBundle\Entity\Scope;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Doctrine\ORM\Mapping as ORM;
|
||||
|
||||
@ -27,6 +28,13 @@ class PersonDocument extends Document implements HasCenterInterface, HasScopeInt
|
||||
*/
|
||||
private Person $person;
|
||||
|
||||
/**
|
||||
* @ORM\ManyToOne(targetEntity="Chill\MainBundle\Entity\Scope")
|
||||
*
|
||||
* @var \Chill\MainBundle\Entity\Scope The document's center
|
||||
*/
|
||||
private $scope;
|
||||
|
||||
public function getCenter()
|
||||
{
|
||||
return $this->getPerson()->getCenter();
|
||||
@ -37,10 +45,22 @@ class PersonDocument extends Document implements HasCenterInterface, HasScopeInt
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
public function getScope(): ?Scope
|
||||
{
|
||||
return $this->scope;
|
||||
}
|
||||
|
||||
public function setPerson($person): self
|
||||
{
|
||||
$this->person = $person;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setScope($scope): self
|
||||
{
|
||||
$this->scope = $scope;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
@ -88,10 +88,5 @@ class AccompanyingCourseDocumentType extends AbstractType
|
||||
$resolver->setDefaults([
|
||||
'data_class' => Document::class,
|
||||
]);
|
||||
|
||||
// $resolver->setRequired(['role', 'center'])
|
||||
// ->setAllowedTypes('role', [ \Symfony\Component\Security\Core\Role\Role::class ])
|
||||
// ->setAllowedTypes('center', [ \Chill\MainBundle\Entity\Center::class ])
|
||||
// ;
|
||||
}
|
||||
}
|
||||
|
@ -106,6 +106,10 @@ class AccompanyingCourseDocumentVoter extends AbstractChillVoter implements Prov
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (self::CREATE === $attribute && null !== $subject->getCourse()) {
|
||||
return $this->voterHelper->voteOnAttribute($attribute, $subject->getCourse(), $token);
|
||||
}
|
||||
}
|
||||
|
||||
return $this->voterHelper->voteOnAttribute($attribute, $subject, $token);
|
||||
|
Loading…
x
Reference in New Issue
Block a user