diff --git a/lib/Config/Migrator.php b/lib/Config/Migrator.php index abe3086f6e..db059da01d 100644 --- a/lib/Config/Migrator.php +++ b/lib/Config/Migrator.php @@ -3,6 +3,7 @@ namespace MailPoet\Config; use MailPoet\Models\Subscriber; use MailPoet\Models\Newsletter; +use MailPoet\Util\Helpers; if(!defined('ABSPATH')) exit; @@ -41,7 +42,8 @@ class Migrator { $_this = $this; $migrate = function($model) use($_this) { - dbDelta($_this->$model()); + $modelMethod = Helpers::underscoreToCamelCase($model); + dbDelta($_this->$modelMethod()); }; array_map($migrate, $this->models); @@ -86,7 +88,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function custom_fields() { + function customFields() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'name varchar(90) NOT NULL,', @@ -100,7 +102,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function sending_queues() { + function sendingQueues() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -140,7 +142,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function subscriber_segment() { + function subscriberSegment() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'subscriber_id mediumint(9) NOT NULL,', @@ -154,7 +156,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function subscriber_custom_field() { + function subscriberCustomField() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'subscriber_id mediumint(9) NOT NULL,', @@ -188,7 +190,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function newsletter_templates() { + function newsletterTemplates() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'name varchar(250) NOT NULL,', @@ -203,7 +205,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function newsletter_option_fields() { + function newsletterOptionFields() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'name varchar(90) NOT NULL,', @@ -216,7 +218,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function newsletter_option() { + function newsletterOption() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -230,7 +232,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function newsletter_segment() { + function newsletterSegment() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -243,7 +245,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function newsletter_links() { + function newsletterLinks() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -257,7 +259,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function newsletter_posts() { + function newsletterPosts() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -284,7 +286,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function statistics_newsletters() { + function statisticsNewsletters() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -296,7 +298,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function statistics_clicks() { + function statisticsClicks() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -311,7 +313,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function statistics_opens() { + function statisticsOpens() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -323,7 +325,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function statistics_unsubscribes() { + function statisticsUnsubscribes() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'newsletter_id mediumint(9) NOT NULL,', @@ -335,7 +337,7 @@ class Migrator { return $this->sqlify(__FUNCTION__, $attributes); } - function statistics_forms() { + function statisticsForms() { $attributes = array( 'id mediumint(9) NOT NULL AUTO_INCREMENT,', 'form_id mediumint(9) NOT NULL,', @@ -348,7 +350,7 @@ class Migrator { } private function sqlify($model, $attributes) { - $table = $this->prefix . $model; + $table = $this->prefix . Helpers::camelCaseToUnderscore($model); $sql = array(); $sql[] = "CREATE TABLE " . $table . " ("; diff --git a/lib/Config/Populator.php b/lib/Config/Populator.php index aac9edbb27..ebfd64c1df 100644 --- a/lib/Config/Populator.php +++ b/lib/Config/Populator.php @@ -9,6 +9,7 @@ use \MailPoet\Models\Segment; use \MailPoet\Segments\WP; use \MailPoet\Models\Setting; use \MailPoet\Settings\Pages; +use \MailPoet\Util\Helpers; if(!defined('ABSPATH')) exit; @@ -29,7 +30,8 @@ class Populator { $_this = $this; $populate = function($model) use($_this, $wpdb) { - $fields = $_this->$model(); + $modelMethod = Helpers::underscoreToCamelCase($model); + $fields = $_this->$modelMethod(); $table = $_this->prefix . $model; array_map(function($field) use ($wpdb, $table) { @@ -126,7 +128,7 @@ class Populator { } } - function newsletter_option_fields() { + private function newsletterOptionFields() { return array( array( 'name' => 'isScheduled', @@ -184,7 +186,7 @@ class Populator { ); } - private function newsletter_templates() { + private function newsletterTemplates() { return array( (new FranksRoastHouseTemplate(Env::$assets_url))->get(), (new BlankTemplate(Env::$assets_url))->get(), @@ -194,7 +196,8 @@ class Populator { } private function populate($model) { - $rows = $this->$model(); + $modelMethod = Helpers::underscoreToCamelCase($model); + $rows = $this->$modelMethod(); $table = $this->prefix . $model; $_this = $this; diff --git a/lib/Config/Renderer.php b/lib/Config/Renderer.php index a1ce2d95fb..1e86771fc3 100644 --- a/lib/Config/Renderer.php +++ b/lib/Config/Renderer.php @@ -30,7 +30,7 @@ class Renderer { } function setupTranslations() { - $this->renderer->addExtension(new Twig\i18n(Env::$plugin_name)); + $this->renderer->addExtension(new Twig\I18n(Env::$plugin_name)); } function setupFunctions() { diff --git a/lib/Twig/i18n.php b/lib/Twig/I18n.php similarity index 98% rename from lib/Twig/i18n.php rename to lib/Twig/I18n.php index 09f8d89e05..8b29f5e2e8 100644 --- a/lib/Twig/i18n.php +++ b/lib/Twig/I18n.php @@ -1,7 +1,7 @@ - + @@ -51,12 +51,8 @@ - - - - - - + + @@ -68,7 +64,7 @@ - +