Created
October 17, 2015 14:14
-
-
Save gsomoza/6171738fce1c39608afb to your computer and use it in GitHub Desktop.
Pimcore Migrations Samples
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
<?php | |
namespace Migrations; | |
use Pimcore\Migrations\Migration\AbstractMigration; | |
use Pimcore\Model\Staticroute; | |
/** | |
* Migration v20151009133517_AddStaticRoute | |
* @author Gabriel Somoza <[email protected]> | |
*/ | |
class v20151009133517_ForgotPasswordRoutes extends AbstractMigration | |
{ | |
/** | |
* Executed when migrating upwards. | |
*/ | |
public function up() | |
{ | |
//add forgotpassword static route | |
$route = new Staticroute(); | |
$route->setName('my-route') | |
->setPattern('#/foo/my-route/(.*?)#') | |
->setReverse('/foo/my-route/%param') | |
->setController('foo') | |
->setAction('myroute') | |
->setVariables('param') | |
->setPriority(1) | |
->save(); | |
} | |
/** | |
* Executed when migrating downwards. | |
*/ | |
public function down() | |
{ | |
$list = new Staticroute\Listing(); | |
$list->setCondition("name = ?", ['forgotpassword']); | |
$results = $list->load(); | |
if (!empty($results)) { | |
$results[0]->delete(); | |
} | |
} | |
} |
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
<?php | |
namespace Migrations; | |
use Pimcore\Controller\Action\Admin\Element; | |
use Pimcore\Migrations\Migration\AbstractMigration; | |
use Pimcore\Model\Document; | |
/** | |
* Migration v20151013133917_ReplaceElement | |
* @author Gabriel Somoza <[email protected]> | |
*/ | |
class v20151013133917_ReplaceElement extends AbstractMigration | |
{ | |
/** | |
* Executed when migrating upwards. | |
*/ | |
public function up() | |
{ | |
$page = Document::getById(1); | |
//second column | |
$newIcon = 'icon-browser-streamline-window half-opacity'; | |
$page->setRawElement('iconcontent_cs3_1content11_1', 'select', $newIcon); | |
//third column | |
$newIcon = 'icon-man-people-streamline-user half-opacity'; | |
$page->setRawElement('iconcontent_cs3_2content11_1', 'select', $newIcon); | |
//fourth column | |
$newIcon = 'icon-crown-king-streamline half-opacity'; | |
$page->setRawElement('iconcontent_cs3_3content11_1', 'select', $newIcon); | |
$page->save(); | |
} | |
/** | |
* Executed when migrating downwards. | |
*/ | |
public function down() | |
{ | |
//second column | |
$page = Document::getById(1); | |
$newIcon = 'icon-chef-food-restaurant-streamline'; | |
$page->setRawElement('iconcontent_cs3_1content11_1', 'select', $newIcon); | |
//third column | |
$newIcon = 'half-opacity icon-armchair-chair-streamline'; | |
$page->setRawElement('iconcontent_cs3_2content11_1', 'select', $newIcon); | |
//fourth column | |
$newIcon = 'icon-book-dowload-streamline'; | |
$page->setRawElement('iconcontent_cs3_3content11_1', 'select', $newIcon); | |
$page->save(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment