Skip to content

Commit

Permalink
API Implement namespaces and core API changes throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Sep 21, 2017
1 parent db8e7bf commit 50a5f5f
Show file tree
Hide file tree
Showing 53 changed files with 943 additions and 1,104 deletions.
3 changes: 3 additions & 0 deletions .upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ mappings:
WorkflowService: Symbiote\AdvancedWorkflow\Services\WorkflowService
ExistingWorkflowException: Symbiote\AdvancedWorkflow\Services\ExistingWorkflowException
WorkflowReminderTask: Symbiote\AdvancedWorkflow\Tasks\WorkflowReminderTask
WorkflowTemplate: Symbiote\AdvancedWorkflow\Templates\WorkflowTemplate
GridFieldExportAction: Symbiote\AdvancedWorkflow\Forms\GridField\GridFieldExportAction
GridFieldWorkflowRestrictedEditButton: Symbiote\AdvancedWorkflow\Forms\GridField\GridFieldWorkflowRestrictedEditButton
7 changes: 0 additions & 7 deletions _config.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,3 @@
* @license BSD License (http://silverstripe.org/bsd-license/)
* @package advancedworkflow
*/
define('ADVANCED_WORKFLOW_DIR', basename(dirname(__FILE__)));

if (ADVANCED_WORKFLOW_DIR != 'advancedworkflow') {
throw new Exception(
"The advanced workflow module must be in a directory named 'advancedworkflow', not " . ADVANCED_WORKFLOW_DIR
);
}
21 changes: 10 additions & 11 deletions _config/workflowconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ After:
- 'framework/*'
- 'cms/*'
---
SiteTree:
SilverStripe\CMS\Model\SiteTree:
extensions:
- WorkflowApplicable
CMSPageEditController:
- Symbiote\AdvancedWorkflow\Extensions\WorkflowApplicable
SilverStripe\CMS\Controllers\CMSPageEditController:
extensions:
- AdvancedWorkflowExtension
GridFieldDetailForm_ItemRequest:
- Symbiote\AdvancedWorkflow\Extensions\AdvancedWorkflowExtension
SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest:
extensions:
- AdvancedWorkflowExtension
LeftAndMain:
- Symbiote\AdvancedWorkflow\Extensions\AdvancedWorkflowExtension
SilverStripe\Admin\LeftAndMain:
extra_requirements_css:
- advancedworkflow/css/AdvancedWorkflowAdmin.css

---
Name: workflow_jobs
Only:
moduleexists: queuedjobs
---
Injector:
WorkflowReminderJob:
SilverStripe\Core\Injector\Injector:
Symbiote\AdvancedWorkflow\Jobs\WorkflowReminderJob:
properties:
queuedJobService: %$QueuedJobService
queuedJobService: %$Symbiote\QueuedJobs\Services\QueuedJobService
66 changes: 33 additions & 33 deletions _config/workflows.yml
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
---
Name: defaultworkflows
---
Injector:
SilverStripe\Core\Injector\Injector:
SimpleReviewApprove:
class: WorkflowTemplate
class: Symbiote\AdvancedWorkflow\Templates\WorkflowTemplate
constructor:
- Review and Approve
- Single step review and approve. Make sure to update the Apply for approval and Notify users steps!
- 'Review and Approve'
- 'Single step review and approve. Make sure to update the Apply for approval and Notify users steps!'
- 0.2
properties:
structure:
Apply for approval:
type: AssignUsersToWorkflowAction
transitions:
notify: Notify users
Notify users:
type: NotifyUsersWorkflowAction
'Apply for approval':
type: Symbiote\AdvancedWorkflow\Actions\AssignUsersToWorkflowAction
transitions:
notify: 'Notify users'
'Notify users':
type: Symbiote\AdvancedWorkflow\Actions\NotifyUsersWorkflowAction
transitions:
approval: Approval
Approval:
type: SimpleApprovalWorkflowAction
type: Symbiote\AdvancedWorkflow\Actions\SimpleApprovalWorkflowAction
transitions:
Approve: Publish
Reject: Reject changes
Reject: 'Reject changes'
Publish:
type: PublishItemWorkflowAction
transitions:
assign: Assign Initiator Publish
Assign Initiator Publish:
type: AssignUsersToWorkflowAction
transitions:
notify: Notify Initiator Publish
Notify Initiator Publish:
type: NotifyUsersWorkflowAction
Reject changes:
type: CancelWorkflowAction
transitions:
assign: Assign Initiator Cancel
Assign Initiator Cancel:
type: AssignUsersToWorkflowAction
transitions:
notify: Notify Initiator Cancel
Notify Initiator Cancel:
type: NotifyUsersWorkflowAction
WorkflowService:
type: Symbiote\AdvancedWorkflow\Actions\PublishItemWorkflowAction
transitions:
assign: 'Assign Initiator Publish'
'Assign Initiator Publish':
type: Symbiote\AdvancedWorkflow\Actions\AssignUsersToWorkflowAction
transitions:
notify: 'Notify Initiator Publish'
'Notify Initiator Publish':
type: Symbiote\AdvancedWorkflow\Actions\NotifyUsersWorkflowAction
'Reject changes':
type: Symbiote\AdvancedWorkflow\Actions\CancelWorkflowAction
transitions:
assign: 'Assign Initiator Cancel'
'Assign Initiator Cancel':
type: Symbiote\AdvancedWorkflow\Actions\AssignUsersToWorkflowAction
transitions:
notify: 'Notify Initiator Cancel'
'Notify Initiator Cancel':
type: Symbiote\AdvancedWorkflow\Actions\NotifyUsersWorkflowAction
Symbiote\AdvancedWorkflow\Services\WorkflowService:
properties:
templates:
- %$SimpleReviewApprove
- '%$SimpleReviewApprove'
32 changes: 14 additions & 18 deletions code/actions/AssignUsersToWorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,16 @@

namespace Symbiote\AdvancedWorkflow\Actions;

use SilverStripe\ORM\DB;
use SilverStripe\ORM\ArrayList;
use SilverStripe\Security\Member;






use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
use SilverStripe\Forms\HeaderField;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\CheckboxSetField;
use SilverStripe\Forms\HeaderField;
use SilverStripe\Forms\TreeMultiselectField;
use SilverStripe\ORM\ArrayList;
use SilverStripe\ORM\DB;
use SilverStripe\Security\Group;
use SilverStripe\Security\Member;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;

/**
* A workflow action that allows additional users or groups to be assigned to
Expand All @@ -28,18 +23,19 @@
*/
class AssignUsersToWorkflowAction extends WorkflowAction
{

private static $db = array(
'AssignInitiator' => 'Boolean',
);

private static $many_many = array(
'Users' => 'SilverStripe\\Security\\Member',
'Groups' => 'SilverStripe\\Security\\Group'
'Users' => Member::class,
'Groups' => Group::class,
);

private static $icon = 'advancedworkflow/images/assign.png';

private static $table_name = 'AssignUsersToWorkflowAction';

public function execute(WorkflowInstance $workflow)
{
$workflow->Users()->removeAll();
Expand Down Expand Up @@ -69,7 +65,7 @@ public function getCMSFields()
new HeaderField('AssignUsers', $this->fieldLabel('AssignUsers')),
new CheckboxField('AssignInitiator', $this->fieldLabel('AssignInitiator')),
$users = CheckboxSetField::create('Users', $this->fieldLabel('Users'), $cmsUsers),
new TreeMultiselectField('Groups', $this->fieldLabel('Groups'), 'SilverStripe\\Security\\Group')
new TreeMultiselectField('Groups', $this->fieldLabel('Groups'), Group::class)
));

// limit to the users which actually can access the CMS
Expand All @@ -82,7 +78,7 @@ public function fieldLabels($relations = true)
{
return array_merge(parent::fieldLabels($relations), array(
'AssignUsers' => _t('AssignUsersToWorkflowAction.ASSIGNUSERS', 'Assign Users'),
'Users' => _t('AssignUsersToWorkflowAction.USERS', 'Users'),
'Users' => _t('AssignUsersToWorkflowAction.USERS', 'Users'),
'Groups' => _t('AssignUsersToWorkflowAction.GROUPS', 'Groups'),
'AssignInitiator' => _t('AssignUsersToWorkflowAction.INITIATOR', 'Assign Initiator'),
));
Expand All @@ -100,12 +96,12 @@ public function getAssignedMembers()

// Can't merge instances of DataList so convert to something where we can
$_members = ArrayList::create();
$members->each(function ($item) use (&$_members) {
$members->each(function ($item) use ($_members) {
$_members->push($item);
});

$_groups = ArrayList::create();
$groups->each(function ($item) use (&$_groups) {
$groups->each(function ($item) use ($_groups) {
$_groups->push($item);
});

Expand Down
2 changes: 2 additions & 0 deletions code/actions/CancelWorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
class CancelWorkflowAction extends WorkflowAction
{
private static $icon = 'advancedworkflow/images/cancel.png';

private static $table_name = 'CancelWorkflowAction';
}
40 changes: 16 additions & 24 deletions code/actions/NotifyUsersWorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,21 @@

namespace Symbiote\AdvancedWorkflow\Actions;

use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Member;











use SilverStripe\Control\Email\Email;
use SilverStripe\Forms\HeaderField;
use SilverStripe\Forms\LiteralField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\TextareaField;
use SilverStripe\Forms\TextField;
use SilverStripe\Forms\ToggleCompositeField;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
use SilverStripe\ORM\CMSPreviewable;
use SilverStripe\ORM\DataObject;
use SilverStripe\ORM\FieldType\DBDatetime;
use SilverStripe\Security\Member;
use SilverStripe\Security\Security;
use SilverStripe\View\ArrayData;
use SilverStripe\View\SSViewer;
use SilverStripe\Control\Email\Email;
use SilverStripe\ORM\CMSPreviewable;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;

/**
* A workflow action that notifies users attached to the workflow path that they have a task awaiting them.
Expand All @@ -37,20 +27,22 @@
*/
class NotifyUsersWorkflowAction extends WorkflowAction
{

/**
* @config
* @var bool Should templates be constrained to just known-safe variables.
*/
private static $whitelist_template_variables = false;

private static $db = array(
'EmailSubject' => 'Varchar(100)',
'EmailFrom' => 'Varchar(50)',
'EmailTemplate' => 'Text'
'EmailSubject' => 'Varchar(100)',
'EmailFrom' => 'Varchar(50)',
'EmailTemplate' => 'Text'
);

private static $icon = 'advancedworkflow/images/notify.png';

private static $table_name = 'NotifyUsersWorkflowAction';

public function getCMSFields()
{
$fields = parent::getCMSFields();
Expand Down Expand Up @@ -97,7 +89,7 @@ public function execute(WorkflowInstance $workflow)
return true;
}

$member = Member::currentUser();
$member = Security::getCurrentUser();
$initiator = $workflow->Initiator();

$contextFields = $this->getContextFields($workflow->getTarget());
Expand Down Expand Up @@ -196,7 +188,7 @@ public function getContextFields(DataObject $target)
public function getMemberFields(Member $member = null)
{
if (!$member) {
$member = Member::currentUser();
$member = Security::getCurrentUser();
}
$result = array();

Expand Down
20 changes: 7 additions & 13 deletions code/actions/PublishItemWorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,15 @@

namespace Symbiote\AdvancedWorkflow\Actions;

use SilverStripe\ORM\DataObject;







use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
use Symbiote\AdvancedWorkflow\Jobs\WorkflowPublishTargetJob;
use Symbiote\AdvancedWorkflow\Extensions\WorkflowEmbargoExpiryExtension;
use SilverStripe\Forms\CheckboxField;
use SilverStripe\Forms\FieldGroup;
use SilverStripe\Forms\LabelField;
use SilverStripe\Forms\NumericField;
use SilverStripe\Forms\FieldGroup;
use SilverStripe\ORM\DataObject;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
use Symbiote\AdvancedWorkflow\Extensions\WorkflowEmbargoExpiryExtension;
use Symbiote\AdvancedWorkflow\Jobs\WorkflowPublishTargetJob;

/**
* Publishes an item
Expand All @@ -29,7 +22,6 @@
*/
class PublishItemWorkflowAction extends WorkflowAction
{

private static $db = array(
'PublishDelay' => 'Int',
'AllowEmbargoedEditing' => 'Boolean',
Expand All @@ -41,6 +33,8 @@ class PublishItemWorkflowAction extends WorkflowAction

private static $icon = 'advancedworkflow/images/publish.png';

private static $table_name = 'PublishItemWorkflowAction';

public function execute(WorkflowInstance $workflow)
{
if (!$target = $workflow->getTarget()) {
Expand Down
10 changes: 6 additions & 4 deletions code/actions/SetPropertyWorkflowAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace Symbiote\AdvancedWorkflow\Actions;

use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;
use SilverStripe\Forms\TextField;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowAction;
use Symbiote\AdvancedWorkflow\DataObjects\WorkflowInstance;

/**
*
Expand All @@ -14,10 +14,12 @@
class SetPropertyWorkflowAction extends WorkflowAction
{
private static $db = array(
'Property' => 'Varchar',
'Value' => 'Text',
'Property' => 'Varchar',
'Value' => 'Text',
);


private static $table_name = 'SetPropertyWorkflowAction';

public function execute(WorkflowInstance $workflow)
{
if (!$target = $workflow->getTarget()) {
Expand Down
Loading

0 comments on commit 50a5f5f

Please sign in to comment.