Skip to content

Commit

Permalink
Remove underscores from methods and properties
Browse files Browse the repository at this point in the history
  • Loading branch information
bencroker committed Mar 20, 2024
1 parent 92f370a commit 7a8cdf5
Show file tree
Hide file tree
Showing 34 changed files with 482 additions and 553 deletions.
76 changes: 38 additions & 38 deletions src/Campaign.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,36 +204,36 @@ public function init(): void
self::$plugin = $this;
$this->name = Craft::t('campaign', 'Plugin Name');

$this->_registerComponents();
$this->_registerInstances();
$this->_registerVariables();
$this->_registerLogTarget();
$this->_registerElementTypes();
$this->_registerFieldTypes();
$this->_registerAfterInstallEvent();
$this->_registerFieldEvents();
$this->_registerProjectConfigListeners();
$this->_registerTemplateHooks();
$this->_registerAllowedOrigins();
$this->_registerTwigExtensions();
$this->_registerFeedMeElements();
$this->registerComponents();
$this->registerInstances();
$this->registerVariables();
$this->registerLogTarget();
$this->registerElementTypes();
$this->registerFieldTypes();
$this->registerAfterInstallEvent();
$this->registerFieldEvents();
$this->registerProjectConfigListeners();
$this->registerTemplateHooks();
$this->registerAllowedOrigins();
$this->registerTwigExtensions();
$this->registerFeedMeElements();

// Register tracker controller shorthand for site requests
if (Craft::$app->getRequest()->getIsSiteRequest()) {
$this->controllerMap = ['t' => TrackerController::class];
}

if (Craft::$app->getRequest()->getIsCpRequest()) {
$this->_registerNativeFields();
$this->_registerAssetBundles();
$this->_registerCpUrlRules();
$this->_registerUtilities();
$this->_registerWidgets();
$this->registerNativeFields();
$this->registerAssetBundles();
$this->registerCpUrlRules();
$this->registerUtilities();
$this->registerWidgets();
}

// If Craft edition is pro
if (Craft::$app->getEdition() === Craft::Pro) {
$this->_registerUserPermissions();
$this->registerUserPermissions();
$this->sync->registerUserEvents();
}
}
Expand Down Expand Up @@ -470,15 +470,15 @@ protected function getCpRoutes(): array
*
* @see Plugins::$pluginConfigs
*/
private function _registerComponents(): void
private function registerComponents(): void
{
$this->set('mailer', fn() => $this->createMailer());
}

/**
* Registers instances configured via `config/app.php`, ensuring they are of the correct type.
*/
private function _registerInstances(): void
private function registerInstances(): void
{
$this->queue = Instance::ensure($this->queue, Queue::class);
}
Expand All @@ -488,7 +488,7 @@ private function _registerInstances(): void
*
* @since 2.0.0
*/
private function _registerVariables(): void
private function registerVariables(): void
{
Event::on(CraftVariable::class, CraftVariable::EVENT_INIT,
function(Event $event) {
Expand All @@ -504,7 +504,7 @@ function(Event $event) {
*
* @see LineFormatter::SIMPLE_FORMAT
*/
private function _registerLogTarget(): void
private function registerLogTarget(): void
{
if (Craft::getLogger()->dispatcher instanceof Dispatcher) {
Craft::getLogger()->dispatcher->targets[] = new MonologTarget([
Expand All @@ -524,7 +524,7 @@ private function _registerLogTarget(): void
/**
* Registers element types.
*/
private function _registerElementTypes(): void
private function registerElementTypes(): void
{
Event::on(Elements::class, Elements::EVENT_REGISTER_ELEMENT_TYPES,
function(RegisterComponentTypesEvent $event) {
Expand All @@ -540,7 +540,7 @@ function(RegisterComponentTypesEvent $event) {
/**
* Registers custom field types.
*/
private function _registerFieldTypes(): void
private function registerFieldTypes(): void
{
Event::on(Fields::class, Fields::EVENT_REGISTER_FIELD_TYPES, function(RegisterComponentTypesEvent $event) {
$event->types[] = CampaignsField::class;
Expand All @@ -552,7 +552,7 @@ private function _registerFieldTypes(): void
/**
* Registers after install event.
*/
private function _registerAfterInstallEvent(): void
private function registerAfterInstallEvent(): void
{
Event::on(Plugins::class, Plugins::EVENT_AFTER_INSTALL_PLUGIN,
function(PluginEvent $event) {
Expand Down Expand Up @@ -581,7 +581,7 @@ function(PluginEvent $event) {
/**
* Registers field events.
*/
private function _registerFieldEvents(): void
private function registerFieldEvents(): void
{
Event::on(Fields::class, Fields::EVENT_AFTER_SAVE_FIELD,
function(FieldEvent $event) {
Expand All @@ -601,7 +601,7 @@ function(FieldEvent $event) {
/**
* Registers event listeners for project config changes.
*/
private function _registerProjectConfigListeners(): void
private function registerProjectConfigListeners(): void
{
// Contact field layout
Craft::$app->getProjectConfig()
Expand Down Expand Up @@ -634,7 +634,7 @@ private function _registerProjectConfigListeners(): void
*
* @since 1.15.1
*/
private function _registerTemplateHooks(): void
private function registerTemplateHooks(): void
{
Craft::$app->getView()->hook('cp.users.edit.details', function($context) {
/** @var User|null $user */
Expand Down Expand Up @@ -663,7 +663,7 @@ private function _registerTemplateHooks(): void
*
* @since 1.21.0
*/
private function _registerAllowedOrigins(): void
private function registerAllowedOrigins(): void
{
Event::on(PreviewController::class, Controller::EVENT_BEFORE_ACTION,
function(ActionEvent $event) {
Expand Down Expand Up @@ -702,7 +702,7 @@ function(ActionEvent $event) {
*
* @since 2.0.0
*/
private function _registerTwigExtensions(): void
private function registerTwigExtensions(): void
{
Craft::$app->getView()->registerTwigExtension(new CampaignTwigExtension());
}
Expand All @@ -712,7 +712,7 @@ private function _registerTwigExtensions(): void
*
* @since 2.8.0
*/
private function _registerFeedMeElements(): void
private function registerFeedMeElements(): void
{
// Only check that the class exists, disregarding application initialisation.
// https://github.com/putyourlightson/craft-campaign/issues/428
Expand All @@ -732,7 +732,7 @@ function(RegisterFeedMeElementsEvent $event) {
*
* @since 2.0.0
*/
private function _registerNativeFields(): void
private function registerNativeFields(): void
{
Event::on(FieldLayout::class, FieldLayout::EVENT_DEFINE_NATIVE_FIELDS,
function(DefineFieldLayoutFieldsEvent $event) {
Expand All @@ -759,7 +759,7 @@ function(DefineFieldLayoutFieldsEvent $event) {
*
* @since 2.0.0
*/
private function _registerAssetBundles(): void
private function registerAssetBundles(): void
{
Craft::$app->getView()->registerAssetBundle(CpAsset::class);

Expand All @@ -773,7 +773,7 @@ private function _registerAssetBundles(): void
*
* @since 2.0.0
*/
private function _registerCpUrlRules(): void
private function registerCpUrlRules(): void
{
Event::on(UrlManager::class, UrlManager::EVENT_REGISTER_CP_URL_RULES,
function(RegisterUrlRulesEvent $event) {
Expand All @@ -787,7 +787,7 @@ function(RegisterUrlRulesEvent $event) {
*
* @since 2.0.0
*/
private function _registerUtilities(): void
private function registerUtilities(): void
{
Event::on(Utilities::class, Utilities::EVENT_REGISTER_UTILITY_TYPES,
function(RegisterComponentTypesEvent $event) {
Expand All @@ -801,7 +801,7 @@ function(RegisterComponentTypesEvent $event) {
*
* @since 2.4.0
*/
private function _registerWidgets(): void
private function registerWidgets(): void
{
Event::on(Dashboard::class, Dashboard::EVENT_REGISTER_WIDGET_TYPES,
function(RegisterComponentTypesEvent $event) {
Expand All @@ -816,7 +816,7 @@ function(RegisterComponentTypesEvent $event) {
*
* @since 2.0.0
*/
private function _registerUserPermissions(): void
private function registerUserPermissions(): void
{
Event::on(UserPermissions::class, UserPermissions::EVENT_REGISTER_PERMISSIONS,
function(RegisterUserPermissionsEvent $event) {
Expand Down
24 changes: 12 additions & 12 deletions src/assets/CpAsset.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ public function registerAssetFiles($view): void
parent::registerAssetFiles($view);

if ($view instanceof View) {
$this->_registerTranslations($view);
$this->registerTranslations($view);
}

$this->_registerEditableTypes($view);
$this->registerEditableTypes($view);
}

private function _registerTranslations(View $view): void
private function registerTranslations(View $view): void
{
$view->registerTranslations('app', [
'(blank)',
Expand All @@ -72,17 +72,17 @@ private function _registerTranslations(View $view): void
]);
}

private function _registerEditableTypes(BaseView $view): void
private function registerEditableTypes(BaseView $view): void
{
$user = Craft::$app->getUser()->getIdentity();
if ($user === null) {
return;
}

$editableCampaignTypes = Json::encode($this->_getEditableCampaignTypes());
$editableMailingListTypes = Json::encode($this->_getEditableMailingListTypes());
$editableSegmentTypes = Json::encode($this->_getEditableSegmentTypes());
$editableSendoutTypes = Json::encode($this->_getEditableSendoutTypes());
$editableCampaignTypes = Json::encode($this->getEditableCampaignTypes());
$editableMailingListTypes = Json::encode($this->getEditableMailingListTypes());
$editableSegmentTypes = Json::encode($this->getEditableSegmentTypes());
$editableSendoutTypes = Json::encode($this->getEditableSendoutTypes());

$js = <<<JS
window.Craft.editableCampaignTypes = $editableCampaignTypes;
Expand All @@ -94,7 +94,7 @@ private function _registerEditableTypes(BaseView $view): void
$view->registerJs($js, BaseView::POS_HEAD);
}

private function _getEditableCampaignTypes(): array
private function getEditableCampaignTypes(): array
{
$campaignTypes = [];

Expand All @@ -111,7 +111,7 @@ private function _getEditableCampaignTypes(): array
return $campaignTypes;
}

private function _getEditableMailingListTypes(): array
private function getEditableMailingListTypes(): array
{
$mailingListTypes = [];

Expand All @@ -128,7 +128,7 @@ private function _getEditableMailingListTypes(): array
return $mailingListTypes;
}

private function _getEditableSegmentTypes(): array
private function getEditableSegmentTypes(): array
{
$segmentTypes = [];

Expand All @@ -142,7 +142,7 @@ private function _getEditableSegmentTypes(): array
return $segmentTypes;
}

private function _getEditableSendoutTypes(): array
private function getEditableSendoutTypes(): array
{
$sendoutTypes = [];

Expand Down
10 changes: 3 additions & 7 deletions src/base/ScheduleModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
use putyourlightson\campaign\elements\conditions\sendouts\SendoutScheduleCondition;
use putyourlightson\campaign\elements\SendoutElement;

/**
* @property ElementConditionInterface|array|string|null $condition
* @property-read array $intervalOptions
*/
abstract class ScheduleModel extends Model implements ScheduleInterface
{
/**
Expand Down Expand Up @@ -45,7 +41,7 @@ abstract class ScheduleModel extends Model implements ScheduleInterface
* @see getCondition()
* @see setCondition()
*/
private ?ElementConditionInterface $_condition = null;
private ?ElementConditionInterface $condition = null;

/**
* @inheritdoc
Expand All @@ -71,7 +67,7 @@ public function getIntervalOptions(): array
*/
public function getCondition(): ElementConditionInterface
{
$condition = $this->_condition ?? Craft::createObject(SendoutScheduleCondition::class, [SendoutElement::class]);
$condition = $this->condition ?? Craft::createObject(SendoutScheduleCondition::class, [SendoutElement::class]);
$condition->mainTag = 'div';
$condition->name = 'condition';

Expand All @@ -94,7 +90,7 @@ public function setCondition(ElementConditionInterface|array|string|null $condit
$condition->forProjectConfig = false;

/** @var SendoutScheduleCondition $condition */
$this->_condition = $condition;
$this->condition = $condition;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/console/controllers/SendoutsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class SendoutsController extends Controller
*/
public function actionQueue(): int
{
$this->_queuePendingSendouts();
$this->queuePendingSendouts();

return ExitCode::OK;
}
Expand All @@ -34,7 +34,7 @@ public function actionQueue(): int
*/
public function actionRun(): int
{
$this->_queuePendingSendouts();
$this->queuePendingSendouts();

/** @var Queue $queue */
$queue = Craft::$app->getQueue();
Expand All @@ -43,7 +43,7 @@ public function actionRun(): int
return ExitCode::OK;
}

private function _queuePendingSendouts(): void
private function queuePendingSendouts(): void
{
$count = Campaign::$plugin->sendouts->queuePendingSendouts();

Expand Down
Loading

0 comments on commit 7a8cdf5

Please sign in to comment.