src/Zicht/Bundle/PageBundle/Security/Voter/ScheduledContentVoter.php
public static function decide(ScheduledContentInterface $object, array $attributes = [])
    {
        $now = new \DateTimeImmutable();
        $vote = VoterInterface::ACCESS_ABSTAIN;
        $from = $object->isScheduledFrom();
        $till = $object->isScheduledTill();

        if (!$object->isPublic() || false === self::notEmpty($from, $till))  {
            return $vote;
        }

        switch (true) {
            case is_null($from):
                $vote = $till >= $now ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
                break;
            case is_null($till):
                switch (true) {
                    case ($from <= $now):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    case ($from > $now && self::hasCmsAttribute($attributes)):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    default:
                        $vote = VoterInterface::ACCESS_DENIED;
                }
                break;
            default:
                switch (true) {
                    case ($from <= $now && $till >= $now):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    case (($from > $now && $till >= $now) && self::hasCmsAttribute($attributes)):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    default:
                        $vote = VoterInterface::ACCESS_DENIED;
                }
        }

        return $vote;
    }
public static function decide(ScheduledContentInterface $object, array $attributes = [])
    {
        $now = new \DateTimeImmutable();
        $vote = VoterInterface::ACCESS_ABSTAIN;
        $from = $object->isScheduledFrom();
        $till = $object->isScheduledTill();

        if (!$object->isPublic() || false === self::notEmpty($from, $till))  {
            return $vote;
        }

        switch (true) {
            case is_null($from):
                $vote = $till >= $now ? VoterInterface::ACCESS_GRANTED : VoterInterface::ACCESS_DENIED;
                break;
            case is_null($till):
                switch (true) {
                    case ($from <= $now):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    case ($from > $now && self::hasCmsAttribute($attributes)):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    default:
                        $vote = VoterInterface::ACCESS_DENIED;
                }
                break;
            default:
                switch (true) {
                    case ($from <= $now && $till >= $now):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    case (($from > $now && $till >= $now) && self::hasCmsAttribute($attributes)):
                        $vote = VoterInterface::ACCESS_GRANTED;
                        break;
                    default:
                        $vote = VoterInterface::ACCESS_DENIED;
                }
        }

        return $vote;
    }
Decide based on the current date and time what the vote should be. Static so it's strategy can easily be accessed
by other components as well, without the actual need for the voter instance.

@param ScheduledContentInterface $object
@param array $attributes
@return int