Skip to content

Instantly share code, notes, and snippets.

View brusch's full-sized avatar

Bernhard Rusch brusch

View GitHub Profile
\Pimcore::getEventManager()->attach("object.preUpdate", function (\Zend_EventManager_Event $e) {
$object = $e->getTarget();
$status = $object->getProperty("workflowStatus");
if($status == "step1") {
// send mail to ...
// set new status
$object->setProperty("workflowStatus", "text", "step2");
### Contributor License Agreement
The following terms are used throughout this agreement:
* **You** - the person or legal entity including its affiliates asked to accept this agreement. An affiliate is any
entity that controls or is controlled by the legal entity, or is under common control with it.
* **Project** - is an umbrella term that refers to any and all pimcore open source projects.
* **Contribution** - any type of work that is submitted to a Project, including any modifications or additions to
existing work.
<?php
include("../../pimcore/cli/startup.php");
$db = Pimcore\Resource::get();
$tables = $db->fetchAll("SHOW TABLES LIKE 'object_localized_query_%'");
echo "\n\n";
foreach ($tables as $table) {
// 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": "*"
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);
},
<?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
<?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
include_once 'pimcore/config/startup_cli.php';
$classList = new \Pimcore\Model\DataObject\ClassDefinition\Listing();
$classes = $classList->load();
foreach ($classes as $class) {
$class->save();
}
<?php
namespace AppBundle\EventListener;
use Pimcore\Event\Model\AssetEvent;
class AssetMetadataListener
{
public function onAssetCreate(AssetEvent $event)
{
<?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]);