Skip to content

Instantly share code, notes, and snippets.

View brusch's full-sized avatar

Bernhard Rusch brusch

View GitHub Profile
@brusch
brusch / pimcore-6-migrate-content.php
Created December 16, 2019 09:50
Pimcore 6 Content Migration Script
<?php
include_once __DIR__ . "/vendor/autoload.php";
\Pimcore\Bootstrap::setProjectRoot();
\Pimcore\Bootstrap::startupCli();
use Pimcore\Model\DataObject;
$search = 'O:30:"Pimcore\Model\Object\Data\Link"';
@brusch
brusch / JqueryAdminListener.php
Created November 13, 2019 08:26
Add jQuery to Pimcore admin interface
<?php
namespace AppBundle\EventListener;
use Pimcore\Event\BundleManager\PathsEvent;
use Pimcore\Event\BundleManagerEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class JqueryAdminListener implements EventSubscriberInterface
{
@brusch
brusch / pimcore-migrations-40-to-54.php
Last active January 22, 2020 08:52
Pimcore migrations from 4.x to 5.4
<?php
namespace localMigration;
include_once __DIR__ . "/vendor/autoload.php";
\Pimcore\Bootstrap::startupCli();
use Pimcore\Bundle\EcommerceFrameworkBundle\PimcoreEcommerceFrameworkBundle;
use Pimcore\Db;
<?php
$client = new \Zend\XmlRpc\Client('https://example.com/rpc/xmlrpc'); // INSERT your hostname
$token = $client->call('confluence2.login', ['USERNAME','PASSWORD']); // INSERT your user + pass
try {
$profilePictureData = file_get_contents('/path/to/your/image/file.jpg'); // INSERT path to the file
$profilePictureData = new \Zend\XmlRpc\Value\Base64($profilePictureData);
// REPLACE "confluence-username" with the username of the user to update
$result = $client->call('confluence2.addProfilePicture', [$token, 'confluence-username', 'file.jpg', 'image/jpg', $profilePictureData]);
<?php
namespace AppBundle\EventListener;
use Pimcore\Event\Model\AssetEvent;
class AssetMetadataListener
{
public function onAssetCreate(AssetEvent $event)
{
<?php
include_once 'pimcore/config/startup_cli.php';
$classList = new \Pimcore\Model\DataObject\ClassDefinition\Listing();
$classes = $classList->load();
foreach ($classes as $class) {
$class->save();
}
<?php
\Pimcore::getEventManager()->attach("object.preUpdate", function (\Zend_EventManager_Event $event) {
$newObject = $event->getTarget();
\Pimcore::collectGarbage();
$oldObject = \Pimcore\Model\Object::getById($newObject);
if($newObject->getKey() != $oldObject->getKey()) {
// ...
}
<?php
\Pimcore::getEventManager()->attach("admin.controller.postInit", function ($event) {
$controller = $event->getTarget();
if($controller->getParam("controller") == "object" && $controller->getParam("action") == "update") {
$object = \Pimcore\Model\Object::getById($controller->getParam("id"));
// do with the object whatever you want
// later in ObjectController::updateAction() the pimcore admin will get the same instance of this object
// since ::getById() returns always the same object for an ID
pimcore.registerNS("pimcore.plugin.test");
pimcore.plugin.test = Class.create(pimcore.plugin.admin, {
getClassName: function() {
return "pimcore.plugin.test";
},
initialize: function() {
pimcore.plugin.broker.registerPlugin(this);
},
// PUT THE FOLLOWING INTO YOUR "BUCKET POLICY" AND RENAME 'pimcore-demo' WITH THE NAME OF YOUR S3-BUCKET
{
"Version": "2008-10-17",
"Id": "Policy1380877762691",
"Statement": [
{
"Sid": "Stmt1380877761162",
"Effect": "Allow",
"Principal": {
"AWS": "*"