Skip to content

Commit

Permalink
Merge pull request #8 from s-nakajima/master
Browse files Browse the repository at this point in the history
共通処理の見直しによる修正
  • Loading branch information
s-nakajima committed Sep 13, 2015
2 parents 087b1c5 + f236fe5 commit ae90199
Show file tree
Hide file tree
Showing 26 changed files with 889 additions and 619 deletions.
57 changes: 5 additions & 52 deletions Config/Migration/1434983278_init.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Init extends CakeMigration {
'room_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false),
'plugin_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'block key | プラグインKEY | plugins.key | ', 'charset' => 'utf8'),
'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Key of the block.', 'charset' => 'utf8'),
'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Name of the block.', 'charset' => 'utf8'),
'name' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Name of the block.', 'charset' => 'utf8'),
'public_type' => array('type' => 'integer', 'null' => false, 'default' => '1', 'length' => 4, 'unsigned' => false, 'comment' => '一般以下のパートが閲覧可能かどうか。
(0:非公開, 1:公開, 2:期間限定公開)
Expand All @@ -63,9 +63,9 @@ class Init extends CakeMigration {
期間限定公開の場合、現在時刻がfrom-toカラムの範囲内の時に公開。'),
'from' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'Datetime display frame from.'),
'to' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'Datetime display frame to.'),
'translation_engine' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'is_auto_translated' => array('type' => 'boolean', 'null' => false, 'default' => null),
'is_first_auto_translation' => array('type' => 'boolean', 'null' => false, 'default' => null),
'translation_engine' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'is_auto_translated' => array('type' => 'boolean', 'null' => true, 'default' => null),
'is_first_auto_translation' => array('type' => 'boolean', 'null' => true, 'default' => null),
'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
Expand All @@ -89,24 +89,7 @@ class Init extends CakeMigration {
*
* @var array $records
*/
public $records = array(
'Block' => array(
array(
'id' => '1',
'language_id' => '2',
'room_id' => '1',
'plugin_key' => 'announcements',
'key' => 'block_1',
),
array(
'id' => '2',
'language_id' => '2',
'room_id' => '1',
'plugin_key' => 'menus',
'key' => 'block_2',
),
),
);
public $records = array();

/**
* Before migration callback
Expand All @@ -125,36 +108,6 @@ public function before($direction) {
* @return bool Should process continue
*/
public function after($direction) {
if ($direction === 'down') {
return true;
}

foreach ($this->records as $model => $records) {
if (!$this->updateRecords($model, $records)) {
return false;
}
}

return true;
}

/**
* Update model records
*
* @param string $model model name to update
* @param string $records records to be stored
* @param string $scope ?
* @return bool Should process continue
*/
public function updateRecords($model, $records, $scope = null) {
$Model = $this->generateModel($model);
foreach ($records as $record) {
$Model->create();
if (!$Model->save($record, false)) {
return false;
}
}

return true;
}
}
2 changes: 2 additions & 0 deletions Config/Migration/9999999999_records.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class Records extends NetCommonsMigration {
'language_id' => '2',
'room_id' => '1',
'plugin_key' => 'announcements',
'name' => 'NetCommons 3! セッティングモードで編集しよう.',
'key' => 'block_1',
),
array(
Expand All @@ -63,6 +64,7 @@ class Records extends NetCommonsMigration {
'language_id' => '1',
'room_id' => '1',
'plugin_key' => 'announcements',
'name' => 'NetCommons 3! Click the setting mode.',
'key' => 'block_1',
),
array(
Expand Down
8 changes: 4 additions & 4 deletions Config/Schema/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function after($event = array()) {
'room_id' => array('type' => 'integer', 'null' => false, 'default' => null, 'unsigned' => false),
'plugin_key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'block key | プラグインKEY | plugins.key | ', 'charset' => 'utf8'),
'key' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Key of the block.', 'charset' => 'utf8'),
'name' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Name of the block.', 'charset' => 'utf8'),
'name' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'comment' => 'Name of the block.', 'charset' => 'utf8'),
'public_type' => array('type' => 'integer', 'null' => false, 'default' => '1', 'length' => 4, 'unsigned' => false, 'comment' => '一般以下のパートが閲覧可能かどうか。
(0:非公開, 1:公開, 2:期間限定公開)
Expand All @@ -88,9 +88,9 @@ public function after($event = array()) {
期間限定公開の場合、現在時刻がfrom-toカラムの範囲内の時に公開。'),
'from' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'Datetime display frame from.'),
'to' => array('type' => 'datetime', 'null' => true, 'default' => null, 'comment' => 'Datetime display frame to.'),
'translation_engine' => array('type' => 'string', 'null' => false, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'is_auto_translated' => array('type' => 'boolean', 'null' => false, 'default' => null),
'is_first_auto_translation' => array('type' => 'boolean', 'null' => false, 'default' => null),
'translation_engine' => array('type' => 'string', 'null' => true, 'default' => null, 'collate' => 'utf8_general_ci', 'charset' => 'utf8'),
'is_auto_translated' => array('type' => 'boolean', 'null' => true, 'default' => null),
'is_first_auto_translation' => array('type' => 'boolean', 'null' => true, 'default' => null),
'created_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
'created' => array('type' => 'datetime', 'null' => true, 'default' => null),
'modified_user' => array('type' => 'integer', 'null' => true, 'default' => null, 'unsigned' => false),
Expand Down
Loading

0 comments on commit ae90199

Please sign in to comment.