Skip to content

Commit 3a71cbb

Browse files
committed
Merge branch '1.3'
Conflicts: .travis.yml src/PublishWorkflow/Voter/PublishableVoter.php
2 parents 389e3ca + 2c4018d commit 3a71cbb

File tree

5 files changed

+25
-13
lines changed

5 files changed

+25
-13
lines changed

src/PublishWorkflow/Voter/PublishTimePeriodVoter.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,16 @@ public function supportsClass($class)
7070
/**
7171
* {@inheritdoc}
7272
*
73-
* @param PublishTimePeriodReadInterface $object
73+
* @param PublishTimePeriodReadInterface $subject
7474
*/
75-
public function vote(TokenInterface $token, $object, array $attributes)
75+
public function vote(TokenInterface $token, $subject, array $attributes)
7676
{
77-
if (!$this->supportsClass(get_class($object))) {
77+
if (!is_object($subject) || !$this->supportsClass(get_class($subject))) {
7878
return self::ACCESS_ABSTAIN;
7979
}
8080

81-
$startDate = $object->getPublishStartDate();
82-
$endDate = $object->getPublishEndDate();
81+
$startDate = $subject->getPublishStartDate();
82+
$endDate = $subject->getPublishEndDate();
8383

8484
$decision = self::ACCESS_GRANTED;
8585
foreach ($attributes as $attribute) {

src/PublishWorkflow/Voter/PublishableVoter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public function supportsClass($class)
4848
/**
4949
* {@inheritdoc}
5050
*
51-
* @param PublishableReadInterface $object
51+
* @param PublishableReadInterface $subject
5252
*/
53-
public function vote(TokenInterface $token, $object, array $attributes)
53+
public function vote(TokenInterface $token, $subject, array $attributes)
5454
{
55-
if (!$this->supportsClass(get_class($object))) {
55+
if (!is_object($subject) || !$this->supportsClass(get_class($subject))) {
5656
return self::ACCESS_ABSTAIN;
5757
}
5858

@@ -66,7 +66,7 @@ public function vote(TokenInterface $token, $object, array $attributes)
6666
continue;
6767
}
6868

69-
if (!$object->isPublishable()) {
69+
if (!$subject->isPublishable()) {
7070
return self::ACCESS_DENIED;
7171
}
7272
}

src/Security/Authorization/Voter/PublishedVoter.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ public function supportsClass($class)
5757
/**
5858
* {@inheritdoc}
5959
*
60-
* @param object $object
60+
* @param object $subject
6161
*/
62-
public function vote(TokenInterface $token, $object, array $attributes)
62+
public function vote(TokenInterface $token, $subject, array $attributes)
6363
{
64-
if (!$this->supportsClass(get_class($object))) {
64+
if (!is_object($subject) || !$this->supportsClass(get_class($subject))) {
6565
return self::ACCESS_ABSTAIN;
6666
}
6767
foreach ($attributes as $attribute) {
@@ -70,7 +70,7 @@ public function vote(TokenInterface $token, $object, array $attributes)
7070
}
7171
}
7272

73-
if ($this->publishWorkflowChecker->isGranted($attributes, $object)) {
73+
if ($this->publishWorkflowChecker->isGranted($attributes, $subject)) {
7474
return self::ACCESS_GRANTED;
7575
}
7676

tests/Unit/PublishWorkflow/Voter/PublishTimePeriodVoterTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,10 @@ public function testUnsupportedClass()
133133
);
134134
$this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $result);
135135
}
136+
137+
public function testNonClassSubject()
138+
{
139+
$result = $this->voter->vote($this->token, array(1, 2, 3), array(PublishWorkflowChecker::VIEW_ATTRIBUTE));
140+
$this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $result);
141+
}
136142
}

tests/Unit/PublishWorkflow/Voter/PublishableVoterTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,10 @@ public function testUnsupportedClass()
101101
);
102102
$this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $result);
103103
}
104+
105+
public function testNonClassSubject()
106+
{
107+
$result = $this->voter->vote($this->token, array(1, 2, 3), array(PublishWorkflowChecker::VIEW_ATTRIBUTE));
108+
$this->assertEquals(VoterInterface::ACCESS_ABSTAIN, $result);
109+
}
104110
}

0 commit comments

Comments
 (0)