These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Unpublishes an item |
||
4 | * |
||
5 | * @author [email protected] |
||
6 | * @license BSD License (http://silverstripe.org/bsd-license/) |
||
7 | * @package advancedworkflow |
||
8 | * @subpackage actions |
||
9 | */ |
||
10 | class UnpublishItemWorkflowAction extends WorkflowAction { |
||
0 ignored issues
–
show
|
|||
11 | |||
12 | private static $db = array( |
||
0 ignored issues
–
show
|
|||
13 | 'UnpublishDelay' => 'Int' |
||
14 | ); |
||
15 | |||
16 | public static $icon = 'advancedworkflow/images/unpublish.png'; |
||
17 | |||
18 | public function execute(WorkflowInstance $workflow) { |
||
19 | if (!$target = $workflow->getTarget()) { |
||
20 | return true; |
||
21 | } |
||
22 | |||
23 | if (class_exists('AbstractQueuedJob') && $this->UnpublishDelay) { |
||
24 | $job = new WorkflowPublishTargetJob($target, "unpublish"); |
||
25 | $days = $this->UnpublishDelay; |
||
0 ignored issues
–
show
The property
UnpublishDelay does not exist on object<UnpublishItemWorkflowAction> . Since you implemented __set , maybe consider adding a @property annotation.
Since your code implements the magic setter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
Since the property has write access only, you can use the @property-write annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property.
Loading history...
|
|||
26 | $after = date('Y-m-d H:i:s', strtotime("+$days days")); |
||
27 | singleton('QueuedJobService')->queueJob($job, $after); |
||
28 | } else if ($target->hasExtension('WorkflowEmbargoExpiryExtension')) { |
||
29 | // setting future date stuff if needbe |
||
30 | |||
31 | // set these values regardless |
||
32 | $target->DesiredUnPublishDate = ''; |
||
33 | $target->DesiredPublishDate = ''; |
||
34 | $target->write(); |
||
35 | |||
36 | if ($target->hasMethod('doUnpublish')) { |
||
37 | $target->doUnpublish(); |
||
38 | } |
||
39 | } else { |
||
40 | if ($target->hasMethod('doUnpublish')) { |
||
41 | $target->doUnpublish(); |
||
42 | } |
||
43 | } |
||
44 | |||
45 | return true; |
||
46 | } |
||
47 | |||
48 | View Code Duplication | public function getCMSFields() { |
|
49 | $fields = parent::getCMSFields(); |
||
50 | |||
51 | if (class_exists('AbstractQueuedJob')) { |
||
52 | $before = _t('UnpublishItemWorkflowAction.DELAYUNPUBDAYSBEFORE', 'Delay unpublishing by '); |
||
53 | $after = _t('UnpublishItemWorkflowAction.DELAYUNPUBDAYSAFTER', ' days'); |
||
54 | |||
55 | $fields->addFieldToTab('Root.Main', new FieldGroup( |
||
56 | _t('UnpublishItemWorkflowAction.UNPUBLICATIONDELAY', 'Delay Un-publishing'), |
||
57 | new LabelField('UnpublishDelayBefore', $before), |
||
58 | new NumericField('UnpublishDelay', ''), |
||
59 | new LabelField('UnpublishDelayAfter', $after) |
||
60 | )); |
||
61 | } |
||
62 | |||
63 | return $fields; |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param DataObject $target |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function canPublishTarget(DataObject $target) { |
||
71 | return false; |
||
72 | } |
||
73 | |||
74 | } |
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.