Skip to content

Instantly share code, notes, and snippets.

@gsomoza
Created October 17, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gsomoza/6171738fce1c39608afb to your computer and use it in GitHub Desktop.
Save gsomoza/6171738fce1c39608afb to your computer and use it in GitHub Desktop.
Pimcore Migrations Samples
<?php
namespace Migrations;
use Pimcore\Migrations\Migration\AbstractMigration;
use Pimcore\Model\Staticroute;
/**
* Migration v20151009133517_AddStaticRoute
* @author Gabriel Somoza <gabriel@somoza.me>
*/
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();
}
}
}
<?php
namespace Migrations;
use Pimcore\Controller\Action\Admin\Element;
use Pimcore\Migrations\Migration\AbstractMigration;
use Pimcore\Model\Document;
/**
* Migration v20151013133917_ReplaceElement
* @author Gabriel Somoza <gabriel@somoza.me>
*/
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