Full UI theme for CakePHP
ViewExtension componentHTMLExample:
if ($this->ViewExtension->isHtml()) {
echo 'This is an HTML request';
}
In your Controller action add:
// Set redirect URL to cache
$this->ViewExtension->setRedirectUrl($redirect, $key);
Where:
$redirect - Redirect URL. If empty, use redirect URL. If True, use current URL.$key - Key for cacheLater:
// Redirect by URL
$this->ViewExtension->redirectByUrl($defaultRedirect, $key);
Where:
$defaultRedirect - Default redirect URL. Use if redirect URL is not found in cache.$key - Key for cacheRequire plugin Queue. Use the composer to install:
composer require dereuromark/cakephp-queue:^2.3.0
In your Task load Model ExtendQueuedTask, e.g.:
public $uses = [
'Queue.QueuedTask',
'CakeTheme.ExtendQueuedTask',
];
Use progress of task:
$step = 0;
$maxStep = 5;
$this->ExtendQueuedTask->updateTaskProgress($id, $step, $maxStep);
Where:
$id - ID of job$step - Current step of job$maxStep - Maximum steps of jobAdd a message with the result of the task
$this->ExtendQueuedTask->updateMessage($id, $message);
// or
$this->ExtendQueuedTask->updateTaskErrorMessage($id, $message, $keepExistingMessage);
Where:
$id - ID of job$message - Message for update$keepExistingMessage - If True, keep existing error messageIn your Controller action add:
$this->loadModel('CakeTheme.ExtendQueuedTask');
$taskName = 'SomeTask';
$taskParam = ['param' => 'value'];
$notBefore = null;
$group = 'some_group';
$this->ExtendQueuedTask->createJob($taskName, $taskParam, $notBefore, $group);
$this->ViewExtension->setProgressSseTask($taskName);
Where:
$taskName - Name of task$taskParam - Optional parameters for the task$notBefore - Optional date which must not be preceded$group - Used to group similar QueuedTasksIn your View file add:
echo $this->ViewExtension->requestOnlyLink($title, $url, $options);
// or
echo $this->Html->link($title, $url, ['data-toggle' => 'request-only']);
Where:
$title - The content to be wrapped by <a> tags.$url - Cake-relative URL or array of URL parameters, or external URL (starts with http://)$options - HTML options for link element
See https://book.cakephp.org/2.0/en/core-libraries/helpers/html.html#HtmlHelper::linkExample:
return $this->ViewExtension->setExceptionMessage(new NotFoundException(__('Invalid ID for record of post')));
// or
$this->ViewExtension->setExceptionMessage($message, $defaultRedirect, $key);
Where:
$message - Message to be flashed. If an instance of Exception the exception
message will be used and code will be set in params.$defaultRedirect - Default redirect URL. Use if redirect URL is not found in cache.$key - Key for cache