| @@ 14-58 (lines=45) @@ | ||
| 11 | * @author PyroCMS, Inc. <[email protected]> |
|
| 12 | * @author Ryan Thompson <[email protected]> |
|
| 13 | */ |
|
| 14 | class ChangeAssignmentColumn |
|
| 15 | { |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The assignment interface. |
|
| 19 | * |
|
| 20 | * @var AssignmentInterface |
|
| 21 | */ |
|
| 22 | protected $assignment; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Create a new ChangeAssignmentColumn instance. |
|
| 26 | * |
|
| 27 | * @param AssignmentInterface $assignment |
|
| 28 | */ |
|
| 29 | public function __construct(AssignmentInterface $assignment) |
|
| 30 | { |
|
| 31 | $this->assignment = $assignment; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Handle the command. |
|
| 36 | * |
|
| 37 | * @param AssignmentSchema $schema |
|
| 38 | * @param AssignmentRepositoryInterface $assignments |
|
| 39 | */ |
|
| 40 | public function handle(AssignmentSchema $schema, AssignmentRepositoryInterface $assignments) |
|
| 41 | { |
|
| 42 | $stream = $this->assignment->getStream(); |
|
| 43 | $type = $this->assignment->getFieldType(true); |
|
| 44 | ||
| 45 | if (!$this->assignment->isTranslatable()) { |
|
| 46 | $table = $stream->getEntryTableName(); |
|
| 47 | } else { |
|
| 48 | $table = $stream->getEntryTranslationsTableName(); |
|
| 49 | } |
|
| 50 | ||
| 51 | /* @var AssignmentInterface $assignment */ |
|
| 52 | $assignment = $assignments->find($this->assignment->getId()); |
|
| 53 | ||
| 54 | $assignment = clone($assignment); |
|
| 55 | ||
| 56 | $schema->renameColumn($table, $type, $assignment); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| @@ 14-58 (lines=45) @@ | ||
| 11 | * @author PyroCMS, Inc. <[email protected]> |
|
| 12 | * @author Ryan Thompson <[email protected]> |
|
| 13 | */ |
|
| 14 | class RenameAssignmentColumn |
|
| 15 | { |
|
| 16 | ||
| 17 | /** |
|
| 18 | * The assignment interface. |
|
| 19 | * |
|
| 20 | * @var AssignmentInterface |
|
| 21 | */ |
|
| 22 | protected $assignment; |
|
| 23 | ||
| 24 | /** |
|
| 25 | * Create a new RenameAssignmentColumn instance. |
|
| 26 | * |
|
| 27 | * @param AssignmentInterface $assignment |
|
| 28 | */ |
|
| 29 | public function __construct(AssignmentInterface $assignment) |
|
| 30 | { |
|
| 31 | $this->assignment = $assignment; |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * Handle the command. |
|
| 36 | * |
|
| 37 | * @param AssignmentSchema $schema |
|
| 38 | * @param AssignmentRepositoryInterface $assignments |
|
| 39 | */ |
|
| 40 | public function handle(AssignmentSchema $schema, AssignmentRepositoryInterface $assignments) |
|
| 41 | { |
|
| 42 | $stream = $this->assignment->getStream(); |
|
| 43 | $type = $this->assignment->getFieldType(true); |
|
| 44 | ||
| 45 | if (!$this->assignment->isTranslatable()) { |
|
| 46 | $table = $stream->getEntryTableName(); |
|
| 47 | } else { |
|
| 48 | $table = $stream->getEntryTranslationsTableName(); |
|
| 49 | } |
|
| 50 | ||
| 51 | /* @var AssignmentInterface $assignment */ |
|
| 52 | $assignment = $assignments->find($this->assignment->getId()); |
|
| 53 | ||
| 54 | $assignment = clone($assignment); |
|
| 55 | ||
| 56 | $schema->renameColumn($table, $type, $assignment); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||