-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
132 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace venveo\bulkedit\base; | ||
|
||
use craft\base\Element; | ||
use craft\base\Field; | ||
use craft\base\FieldInterface; | ||
|
||
abstract class AbstractFieldProcessor implements FieldProcessorInterface | ||
{ | ||
public static function performMerge(Element $element, Field $field, $value): void | ||
{ | ||
|
||
} | ||
|
||
public static function performReplacement(Element $element, Field $field, $value): void | ||
{ | ||
|
||
} | ||
|
||
public static function performSubtraction(Element $element, Field $field, $value): void | ||
{ | ||
|
||
} | ||
|
||
/** | ||
* @param FieldInterface $field | ||
* @return bool | ||
*/ | ||
public static function supportsField(FieldInterface $field): bool | ||
{ | ||
foreach (self::getSupportedFields() as $fieldType) { | ||
if ($field instanceof $fieldType) { | ||
return true; | ||
} | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
namespace venveo\bulkedit\base; | ||
|
||
use craft\base\Element; | ||
use craft\base\Field; | ||
|
||
interface FieldProcessorInterface | ||
{ | ||
/** | ||
* An array of class names for supported fields | ||
* @return array | ||
*/ | ||
public static function getSupportedFields(): array; | ||
|
||
/** | ||
* Returns the supported strategies for this field type | ||
* @return array | ||
*/ | ||
public static function getSupportedStrategies(): array; | ||
|
||
public static function performReplacement(Element $element, Field $field, $value): void; | ||
public static function performSubtraction(Element $element, Field $field, $value): void; | ||
public static function performMerge(Element $element, Field $field, $value): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<?php | ||
|
||
namespace venveo\bulkedit\fields\processors; | ||
|
||
use craft\base\Element; | ||
use craft\base\Field; | ||
use craft\fields\Checkboxes; | ||
use craft\fields\Color; | ||
use craft\fields\Date; | ||
use craft\fields\Dropdown; | ||
use craft\fields\Email; | ||
use craft\fields\Lightswitch; | ||
use craft\fields\MultiSelect; | ||
use craft\fields\Number; | ||
use craft\fields\PlainText; | ||
use craft\fields\RadioButtons; | ||
use craft\fields\Table; | ||
use craft\redactor\Field as RedactorField; | ||
use craft\fields\Url; | ||
use venveo\bulkedit\base\AbstractFieldProcessor; | ||
use venveo\bulkedit\services\BulkEdit; | ||
|
||
class PlainTextProcessor extends AbstractFieldProcessor | ||
{ | ||
|
||
/** | ||
* The fully qualified class name for the element this processor works on | ||
* @return array | ||
*/ | ||
public static function getSupportedFields(): array | ||
{ | ||
$fields = [ | ||
PlainText::class, | ||
Number::class, | ||
Color::class, | ||
Checkboxes::class, | ||
Dropdown::class, | ||
Date::class, | ||
Table::class, | ||
RadioButtons::class, | ||
Lightswitch::class, | ||
Url::class, | ||
Email::class, | ||
MultiSelect::class | ||
]; | ||
|
||
if (\Craft::$app->plugins->isPluginInstalled('redactor')) { | ||
$fields[] = RedactorField::class; | ||
} | ||
|
||
return $fields; | ||
} | ||
|
||
/** | ||
* Returns the supported strategies for this field type | ||
* @return array | ||
*/ | ||
public static function getSupportedStrategies(): array | ||
{ | ||
return [BulkEdit::STRATEGY_REPLACE]; | ||
} | ||
|
||
|
||
public static function performReplacement(Element $element, Field $field, $value): void | ||
{ | ||
|
||
} | ||
} |