Complex classes like RendererProviderHTML often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use RendererProviderHTML, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 75 | class RendererProviderHTML implements RendererProviderInterface |
||
| 76 | { |
||
| 77 | /** |
||
| 78 | * Trace logger. |
||
| 79 | * |
||
| 80 | * @var \Alpha\Util\Logging\Logger; |
||
| 81 | * |
||
| 82 | * @since 1.2 |
||
| 83 | */ |
||
| 84 | private static $logger = null; |
||
| 85 | |||
| 86 | /** |
||
| 87 | * The business object that we are renderering. |
||
| 88 | * |
||
| 89 | * @var \Alpha\Model\ActiveRecord |
||
| 90 | * |
||
| 91 | * @since 1.2 |
||
| 92 | */ |
||
| 93 | private $record; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * The constructor. |
||
| 97 | * |
||
| 98 | * @since 1.2 |
||
| 99 | */ |
||
| 100 | public function __construct() |
||
| 101 | { |
||
| 102 | self::$logger = new Logger('RendererProviderHTML'); |
||
| 103 | self::$logger->debug('>>__construct()'); |
||
| 104 | |||
| 105 | self::$logger->debug('<<__construct'); |
||
| 106 | } |
||
| 107 | |||
| 108 | /** |
||
| 109 | * {@inheritdoc} |
||
| 110 | */ |
||
| 111 | public function setRecord($record) |
||
| 112 | { |
||
| 113 | $this->record = $record; |
||
| 114 | } |
||
| 115 | |||
| 116 | /** |
||
| 117 | * {@inheritdoc} |
||
| 118 | */ |
||
| 119 | public function createView($fields = array()) |
||
| 120 | { |
||
| 121 | self::$logger->debug('>>createView(fields=['.var_export($fields, true).'])'); |
||
| 122 | |||
| 123 | // the form ID |
||
| 124 | $fields['formID'] = stripslashes(get_class($this->record).'_'.$this->record->getID()); |
||
| 125 | |||
| 126 | // buffer form fields to $formFields |
||
| 127 | $fields['formFields'] = $this->renderAllFields('create'); |
||
| 128 | |||
| 129 | // buffer HTML output for Create and Cancel buttons |
||
| 130 | $button = new Button('submit', 'Create', 'createBut'); |
||
| 131 | $fields['createButton'] = $button->render(); |
||
| 132 | |||
| 133 | if (isset($fields['cancelButtonURL'])) { |
||
| 134 | $button = new Button("document.location.replace('".$fields['cancelButtonURL']."')", 'Cancel', 'cancelBut'); |
||
| 135 | } else { |
||
| 136 | $button = new Button("document.location.replace('".FrontController::generateSecureURL('act=Alpha\\Controller\\ListActiveRecordsController')."')", 'Cancel', 'cancelBut'); |
||
| 137 | } |
||
| 138 | $fields['cancelButton'] = $button->render(); |
||
| 139 | |||
| 140 | // buffer security fields to $formSecurityFields variable |
||
| 141 | $fields['formSecurityFields'] = self::renderSecurityFields(); |
||
| 142 | |||
| 143 | self::$logger->debug('<<createView [HTML]'); |
||
| 144 | |||
| 145 | return View::loadTemplate($this->record, 'create', $fields); |
||
| 146 | } |
||
| 147 | |||
| 148 | /** |
||
| 149 | * {@inheritdoc} |
||
| 150 | */ |
||
| 151 | public function editView($fields = array()) |
||
| 152 | { |
||
| 153 | self::$logger->debug('>>editView(fields=['.var_export($fields, true).'])'); |
||
| 154 | |||
| 155 | $config = ConfigProvider::getInstance(); |
||
| 156 | |||
| 157 | // the form ID |
||
| 158 | $fields['formID'] = stripslashes(get_class($this->record).'_'.$this->record->getID()); |
||
| 159 | |||
| 160 | // buffer form fields to $formFields |
||
| 161 | $fields['formFields'] = $this->renderAllFields('edit'); |
||
| 162 | |||
| 163 | // buffer HTML output for Create and Cancel buttons |
||
| 164 | $button = new Button('submit', 'Save', 'saveBut'); |
||
| 165 | $fields['saveButton'] = $button->render(); |
||
| 166 | |||
| 167 | $formFieldId = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordID')) : 'ActiveRecordID'); |
||
| 168 | |||
| 169 | $js = View::loadTemplateFragment('html', 'bootstrapconfirmokay.phtml', array('prompt' => 'Are you sure you wish to delete this item?', 'formFieldId' => $formFieldId, 'formFieldValue' => $this->record->getID(), 'formId' => 'deleteForm')); |
||
| 170 | |||
| 171 | $button = new Button($js, 'Delete', 'deleteBut'); |
||
| 172 | $fields['deleteButton'] = $button->render(); |
||
| 173 | |||
| 174 | $viewState = ViewState::getInstance(); |
||
| 175 | $start = $viewState->get('selectedStart'); |
||
| 176 | |||
| 177 | if (isset($fields['cancelButtonURL'])) { |
||
| 178 | $button = new Button("document.location = '".$fields['cancelButtonURL']."'", 'Back to List', 'cancelBut'); |
||
| 179 | } else { |
||
| 180 | $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&start='.$start.'&limit='.$config->get('app.list.page.amount'))."'", 'Back to List', 'cancelBut'); |
||
| 181 | } |
||
| 182 | $fields['cancelButton'] = $button->render(); |
||
| 183 | |||
| 184 | // buffer security fields to $formSecurityFields variable |
||
| 185 | $fields['formSecurityFields'] = self::renderSecurityFields(); |
||
| 186 | |||
| 187 | // ID will need to be posted for optimistic lock checking |
||
| 188 | $fields['version_num'] = $this->record->getVersionNumber(); |
||
| 189 | |||
| 190 | self::$logger->debug('<<editView [HTML]'); |
||
| 191 | |||
| 192 | return View::loadTemplate($this->record, 'edit', $fields); |
||
| 193 | } |
||
| 194 | |||
| 195 | /** |
||
| 196 | * {@inheritdoc} |
||
| 197 | */ |
||
| 198 | public function listView($fields = array()) |
||
| 199 | { |
||
| 200 | self::$logger->debug('>>listView(fields=['.var_export($fields, true).'])'); |
||
| 201 | |||
| 202 | $config = ConfigProvider::getInstance(); |
||
| 203 | $sessionProvider = $config->get('session.provider.name'); |
||
| 204 | $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface'); |
||
| 205 | |||
| 206 | // work out how many columns will be in the table |
||
| 207 | $reflection = new ReflectionClass(get_class($this->record)); |
||
| 208 | $properties = array_keys($reflection->getDefaultProperties()); |
||
| 209 | $fields['colCount'] = 1+count(array_diff($properties, $this->record->getDefaultAttributes(), $this->record->getTransientAttributes())); |
||
| 210 | |||
| 211 | // get the class attributes |
||
| 212 | $properties = $reflection->getProperties(); |
||
| 213 | |||
| 214 | $html = ''; |
||
| 215 | |||
| 216 | $html .= '<tr>'; |
||
| 217 | foreach ($properties as $propObj) { |
||
| 218 | $propName = $propObj->name; |
||
| 219 | |||
| 220 | // skip over password fields |
||
| 221 | $property = $this->record->getPropObject($propName); |
||
| 222 | if (!($property instanceof SmallText && $property->checkIsPassword())) { |
||
| 223 | if (!in_array($propName, $this->record->getDefaultAttributes()) && !in_array($propName, $this->record->getTransientAttributes())) { |
||
| 224 | $html .= ' <th>'.$this->record->getDataLabel($propName).'</th>'; |
||
| 225 | } |
||
| 226 | if ($propName == 'ID') { |
||
| 227 | $html .= ' <th>'.$this->record->getDataLabel($propName).'</th>'; |
||
| 228 | } |
||
| 229 | } else { |
||
| 230 | $fields['colCount'] = $fields['colCount']-1; |
||
| 231 | } |
||
| 232 | } |
||
| 233 | $html .= '</tr><tr>'; |
||
| 234 | |||
| 235 | $fields['formHeadings'] = $html; |
||
| 236 | |||
| 237 | $html = ''; |
||
| 238 | |||
| 239 | // and now the values |
||
| 240 | foreach ($properties as $propObj) { |
||
| 241 | $propName = $propObj->name; |
||
| 242 | |||
| 243 | $property = $this->record->getPropObject($propName); |
||
| 244 | if (!($property instanceof SmallText && $property->checkIsPassword())) { |
||
| 245 | if (!in_array($propName, $this->record->getDefaultAttributes()) && !in_array($propName, $this->record->getTransientAttributes())) { |
||
| 246 | if ($property instanceof Text) { |
||
| 247 | $text = htmlentities($this->record->get($propName), ENT_COMPAT, 'utf-8'); |
||
| 248 | if (mb_strlen($text) > 70) { |
||
| 249 | $html .= ' <td> '.mb_substr($text, 0, 70).'...</td>'; |
||
| 250 | } else { |
||
| 251 | $html .= ' <td> '.$text.'</td>'; |
||
| 252 | } |
||
| 253 | } elseif ($property instanceof DEnum) { |
||
| 254 | $html .= ' <td> '.$property->getDisplayValue().'</td>'; |
||
| 255 | } else { |
||
| 256 | $html .= ' <td> '.$property->getValue().'</td>'; |
||
| 257 | } |
||
| 258 | } |
||
| 259 | if ($propName == 'ID') { |
||
| 260 | $html .= ' <td> '.$this->record->getID().'</td>'; |
||
| 261 | } |
||
| 262 | } |
||
| 263 | } |
||
| 264 | $html .= '</tr>'; |
||
| 265 | |||
| 266 | $fields['formFields'] = $html; |
||
| 267 | |||
| 268 | $request = new Request(array('method' => 'GET')); |
||
| 269 | |||
| 270 | // View button |
||
| 271 | if (mb_strpos($request->getURI(), '/tk/') !== false) { |
||
| 272 | if (isset($fields['viewButtonURL'])) { |
||
| 273 | $button = new Button("document.location = '".$fields['viewButtonURL']."';", 'View', 'view'.$this->record->getID().'But'); |
||
| 274 | } else { |
||
| 275 | $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&ActiveRecordID='.$this->record->getID())."';", 'View', 'view'.$this->record->getID().'But'); |
||
| 276 | } |
||
| 277 | $fields['viewButton'] = $button->render(); |
||
| 278 | } else { |
||
| 279 | if ($this->record->hasAttribute('URL')) { |
||
| 280 | $button = new Button("document.location = '".$this->record->get('URL')."';", 'View', 'view'.$this->record->getID().'But'); |
||
| 281 | } else { |
||
| 282 | $button = new Button("document.location = '".$config->get('app.url').'/record/'.urlencode(get_class($this->record)).'/'.$this->record->getID()."';", 'View', 'view'.$this->record->getID().'But'); |
||
| 283 | } |
||
| 284 | |||
| 285 | $fields['viewButton'] = $button->render(); |
||
| 286 | } |
||
| 287 | |||
| 288 | $html = ''; |
||
| 289 | // render edit and delete buttons for admins only |
||
| 290 | if ($session->get('currentUser') && $session->get('currentUser')->inGroup('Admin')) { |
||
| 291 | $html .= ' '; |
||
| 292 | if (isset($fields['editButtonURL'])) { |
||
| 293 | $button = new Button("document.location = '".$fields['editButtonURL']."'", 'Edit', 'edit'.$this->record->getID().'But'); |
||
| 294 | } else { |
||
| 295 | $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&ActiveRecordID='.$this->record->getID().'&view=edit')."'", 'Edit', 'edit'.$this->record->getID().'But'); |
||
| 296 | } |
||
| 297 | |||
| 298 | $html .= $button->render(); |
||
| 299 | $html .= ' '; |
||
| 300 | |||
| 301 | $formFieldId = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordID')) : 'ActiveRecordID'); |
||
| 302 | |||
| 303 | $js = View::loadTemplateFragment('html', 'bootstrapconfirmokay.phtml', array('prompt' => 'Are you sure you wish to delete this item?', 'formFieldId' => $formFieldId, 'formFieldValue' => $this->record->getID(), 'formId' => 'deleteForm')); |
||
| 304 | |||
| 305 | $button = new Button($js, 'Delete', 'delete'.$this->record->getID().'But'); |
||
| 306 | $html .= $button->render(); |
||
| 307 | } |
||
| 308 | $fields['adminButtons'] = $html; |
||
| 309 | |||
| 310 | // buffer security fields to $formSecurityFields variable |
||
| 311 | $fields['formSecurityFields'] = self::renderSecurityFields(); |
||
| 312 | |||
| 313 | self::$logger->debug('<<listView [HTML]'); |
||
| 314 | |||
| 315 | return View::loadTemplate($this->record, 'list', $fields); |
||
| 316 | } |
||
| 317 | |||
| 318 | /** |
||
| 319 | * {@inheritdoc} |
||
| 320 | */ |
||
| 321 | public function detailedView($fields = array()) |
||
| 322 | { |
||
| 323 | self::$logger->debug('>>detailedView(fields=['.var_export($fields, true).'])'); |
||
| 324 | |||
| 325 | $config = ConfigProvider::getInstance(); |
||
| 326 | |||
| 327 | $sessionProvider = $config->get('session.provider.name'); |
||
| 328 | $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface'); |
||
| 329 | |||
| 330 | // we may want to display the ID regardless of class |
||
| 331 | $fields['IDLabel'] = $this->record->getDataLabel('ID'); |
||
| 332 | $fields['ID'] = $this->record->getID(); |
||
| 333 | |||
| 334 | // buffer form fields to $formFields |
||
| 335 | $fields['formFields'] = $this->renderAllFields('view'); |
||
| 336 | |||
| 337 | // Back button |
||
| 338 | $button = new Button('history.back()', 'Back', 'backBut'); |
||
| 339 | $fields['backButton'] = $button->render(); |
||
| 340 | |||
| 341 | $html = ''; |
||
| 342 | // render edit and delete buttons for admins only |
||
| 343 | if ($session->get('currentUser') !== false && $session->get('currentUser')->inGroup('Admin')) { |
||
| 344 | if (isset($fields['editButtonURL'])) { |
||
| 345 | $button = new Button("document.location = '".$fields['editButtonURL']."'", 'Edit', 'editBut'); |
||
| 346 | } else { |
||
| 347 | $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\Controller\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&ActiveRecordID='.$this->record->getID().'&view=edit')."'", 'Edit', 'editBut'); |
||
| 348 | } |
||
| 349 | $html .= $button->render(); |
||
| 350 | |||
| 351 | $formFieldId = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('ActiveRecordID')) : 'ActiveRecordID'); |
||
| 352 | |||
| 353 | $js = View::loadTemplateFragment('html', 'bootstrapconfirmokay.phtml', array('prompt' => 'Are you sure you wish to delete this item?', 'formFieldId' => $formFieldId, 'formFieldValue' => $this->record->getID(), 'formId' => 'deleteForm')); |
||
| 354 | |||
| 355 | $button = new Button($js, 'Delete', 'deleteBut'); |
||
| 356 | $html .= $button->render(); |
||
| 357 | } |
||
| 358 | $fields['adminButtons'] = $html; |
||
| 359 | |||
| 360 | self::$logger->debug('<<detailedView [HTML]'); |
||
| 361 | |||
| 362 | return View::loadTemplate($this->record, 'detail', $fields); |
||
| 363 | } |
||
| 364 | |||
| 365 | /** |
||
| 366 | * {@inheritdoc} |
||
| 367 | */ |
||
| 368 | public function adminView($fields = array()) |
||
| 369 | { |
||
| 370 | self::$logger->debug('>>adminView(fields=['.var_export($fields, true).'])'); |
||
| 371 | |||
| 372 | $config = ConfigProvider::getInstance(); |
||
| 373 | |||
| 374 | // the class name of the record |
||
| 375 | $fields['fullClassName'] = stripslashes(get_class($this->record)); |
||
| 376 | |||
| 377 | // the table name in the DB for the record |
||
| 378 | $fields['tableName'] = $this->record->getTableName(); |
||
| 379 | |||
| 380 | // record count for the Record in the DB |
||
| 381 | $fields['count'] = ($this->record->checkTableExists() ? $this->record->getCount() : '<span class="warning">unavailable</span>'); |
||
| 382 | |||
| 383 | // table exists in the DB? |
||
| 384 | $fields['tableExists'] = ($this->record->checkTableExists() ? '<span class="success">Yes</span>' : '<span class="warning">No</span>'); |
||
| 385 | |||
| 386 | if ($this->record->getMaintainHistory()) { |
||
| 387 | $fields['tableExists'] = ($this->record->checkTableExists(true) ? '<span class="success">Yes</span>' : '<span class="warning">No history table</span>'); |
||
| 388 | } |
||
| 389 | |||
| 390 | // table schema needs to be updated in the DB? |
||
| 391 | $fields['tableNeedsUpdate'] = ($this->record->checkTableNeedsUpdate() ? '<span class="warning">Yes</span>' : '<span class="success">No</span>'); |
||
| 392 | |||
| 393 | // create button |
||
| 394 | if ($this->record->checkTableExists()) { |
||
| 395 | if (isset($fields['createButtonURL'])) { |
||
| 396 | $button = new Button("document.location = '".$fields['createButtonURL']."'", 'Create New', 'create'.stripslashes(get_class($this->record)).'But'); |
||
| 397 | } else { |
||
| 398 | $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType='.get_class($this->record))."'", 'Create New', 'create'.stripslashes(get_class($this->record)).'But'); |
||
| 399 | } |
||
| 400 | $fields['createButton'] = $button->render(); |
||
| 401 | } else { |
||
| 402 | $fields['createButton'] = ''; |
||
| 403 | } |
||
| 404 | |||
| 405 | // list all button |
||
| 406 | if ($this->record->checkTableExists()) { |
||
| 407 | $button = new Button("document.location = '".FrontController::generateSecureURL('act=Alpha\\Controller\\ActiveRecordController&ActiveRecordType='.get_class($this->record).'&start=0&limit='.$config->get('app.list.page.amount'))."'", 'List All', 'list'.stripslashes(get_class($this->record)).'But'); |
||
| 408 | $fields['listButton'] = $button->render(); |
||
| 409 | } else { |
||
| 410 | $fields['listButton'] = ''; |
||
| 411 | } |
||
| 412 | |||
| 413 | // the create table button (if required) |
||
| 414 | $html = ''; |
||
| 415 | |||
| 416 | if (!$this->record->checkTableExists()) { |
||
| 417 | $button = new Button('submit', 'Create Table', 'createTableBut'); |
||
| 418 | $html .= $button->render(); |
||
| 419 | // hidden field so that we know which class to create the table for |
||
| 420 | $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('createTableClass')) : 'createTableClass'); |
||
| 421 | $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->record).'"/>'; |
||
| 422 | } |
||
| 423 | |||
| 424 | if ($html == '' && $this->record->getMaintainHistory() && !$this->record->checkTableExists(true)) { |
||
| 425 | $button = new Button('submit', 'Create History Table', 'createHistoryTableBut'); |
||
| 426 | $html .= $button->render(); |
||
| 427 | // hidden field so that we know which class to create the table for |
||
| 428 | $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('createTableClass')) : 'createTableClass'); |
||
| 429 | $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->record).'"/>'; |
||
| 430 | } |
||
| 431 | $fields['createTableButton'] = $html; |
||
| 432 | |||
| 433 | // recreate and update table buttons (if required) |
||
| 434 | $html = ''; |
||
| 435 | if ($this->record->checkTableNeedsUpdate() && $this->record->checkTableExists()) { |
||
| 436 | $formFieldId = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('admin_'.stripslashes(get_class($this->record)).'_button_pressed')) : 'admin_'.stripslashes(get_class($this->record)).'_button_pressed'); |
||
| 437 | |||
| 438 | $js = View::loadTemplateFragment('html', 'bootstrapconfirmokay.phtml', array('prompt' => 'Are you sure you wish to recreate this class table (all data will be lost)?', 'formFieldId' => $formFieldId, 'formFieldValue' => 'recreateTableBut', 'formId' => 'admin_'.stripslashes(get_class($this->record)))); |
||
| 439 | |||
| 440 | $button = new Button($js, 'Recreate Table', 'recreateTableBut'); |
||
| 441 | $html .= $button->render(); |
||
| 442 | // hidden field so that we know which class to recreate the table for |
||
| 443 | $html .= '<input type="hidden" name="recreateTableClass" value="'.get_class($this->record).'"/>'; |
||
| 444 | $html .= ' '; |
||
| 445 | |||
| 446 | $formFieldId = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('admin_'.stripslashes(get_class($this->record)).'_button_pressed')) : 'admin_'.stripslashes(get_class($this->record)).'_button_pressed'); |
||
| 447 | |||
| 448 | $js = View::loadTemplateFragment('html', 'bootstrapconfirmokay.phtml', array('prompt' => 'Are you sure you wish to attempt to modify this class table by adding new attributes?', 'formFieldId' => $formFieldId, 'formFieldValue' => 'updateTableBut', 'formId' => 'admin_'.stripslashes(get_class($this->record)))); |
||
| 449 | |||
| 450 | $button = new Button($js, 'Update Table', 'updateTableBut'); |
||
| 451 | $html .= $button->render(); |
||
| 452 | // hidden field so that we know which class to update the table for |
||
| 453 | $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('updateTableClass')) : 'updateTableClass'); |
||
| 454 | $html .= '<input type="hidden" name="'.$fieldname.'" value="'.get_class($this->record).'"/>'; |
||
| 455 | |||
| 456 | // hidden field to tell us which button was pressed |
||
| 457 | $fieldname = ($config->get('security.encrypt.http.fieldnames') ? base64_encode(SecurityUtils::encrypt('admin_'.stripslashes(get_class($this->record)).'_button_pressed')) : 'admin_'.stripslashes(get_class($this->record)).'_button_pressed'); |
||
| 458 | $html .= '<input type="hidden" id="'.$fieldname.'" name="'.$fieldname.'" value=""/>'; |
||
| 459 | } |
||
| 460 | $fields['recreateOrUpdateButtons'] = $html; |
||
| 461 | |||
| 462 | // buffer security fields to $formSecurityFields variable |
||
| 463 | $fields['formSecurityFields'] = self::renderSecurityFields(); |
||
| 464 | |||
| 465 | self::$logger->debug('<<adminView [HTML]'); |
||
| 466 | |||
| 467 | return View::loadTemplate($this->record, 'admin', $fields); |
||
| 468 | } |
||
| 469 | |||
| 470 | /** |
||
| 471 | * {@inheritdoc} |
||
| 472 | */ |
||
| 473 | public static function displayPageHead($controller) |
||
| 474 | { |
||
| 475 | if (self::$logger == null) { |
||
| 476 | self::$logger = new Logger('RendererProviderHTML'); |
||
| 477 | } |
||
| 478 | |||
| 479 | self::$logger->debug('>>displayPageHead(controller=['.var_export($controller, true).'])'); |
||
| 480 | |||
| 481 | $config = ConfigProvider::getInstance(); |
||
| 482 | $sessionProvider = $config->get('session.provider.name'); |
||
| 483 | $session = ServiceFactory::getInstance($sessionProvider, 'Alpha\Util\Http\Session\SessionProviderInterface'); |
||
| 484 | |||
| 485 | if (!class_exists(get_class($controller))) { |
||
| 486 | throw new IllegalArguementException('The controller provided ['.get_class($controller).'] is not defined anywhere!'); |
||
| 487 | } |
||
| 488 | |||
| 489 | $allowCSSOverrides = true; |
||
| 490 | |||
| 491 | $request = new Request(array('method' => 'GET')); |
||
| 492 | |||
| 493 | if ($session->get('currentUser') != null && ActiveRecord::isInstalled() && $session->get('currentUser')->inGroup('Admin') && mb_strpos($request->getURI(), '/tk/') !== false) { |
||
| 494 | $allowCSSOverrides = false; |
||
| 495 | } |
||
| 496 | |||
| 497 | $duringCallbackOutput = ''; |
||
| 498 | if (method_exists($controller, 'during_displayPageHead_callback')) { |
||
| 499 | $duringCallbackOutput = $controller->{'during_displayPageHead_callback'}(); |
||
| 500 | } |
||
| 501 | |||
| 502 | $onloadEvent = ''; |
||
| 503 | if ($controller->getRecord() != null && $controller->getRecord()->hasAttribute('bodyOnload')) { |
||
| 504 | $onloadEvent = $controller->getRecord()->get('bodyOnload'); |
||
| 505 | } |
||
| 506 | |||
| 507 | $cmsCallbackOutput = ''; |
||
| 508 | if (method_exists($controller, 'insert_CMSDisplayStandardHeader_callback')) { |
||
| 509 | $cmsCallbackOutput = $controller->{'insert_CMSDisplayStandardHeader_callback'}(); |
||
| 510 | } |
||
| 511 | |||
| 512 | $html = View::loadTemplateFragment('html', 'head.phtml', array('title' => $controller->getTitle(), 'description' => $controller->getDescription(), 'allowCSSOverrides' => $allowCSSOverrides, 'duringCallbackOutput' => $duringCallbackOutput, 'cmsCallbackOutput' => $cmsCallbackOutput, 'onloadEvent' => $onloadEvent)); |
||
| 513 | |||
| 514 | self::$logger->debug('<<displayPageHead [HTML]'); |
||
| 515 | |||
| 516 | return $html; |
||
| 517 | } |
||
| 518 | |||
| 519 | /** |
||
| 520 | * {@inheritdoc} |
||
| 521 | */ |
||
| 522 | public static function displayPageFoot($controller) |
||
| 536 | |||
| 537 | /** |
||
| 538 | * {@inheritdoc} |
||
| 539 | */ |
||
| 540 | public static function displayUpdateMessage($message) |
||
| 553 | |||
| 554 | /** |
||
| 555 | * {@inheritdoc} |
||
| 556 | */ |
||
| 557 | public static function displayErrorMessage($message) |
||
| 570 | |||
| 571 | /** |
||
| 572 | * {@inheritdoc} |
||
| 573 | */ |
||
| 574 | public static function renderErrorPage($code, $message) |
||
| 588 | |||
| 589 | /** |
||
| 590 | * {@inheritdoc} |
||
| 591 | */ |
||
| 592 | public static function renderDeleteForm($URI) |
||
| 613 | |||
| 614 | /** |
||
| 615 | * {@inheritdoc} |
||
| 616 | */ |
||
| 617 | public static function renderSecurityFields() |
||
| 651 | |||
| 652 | /** |
||
| 653 | * {@inheritdoc} |
||
| 654 | */ |
||
| 655 | public function renderIntegerField($name, $label, $mode, $value = '') |
||
| 686 | |||
| 687 | /** |
||
| 688 | * {@inheritdoc} |
||
| 689 | */ |
||
| 690 | public function renderDoubleField($name, $label, $mode, $value = '') |
||
| 721 | |||
| 722 | /** |
||
| 723 | * {@inheritdoc} |
||
| 724 | */ |
||
| 725 | public function renderBooleanField($name, $label, $mode, $value = '') |
||
| 759 | |||
| 760 | /** |
||
| 761 | * {@inheritdoc} |
||
| 762 | */ |
||
| 763 | public function renderEnumField($name, $label, $mode, $options, $value = '') |
||
| 804 | |||
| 805 | /** |
||
| 806 | * {@inheritdoc} |
||
| 807 | */ |
||
| 808 | public function renderDEnumField($name, $label, $mode, $options, $value = '') |
||
| 849 | |||
| 850 | /** |
||
| 851 | * {@inheritdoc} |
||
| 852 | */ |
||
| 853 | public function renderDefaultField($name, $label, $mode, $value = '') |
||
| 885 | |||
| 886 | /** |
||
| 887 | * {@inheritdoc} |
||
| 888 | */ |
||
| 889 | public function renderTextField($name, $label, $mode, $value = '') |
||
| 890 | { |
||
| 891 | self::$logger->debug('>>renderTextField(name=['.$name.'], label=['.$label.'], mode=['.$mode.'], value=['.$value.'])'); |
||
| 892 | |||
| 893 | $html = ''; |
||
| 947 | |||
| 948 | /** |
||
| 949 | * {@inheritdoc} |
||
| 950 | */ |
||
| 951 | public function renderStringField($name, $label, $mode, $value = '') |
||
| 970 | |||
| 971 | /** |
||
| 972 | * {@inheritdoc} |
||
| 973 | */ |
||
| 974 | public function renderRelationField($name, $label, $mode, $value = '', $expanded = false, $buttons = true) |
||
| 1022 | |||
| 1023 | /** |
||
| 1024 | * {@inheritdoc} |
||
| 1025 | */ |
||
| 1026 | public function renderAllFields($mode, $filterFields = array(), $readOnlyFields = array()) |
||
| 1143 | } |
||
| 1144 |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: