--- /dev/null
+<?php
+
+
+namespace Cubist\Backpack\Http\Controllers\Operations;
+
+use Cubist\Backpack\CubistCrudPanel;
+
+trait ReviseOperation
+{
+ use \Backpack\ReviseOperation\ReviseOperation {
+ setupReviseDefaults as protected origSetupDefaults;
+ }
+
+ protected function setupReviseDefaults()
+ {
+ // allow access to the operation
+ $this->crud->allowAccess('revise');
+
+ $this->crud->operation('revise', function () {
+ $this->crud->loadDefaultOperationSettingsFromConfig();
+ });
+
+ $this->crud->operation(['list', 'show'], function () {
+
+ if($this->crud->model->isButtonVisible('revise')) {
+ // add a button in the line stack
+ $this->crud->addButton('line', 'revise', 'view', 'revise-operation::revise_button', 'end');
+ }
+ });
+
+ $crud = $this->crud;
+ }
+
+}
use Backpack\CRUD\app\Http\Controllers\Operations\DeleteOperation;
use Backpack\CRUD\app\Http\Controllers\Operations\UpdateOperation;
use Cubist\Backpack\Http\Controllers\Operations\BulkPublishOperation;
-use Backpack\ReviseOperation\ReviseOperation;
+use Cubist\Backpack\Http\Controllers\Operations\ReviseOperation;
use Backpack\CRUD\app\Library\CrudPanel\CrudPanel;
use Backpack\CRUD\app\Models\Traits\CrudTrait;
use Cubist\Backpack\Magic\BunchOfFields;
protected $connection = null;
protected $primaryKey = 'id';
protected $_operations = [];
- public $timestamps = true;
protected $_enableClone = true;
protected $_enableDeletion = true;
protected $_enableEdition = true;
protected $_enableCreation = true;
protected $_enableRevisions = true;
+ protected $_enableRevisionsButton = false;
protected $_enableBulk = true;
protected static $_ownerAttribute = null;
public function __construct(array $attributes = [])
{
$this->setup();
- $this->fill($attributes);
+ parent::__construct($attributes);
}
public function setup()
}
$this->setFields();
$this->postSetFields();
- $this->bootIfNotBooted();
- $this->initializeTraits();
- $this->syncOriginal();
}
/**
$res = str_replace('_' . $name . '_', $value, $res);
}
- if (!file_exists(dirname($dest))) {
- mkdir(dirname($dest), 0777, true);
+ $dir = dirname($dest);
+ if (!file_exists($dir)) {
+ if (!mkdir($concurrentDirectory = $dir, 0777, true) && !is_dir($concurrentDirectory)) {
+ throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
+ }
}
file_put_contents($dest, $res);
return $this->canUpdate($user);
}
+ public function isButtonVisible($button)
+ {
+ if ($button === 'revise') {
+ return $this->_enableRevisionsButton;
+ }
+ return true;
+ }
+
}