Skip to content

Commit 3b78f64

Browse files
committed
moved tests folder and added some tests
1 parent 3a6dc1d commit 3b78f64

File tree

55 files changed

+349
-13
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+349
-13
lines changed

src/Darryldecode/Backend/BackendServiceProvider.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,6 @@ public function boot(Router $router)
4040
__DIR__.'/Database/Migrations' => database_path('migrations'),
4141
__DIR__.'/Database/Seeders' => database_path('seeds'),
4242
], 'migrations');
43-
44-
$this->publishes([
45-
__DIR__.'/Tests' => base_path('tests'),
46-
], 'tests');
4743
}
4844

4945
/**

src/Darryldecode/Backend/Components/ContentBuilder/Commands/CreateContentCommand.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ public function __construct($title, $body, $slug, $status, $authorId, $contentTy
8080
$this->taxonomies = $taxonomies;
8181
}
8282

83-
/**
84-
* Execute the command.
85-
*
86-
* @param Content $content
87-
* @param Factory $validator
88-
* @param ContentType $contentType
89-
* @param Dispatcher $dispatcher
90-
* @return CommandResult
91-
*/
83+
/**
84+
* Execute the command.
85+
*
86+
* @param Content $content
87+
* @param Factory $validator
88+
* @param ContentType $contentType
89+
* @param Dispatcher $dispatcher
90+
* @return CommandResult
91+
*/
9292
public function handle(Content $content, Factory $validator, ContentType $contentType, Dispatcher $dispatcher)
9393
{
9494
// get content available permissions

src/Darryldecode/Backend/Components/ContentBuilder/Commands/UpdateContentCommand.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Darryldecode\Backend\Base\Commands\Command;
1212
use Darryldecode\Backend\Base\Commands\CommandResult;
1313
use Darryldecode\Backend\Components\ContentBuilder\Models\Content;
14+
use Darryldecode\Backend\Components\ContentBuilder\Models\ContentRevisions;
1415
use Darryldecode\Backend\Components\ContentBuilder\Models\ContentType;
1516
use Illuminate\Contracts\Bus\SelfHandling;
1617
use Illuminate\Contracts\Events\Dispatcher;
@@ -132,6 +133,9 @@ public function handle(Content $content, ContentType $contentType, Dispatcher $d
132133
// fire event updating
133134
$dispatcher->fire($cType->type.'.updating', array($c));
134135

136+
// hold the current content so we can use it later if revisions is enabled
137+
$oldBody = $c->body;
138+
135139
$c->title = $this->title ? $this->title : $c->title;
136140
$c->body = $this->body ? $this->body : $c->body;
137141
$c->slug = $this->slug ? $this->slug : $c->slug;
@@ -178,6 +182,19 @@ public function handle(Content $content, ContentType $contentType, Dispatcher $d
178182
// save
179183
$c->save();
180184

185+
// check if revisions is enabled so we can deal with it
186+
if( $cType->enable_revisions == ContentType::REVISIONS_ENABLED )
187+
{
188+
if( $oldBody != $c->body )
189+
{
190+
$c->revisions()->create(array(
191+
'old_content' => $oldBody,
192+
'new_content' => $c->body,
193+
'author_id' => $this->user->id
194+
));
195+
}
196+
}
197+
181198
// fire event updated
182199
$dispatcher->fire($cType->type.'.updated', array($c));
183200

src/Darryldecode/Backend/Components/ContentBuilder/Models/ContentType.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313

1414
class ContentType extends BaseModel {
1515

16+
const REVISIONS_ENABLED = 1;
17+
const REVISIONS_DISABLED = 0;
18+
1619
static $requiredActionPermission = 'superuser';
1720

1821
protected $table = 'content_types';

0 commit comments

Comments
 (0)