C:\xampp\htdocs\landing\wp-content\plugins\totalpoll\src\Poll\Controller.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<?php

namespace TotalPoll\Poll;
defined'ABSPATH' ) && exit();



use 
TotalPoll\Contracts\Poll\Repository;
use 
TotalPollVendors\TotalCore\Contracts\Http\Request;

/**
 * Poll Controller.
 * @package TotalPoll\Poll
 */
class Controller {
    
/**
     * @var Request $request
     */
    
protected $request;
    
/**
     * @var Repository $repository
     */
    
protected $repository;
    
/**
     * @var null|\TotalPoll\Contracts\Poll\Model $poll
     */
    
protected $poll;

    
/**
     * Controller constructor.
     *
     * @param Request    $request
     * @param Repository $repository
     */
    
public function __constructRequest $requestRepository $repository ) {
        
$this->request    $request;
        
$this->repository $repository;

        
$pollId     = (int) $this->request->request'totalpoll.pollId' );
        
$this->poll $repository->getById$pollId );

        if ( 
$this->poll ):
            
add_action'totalpoll/actions/request/welcome', [ $this'welcome' ] );
            
add_action'totalpoll/actions/request/vote', [ $this'vote' ] );
            
add_action'totalpoll/actions/request/thankyou', [ $this'thankyou' ] );
            
add_action'totalpoll/actions/request/results', [ $this'results' ] );
            
add_action'totalpoll/actions/ajax-request', function () {
                echo 
$this->poll->render();
                
wp_die();
            } );
        endif;

    }

    
/**
     * Welcome.
     */
    
public function welcome() {
        
$this->poll->setScreen'vote' );
    }

    
/**
     * Vote.
     */
    
public function vote() {
        
$this->poll->setScreen'vote' );

        if ( 
$this->poll->getForm()->validate() ):
            
$countVote false;

            if ( 
$this->poll->isAcceptingVotes() ):
                
$countVote TotalPoll'polls.commands.vote.count', [ $this->poll ] )->execute();
                if ( 
is_wp_error$countVote ) ):
                    
$this->poll->setError$countVote );
                endif;
            endif;

            
TotalPoll'polls.commands.vote.log', [ $this->poll ] )->execute();

            if ( 
$countVote && ! is_wp_error$countVote ) ):
                
$this->poll->getRestrictions()->apply();
                
$this->poll->setScreen'thankyou' );

                
TotalPoll'polls.commands.vote.entry', [ $this->poll ] )->execute();
                
TotalPoll'polls.commands.vote.notify', [ $this->poll ] )->execute();
            endif;
        endif;
    }

    
/**
     * Thank you.
     */
    
public function thankyou() {
        
$this->poll->setScreen'results' );
    }

    
/**
     * Results.
     */
    
public function results() {
        
$this->poll->setScreen'results' );
    }

}
x

Windows NT KPTV 6.2 build 9200 (Windows Server 2012 Datacenter Edition) i586