PHP Класс BaseEventTypeController

BaseEventTypeController is the base controller for modules managing events within OpenEyes. It implements a standardised design pattern to provide the general CRUD interface for module events. The controller is designed to be stateful. When an action is called, the state of the controller is determined from the POST and GET attributes of the request. Properties on the controller are populated through a series of methods, and the response is rendered based on these values, and returned to the user. The rationale behind this is that each of the methods provide discrete hooks which can be overridden in module controllers to redefine what the controller properties should be set to. The primary property of the controller to be manipulated is the {@link open_elements} which defines the elements of the event to be displayed in whatever action is being performed. An abstract class in all but name, it should be used for all event based modules. Specific methods can be implemented in module level controllers that will be called automatically by this base controller. Specifically setting defaults on elements and setting complex attributes on individual elements can be handled in specific methods, as defined by
  • {@link setElementDefaultOptions}
  • {@link setElementComplexAttributesFromData}
  • {@link saveElementComplexAttributesFromData}
It's worth noting that at the moment there is no class for Events at the module level. As a result, the controller tends to contain certain business logic that should really be part of the event. Such behaviour should be written in a way that it can be easily extracted into a separate class. The intention in the future is that this would be abstracted into (at a minimum) a helper class, or ideally into an actual event class that would contain all business logic for manipulating the event and its elements. Furthermore no $_POST, $_GET or session data should be utilised within the element models. Data should be extracted by controllers and passed to methods on the element models. In the future, models may be instantiated in different context where these globals would not be available.
Наследование: extends BaseModuleController
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$dont_redirect
$editable
$editing
$episode
$event * @var Event
$eventIssueCreate String to set an issue when an event is created
$event_actions
$event_tabs
$extraViewProperties defines additional variables to be available in view templates
$layout
$moduleStateCssClass
$patient * @var Patient
$pdf_print_documents
$pdf_print_html
$pdf_print_suffix
$renderPatientPanel
$site * @var Site
$successUri

Защищенные свойства (Protected)

Свойство Тип Описание
$action_types array Override for custom actions.
$open_elements

Открытые методы

Метод Описание
accessRules ( )
actionCreate ( ) : boolean | string Carries out the base create action.
actionDelete ( $id ) Delete the event given by $id. Performs the soft delete action if it's been confirmed by $_POST.
actionElementForm ( integer $id, integer $patient_id, integer $previous_id = null ) Ajax method for loading an individual element (and its children).
actionEventImage ( )
actionPDFPrint ( $id )
actionPrint ( integer $id ) Print action.
actionRequestDeletion ( $id ) : boolean | void Action to process delete requests for an event.
actionSaveCanvasImages ( $id )
actionUpdate ( $id ) The update action for the given event id.
actionView ( $id ) View the event specified by $id.
actionViewPreviousElements ( integer $element_type_id, integer $patient_id ) Ajax method for viewing previous elements.
behaviors ( )
canCopy ( BaseEventTypeElement $element ) : boolean Can an element can be copied from a previous version.
canViewPrevious ( BaseEventTypeElement $element ) : boolean Can we view the previous version of the element.
checkAdminAccess ( ) : boolean
checkCreateAccess ( ) : boolean
checkDeleteAccess ( ) : boolean
checkEditAccess ( ) : boolean
checkFormAccess ( ) : boolean
checkPrintAccess ( ) : boolean
checkRequestDeleteAccess ( ) : boolean
checkViewAccess ( ) : boolean
displayErrors ( $errors, boolean $bottom = false ) Render the given errors with the standard template.
getActionType ( string $action ) : string Return an ACTION_TYPE_ constant representing the type of an action for authorisation purposes.
getAssetPathForElement ( BaseEventTypeElement $element ) : string Return the asset path for the given element (by interrogating namespace).
getChildElements ( ElementType $parent_type ) : BaseEventTypeElement[] Get the open child elements for the given ElementType.
getChildOptionalElements ( ElementType $parent_type ) : BaseEventTypeElement[] Get the child optional elements for the given element type.
getCurrent_episode ( ) : Episode Wrapper around the episode property on this controller - current_episode is used in patient layouts.
getElementModulePathAlias ( BaseEventTypeElement $element ) : string Return the path alias for the module the element belongs to based on its namespace (assumes elements exist in a namespace below the module namespace).
getElements ( ) : array Get the open elements for the event that are not children.
getEpisode ( ) : Episode Get the current episode for the firm and patient.
getEpisodes ( ) : array Get all the episodes for the current patient.
getOpenElementByClassName ( string $class_name ) : object Get open element by class name.
getOptionalElements ( ) : BaseEventTypeElement[] Get the optional elements for the current module's event type (that are not children).
getTitle ( )
hasPrevious ( ElementType $element_type, integer $exclude_event_id = null ) : boolean Are there one or more previous instances of an element?
init ( )
isHiddenInUI ( BaseEventTypeElement $element ) : boolean Is this element to be hidden in the UI? (Prevents the elements from being displayed on page load.).
isPrintAction ( string $action ) : boolean Override to use $action_types.
isRequired ( BaseEventTypeElement $element ) : boolean Is this a required element?
isRequiredInUI ( BaseEventTypeElement $element ) : boolean Is this element required in the UI? (Prevents the user from being able to remove the element.).
processJsVars ( ) set base js vars for use in the standard scripts for the controller.
renderChildOpenElements ( BaseEventTypeElement $parent_element, string $action, BaseCActiveBaseEventTypeCActiveForm $form = null, array $data = null ) Render the open elements that are children of the given parent element type.
renderChildOptionalElements ( BaseEventTypeElement $parent_element, string $action, BaseCActiveBaseEventTypeCActiveForm $form = null, array $data = null ) Render the optional child elements for the given parent element type.
renderEventMetadata ( string $view = '//patient/event_metadata' ) Renders the metadata of the event with the standard template.
renderOpenElements ( string $action, BaseCActiveBaseEventTypeCActiveForm $form = null, array $data = null ) Render the open elements for the controller state.
renderOptionalElements ( string $action, boolean $form = null, boolean $data = null ) Render the optional elements for the controller state.
renderPartial ( string $view, null $data = null, boolean $return = false, boolean $processOutput = false ) : string Extend the parent method to support inheritance of modules (and rendering the element views from the parent module).
saveEvent ( $data ) : boolean Save the event for this controller - will create or update the event, create and update the elements, delete any elements that are no longer required. Note that $data is provided for the purposes of any extensions to this behaviour that might be required.
setOpenElements ( array $open_elements ) Set the open elements (for unit testing).
setTitle ( $title )

Защищенные методы

Метод Описание
afterCreateElements ( Event $event ) Called after event (and elements) have been created.
afterUpdateElements ( Event $event ) Called after event (and elements) has been updated.
beforeAction ( $action ) : boolean Setup base css/js etc requirements for the eventual action render.
getControllerPrefix ( ) : string Get the prefix name of this controller, used for path calculations for element views.
getElementForElementForm ( ElementType $element_type, integer $previous_id, array() $additional ) : BaseEventTypeElement Initialise an element of $element_type for returning as an individual form. If the $previous_id is provided, then the default values of the element will be overridden with the properties of the previous intance of the element. Similarly, $additional allows specific values to be set on the element.
getElementViewPathAlias ( BaseEventTypeElement $element ) : string calculate the alias dot notated path to an element view.
getElementsForElementType ( ElementType $element_type, $data ) : array Processes provided form data to create 1 or more elements of the provided type.
getEventElements ( ) : BaseEventTypeElement[] Abstraction of getting the elements for the event being controlled to allow more complex overrides (such as workflow) where required.
initAction ( string $action ) Runs initialisation of the controller based on the action. Looks for a method name of.
initActionCreate ( ) Initialise the controller prior to a create action.
initActionDelete ( ) initialise the controller with the event id.
initActionRequestDeletion ( ) Sets the the css state.
initActionUpdate ( ) initialise the controller prior to event update action.
initActionView ( ) Sets the the css state.
initWithEventId ( $id ) Intialise controller property based off the event id.
persistPcrRisk ( )
printHTML ( integer $id, BaseEventTypeElement[] $elements, string $template = 'print' ) Render HTML print layout.
printInit ( integer $id ) Initialise print action.
printLog ( integer $id, boolean $pdf ) Log print action.
redirectToPatientEpisodes ( ) Redirect to the patient episodes when the controller determines the action cannot be carried out.
renderElement ( BaseEventTypeElement $element, string $action, BaseCActiveBaseEventTypeCActiveForm $form, array $data, array $view_data = [], boolean $return = false, boolean $processOutput = false ) Render the individual element based on the action provided. Note that view names for the associated actions are set in the model.
renderOptionalElement ( BaseEventTypeElement $element, string $action, BaseCActiveBaseEventTypeCActiveForm $form, array $data ) Render an optional element.
saveEventComplexAttributesFromData ( $data ) Iterates through the open elements and calls the custom methods for saving complex data attributes to them.
setAndValidateElementsFromData ( array $data ) : array Set the attributes of the given $elements from the given structured array.
setElementComplexAttributesFromData ( BaseEventTypeElement $element, array $data, integer $index = null ) Looks for custom methods to set many to many data defined on elements. This is called prior to validation so should set values without actually touching the database.
setElementDefaultOptions ( BaseEventTypeElement $element, string $action ) set the defaults on the given BaseEventTypeElement.
setElementOptions ( string $action ) Set the default values on each of the open elements.
setOpenElementsFromCurrentEvent ( $action ) based on the current state of the controller, sets the open_elements property, which is the array of relevant open elements for the controller.
setPatient ( $patient_id ) Sets the patient object on the controller.
setValidationScenarioForElement ( $element ) Set the validation scenario for the element if necessary.
updateEventInfo ( ) Generates the info text for controller event from the current elements, sets it on the event and saves it.
verifyActionAccess ( CAction $action )

Приватные методы

Метод Описание
updateUniqueCode ( $event ) Update Unique code for the event associated the specific procedures.

Описание методов

accessRules() публичный Метод

public accessRules ( )

actionCreate() публичный Метод

Carries out the base create action.
public actionCreate ( ) : boolean | string
Результат boolean | string

actionDelete() публичный Метод

Delete the event given by $id. Performs the soft delete action if it's been confirmed by $_POST.
public actionDelete ( $id )
$id

actionElementForm() публичный Метод

Ajax method for loading an individual element (and its children).
public actionElementForm ( integer $id, integer $patient_id, integer $previous_id = null )
$id integer
$patient_id integer
$previous_id integer

actionEventImage() публичный Метод

public actionEventImage ( )

actionPDFPrint() публичный Метод

public actionPDFPrint ( $id )

actionPrint() публичный Метод

Print action.
public actionPrint ( integer $id )
$id integer event id

actionRequestDeletion() публичный Метод

Action to process delete requests for an event.
public actionRequestDeletion ( $id ) : boolean | void
$id
Результат boolean | void

actionSaveCanvasImages() публичный Метод

public actionSaveCanvasImages ( $id )

actionUpdate() публичный Метод

The update action for the given event id.
public actionUpdate ( $id )
$id

actionView() публичный Метод

View the event specified by $id.
public actionView ( $id )
$id

actionViewPreviousElements() публичный Метод

Ajax method for viewing previous elements.
public actionViewPreviousElements ( integer $element_type_id, integer $patient_id )
$element_type_id integer
$patient_id integer

afterCreateElements() защищенный Метод

Called after event (and elements) have been created.
protected afterCreateElements ( Event $event )
$event Event

afterUpdateElements() защищенный Метод

Called after event (and elements) has been updated.
protected afterUpdateElements ( Event $event )
$event Event

beforeAction() защищенный Метод

Setup base css/js etc requirements for the eventual action render.
protected beforeAction ( $action ) : boolean
$action
Результат boolean

behaviors() публичный Метод

public behaviors ( )

canCopy() публичный Метод

Can an element can be copied from a previous version.
public canCopy ( BaseEventTypeElement $element ) : boolean
$element BaseEventTypeElement
Результат boolean

canViewPrevious() публичный Метод

Can we view the previous version of the element.
public canViewPrevious ( BaseEventTypeElement $element ) : boolean
$element BaseEventTypeElement
Результат boolean

checkAdminAccess() публичный Метод

public checkAdminAccess ( ) : boolean
Результат boolean

checkCreateAccess() публичный Метод

public checkCreateAccess ( ) : boolean
Результат boolean

checkDeleteAccess() публичный Метод

public checkDeleteAccess ( ) : boolean
Результат boolean

checkEditAccess() публичный Метод

public checkEditAccess ( ) : boolean
Результат boolean

checkFormAccess() публичный Метод

public checkFormAccess ( ) : boolean
Результат boolean

checkPrintAccess() публичный Метод

public checkPrintAccess ( ) : boolean
Результат boolean

checkRequestDeleteAccess() публичный Метод

public checkRequestDeleteAccess ( ) : boolean
Результат boolean

checkViewAccess() публичный Метод

public checkViewAccess ( ) : boolean
Результат boolean

displayErrors() публичный Метод

Render the given errors with the standard template.
public displayErrors ( $errors, boolean $bottom = false )
$errors
$bottom boolean

getActionType() публичный Метод

Return an ACTION_TYPE_ constant representing the type of an action for authorisation purposes.
public getActionType ( string $action ) : string
$action string
Результат string

getAssetPathForElement() публичный Метод

Return the asset path for the given element (by interrogating namespace).
public getAssetPathForElement ( BaseEventTypeElement $element ) : string
$element BaseEventTypeElement
Результат string

getChildElements() публичный Метод

Get the open child elements for the given ElementType.
public getChildElements ( ElementType $parent_type ) : BaseEventTypeElement[]
$parent_type ElementType
Результат BaseEventTypeElement[] $open_elements

getChildOptionalElements() публичный Метод

Get the child optional elements for the given element type.
public getChildOptionalElements ( ElementType $parent_type ) : BaseEventTypeElement[]
$parent_type ElementType
Результат BaseEventTypeElement[] $optional_elements

getControllerPrefix() защищенный Метод

Get the prefix name of this controller, used for path calculations for element views.
protected getControllerPrefix ( ) : string
Результат string

getCurrent_episode() публичный Метод

Wrapper around the episode property on this controller - current_episode is used in patient layouts.
public getCurrent_episode ( ) : Episode
Результат Episode

getElementForElementForm() защищенный Метод

Abstracted to allow overrides in specific module controllers
protected getElementForElementForm ( ElementType $element_type, integer $previous_id, array() $additional ) : BaseEventTypeElement
$element_type ElementType
$previous_id integer
$additional array()
Результат BaseEventTypeElement

getElementModulePathAlias() публичный Метод

Return the path alias for the module the element belongs to based on its namespace (assumes elements exist in a namespace below the module namespace).
public getElementModulePathAlias ( BaseEventTypeElement $element ) : string
$element BaseEventTypeElement
Результат string

getElementViewPathAlias() защищенный Метод

calculate the alias dot notated path to an element view.
protected getElementViewPathAlias ( BaseEventTypeElement $element ) : string
$element BaseEventTypeElement
Результат string

getElements() публичный Метод

Get the open elements for the event that are not children.
public getElements ( ) : array
Результат array

getElementsForElementType() защищенный Метод

Processes provided form data to create 1 or more elements of the provided type.
protected getElementsForElementType ( ElementType $element_type, $data ) : array
$element_type ElementType
$data
Результат array

getEpisode() публичный Метод

Get the current episode for the firm and patient.
public getEpisode ( ) : Episode
Результат Episode

getEpisodes() публичный Метод

Get all the episodes for the current patient.
public getEpisodes ( ) : array
Результат array

getEventElements() защищенный Метод

This should be overridden if the standard elements for the event are affected by the controller state.
protected getEventElements ( ) : BaseEventTypeElement[]
Результат BaseEventTypeElement[]

getOpenElementByClassName() публичный Метод

Get open element by class name.
public getOpenElementByClassName ( string $class_name ) : object
$class_name string
Результат object

getOptionalElements() публичный Метод

Get the optional elements for the current module's event type (that are not children).
public getOptionalElements ( ) : BaseEventTypeElement[]
Результат BaseEventTypeElement[] $elements

getTitle() публичный Метод

public getTitle ( )

hasPrevious() публичный Метод

Are there one or more previous instances of an element?
public hasPrevious ( ElementType $element_type, integer $exclude_event_id = null ) : boolean
$element_type ElementType
$exclude_event_id integer
Результат boolean

init() публичный Метод

public init ( )

initAction() защищенный Метод

initAction[$action] and calls it.
protected initAction ( string $action )
$action string

initActionCreate() защищенный Метод

Initialise the controller prior to a create action.
protected initActionCreate ( )

initActionDelete() защищенный Метод

initialise the controller with the event id.
protected initActionDelete ( )

initActionRequestDeletion() защищенный Метод

Sets the the css state.

initActionUpdate() защищенный Метод

initialise the controller prior to event update action.
protected initActionUpdate ( )

initActionView() защищенный Метод

Sets the the css state.
protected initActionView ( )

initWithEventId() защищенный Метод

Intialise controller property based off the event id.
protected initWithEventId ( $id )
$id

isHiddenInUI() публичный Метод

Is this element to be hidden in the UI? (Prevents the elements from being displayed on page load.).
public isHiddenInUI ( BaseEventTypeElement $element ) : boolean
$element BaseEventTypeElement
Результат boolean

isPrintAction() публичный Метод

Override to use $action_types.
public isPrintAction ( string $action ) : boolean
$action string
Результат boolean

isRequired() публичный Метод

Is this a required element?
public isRequired ( BaseEventTypeElement $element ) : boolean
$element BaseEventTypeElement
Результат boolean

isRequiredInUI() публичный Метод

Is this element required in the UI? (Prevents the user from being able to remove the element.).
public isRequiredInUI ( BaseEventTypeElement $element ) : boolean
$element BaseEventTypeElement
Результат boolean

persistPcrRisk() защищенный Метод

protected persistPcrRisk ( )

printHTML() защищенный Метод

Render HTML print layout.
protected printHTML ( integer $id, BaseEventTypeElement[] $elements, string $template = 'print' )
$id integer event id
$elements BaseEventTypeElement[]
$template string

printInit() защищенный Метод

Initialise print action.
protected printInit ( integer $id )
$id integer event id

printLog() защищенный Метод

Log print action.
protected printLog ( integer $id, boolean $pdf )
$id integer event id
$pdf boolean

processJsVars() публичный Метод

set base js vars for use in the standard scripts for the controller.
public processJsVars ( )

redirectToPatientEpisodes() защищенный Метод

Redirect to the patient episodes when the controller determines the action cannot be carried out.

renderChildOpenElements() публичный Метод

Render the open elements that are children of the given parent element type.
public renderChildOpenElements ( BaseEventTypeElement $parent_element, string $action, BaseCActiveBaseEventTypeCActiveForm $form = null, array $data = null )
$parent_element BaseEventTypeElement
$action string
$form BaseCActiveBaseEventTypeCActiveForm
$data array

renderChildOptionalElements() публичный Метод

Render the optional child elements for the given parent element type.
public renderChildOptionalElements ( BaseEventTypeElement $parent_element, string $action, BaseCActiveBaseEventTypeCActiveForm $form = null, array $data = null )
$parent_element BaseEventTypeElement
$action string
$form BaseCActiveBaseEventTypeCActiveForm
$data array

renderElement() защищенный Метод

Render the individual element based on the action provided. Note that view names for the associated actions are set in the model.
protected renderElement ( BaseEventTypeElement $element, string $action, BaseCActiveBaseEventTypeCActiveForm $form, array $data, array $view_data = [], boolean $return = false, boolean $processOutput = false )
$element BaseEventTypeElement
$action string
$form BaseCActiveBaseEventTypeCActiveForm
$data array
$view_data array Data to be passed to the view.
$return boolean Whether the rendering result should be returned instead of being displayed to end users.
$processOutput boolean Whether the rendering result should be postprocessed using processOutput.

renderEventMetadata() публичный Метод

Renders the metadata of the event with the standard template.
public renderEventMetadata ( string $view = '//patient/event_metadata' )
$view string

renderOpenElements() публичный Метод

Render the open elements for the controller state.
public renderOpenElements ( string $action, BaseCActiveBaseEventTypeCActiveForm $form = null, array $data = null )
$action string
$form BaseCActiveBaseEventTypeCActiveForm
$data array

renderOptionalElement() защищенный Метод

Render an optional element.
protected renderOptionalElement ( BaseEventTypeElement $element, string $action, BaseCActiveBaseEventTypeCActiveForm $form, array $data )
$element BaseEventTypeElement
$action string
$form BaseCActiveBaseEventTypeCActiveForm
$data array

renderOptionalElements() публичный Метод

Render the optional elements for the controller state.
public renderOptionalElements ( string $action, boolean $form = null, boolean $data = null )
$action string
$form boolean
$data boolean

renderPartial() публичный Метод

Extend the parent method to support inheritance of modules (and rendering the element views from the parent module).
public renderPartial ( string $view, null $data = null, boolean $return = false, boolean $processOutput = false ) : string
$view string
$data null
$return boolean
$processOutput boolean
Результат string

saveEvent() публичный Метод

Save the event for this controller - will create or update the event, create and update the elements, delete any elements that are no longer required. Note that $data is provided for the purposes of any extensions to this behaviour that might be required.
public saveEvent ( $data ) : boolean
$data
Результат boolean

saveEventComplexAttributesFromData() защищенный Метод

Custom method is of the name format saveComplexAttributes_element_class_name
protected saveEventComplexAttributesFromData ( $data )
$data

setAndValidateElementsFromData() защищенный Метод

Returns any validation errors that arise.
protected setAndValidateElementsFromData ( array $data ) : array
$data array
Результат array $errors

setElementComplexAttributesFromData() защищенный Метод

The $data attribute will typically be the $_POST structure, but can be any appropriately structured array The optional $index attribute is the counter for multiple elements of the same type that might exist in source data. The convention for the method name for the element setting is: setComplexAttributes_element_class_name
protected setElementComplexAttributesFromData ( BaseEventTypeElement $element, array $data, integer $index = null )
$element BaseEventTypeElement
$data array
$index integer

setElementDefaultOptions() защищенный Метод

Looks for a methods based on the class name of the element: setElementDefaultOptions_[element class name] This method is passed the element and action, which allows for controller methods to manipulate the default values of the element (if the controller state is required for this)
protected setElementDefaultOptions ( BaseEventTypeElement $element, string $action )
$element BaseEventTypeElement
$action string

setElementOptions() защищенный Метод

Set the default values on each of the open elements.
protected setElementOptions ( string $action )
$action string

setOpenElements() публичный Метод

Set the open elements (for unit testing).
public setOpenElements ( array $open_elements )
$open_elements array

setOpenElementsFromCurrentEvent() защищенный Метод

based on the current state of the controller, sets the open_elements property, which is the array of relevant open elements for the controller.
protected setOpenElementsFromCurrentEvent ( $action )

setPatient() защищенный Метод

Sets the patient object on the controller.
protected setPatient ( $patient_id )
$patient_id

setTitle() публичный Метод

public setTitle ( $title )

setValidationScenarioForElement() защищенный Метод

Set the validation scenario for the element if necessary.
protected setValidationScenarioForElement ( $element )
$element

updateEventInfo() защищенный Метод

Generates the info text for controller event from the current elements, sets it on the event and saves it.
protected updateEventInfo ( )

verifyActionAccess() защищенный Метод

protected verifyActionAccess ( CAction $action )
$action CAction

Описание свойств

$action_types защищенное статическое свойство

Override for custom actions.
protected static array $action_types
Результат array

$dont_redirect публичное свойство

public $dont_redirect

$editable публичное свойство

public $editable

$editing публичное свойство

public $editing

$episode публичное свойство

public $episode

$event публичное свойство

* @var Event
public $event

$eventIssueCreate публичное свойство

String to set an issue when an event is created
public $eventIssueCreate

$event_actions публичное свойство

public $event_actions

$event_tabs публичное свойство

public $event_tabs

$extraViewProperties публичное свойство

defines additional variables to be available in view templates
public $extraViewProperties

$layout публичное свойство

public $layout

$moduleStateCssClass публичное свойство

public $moduleStateCssClass

$open_elements защищенное свойство

protected $open_elements

$patient публичное свойство

* @var Patient
public $patient

$pdf_print_documents публичное свойство

public $pdf_print_documents

$pdf_print_html публичное свойство

public $pdf_print_html

$pdf_print_suffix публичное свойство

public $pdf_print_suffix

$renderPatientPanel публичное свойство

public $renderPatientPanel

$site публичное свойство

* @var Site
public $site

$successUri публичное свойство

public $successUri