class CourseObjectPoll in Course 8.3
Same name and namespace in other branches
- 8.2 modules/course_poll/src/Course/Object/CourseObjectPoll.php \Drupal\course_poll\Course\Object\CourseObjectPoll
Parent class for poll tracking.
Plugin annotation
@ContentEntityBundleClass(
label = "Specialized paragraph",
entity_type = "paragraph",
bundle = "specialized_bundle"
)
Hierarchy
- class \Drupal\course_poll\Course\Object\CourseObjectPoll extends \Drupal\course\Object\CourseObjectNode
Expanded class hierarchy of CourseObjectPoll
File
- modules/
course_poll/ src/ Course/ Object/ CourseObjectPoll.php, line 16
Namespace
Drupal\course_poll\Course\ObjectView source
class CourseObjectPoll extends CourseObjectNode {
function getTakeType() {
return 'redirect';
}
public function optionsDefinition() {
$options = parent::optionsDefinition();
$options['use_node_title'] = 1;
return $options;
}
/**
* @todo broken D8
*/
public function Xcreate($node = NULL) {
$poll = new stdClass();
$poll->choice = array(
array(
'chtext' => 'Yes',
'chvotes' => 0,
'weight' => 0,
),
array(
'chtext' => 'No',
'chvotes' => 0,
'weight' => 0,
),
);
$poll->type = 'poll';
$poll->active = 1;
$poll->runtime = 0;
parent::create($poll);
}
public function getReports() {
$reports = parent::getReports();
$reports += array(
'results' => array(
'title' => 'Results',
),
'all' => array(
'title' => 'List votes',
),
);
return $reports;
}
public function getReport($key) {
module_load_include('inc', 'poll', 'poll.pages');
switch ($key) {
case 'results':
return array(
'title' => $this
->getNode()->title,
'content' => poll_view_results($this
->getNode(), NULL, NULL, NULL),
);
case 'all':
$out = poll_votes($this
->getNode());
return array(
'title' => 'All votes',
'content' => drupal_render($out),
);
}
return parent::getReport($key);
}
function getNodeTypes() {
return array(
'poll',
);
}
function getCloneAbility() {
return TRUE;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CourseObjectPoll:: |
function | |||
CourseObjectPoll:: |
function | |||
CourseObjectPoll:: |
public | function | ||
CourseObjectPoll:: |
public | function | ||
CourseObjectPoll:: |
function | |||
CourseObjectPoll:: |
public | function | ||
CourseObjectPoll:: |
public | function | @todo broken D8 |