protected function getCsvFieldData($field, $object, $requestedLanguage)
 {
     //check if field is systemfield
     $systemFieldMap = ['id' => "getId", 'fullpath' => "getRealFullPath", 'published' => "getPublished", 'creationDate' => "getCreationDate", 'modificationDate' => "getModificationDate", 'filename' => "getKey", 'classname' => "getClassname"];
     if (in_array($field, array_keys($systemFieldMap))) {
         return $object->{$systemFieldMap[$field]}();
     } else {
         //check if field is standard object field
         $fieldDefinition = $object->getClass()->getFieldDefinition($field);
         if ($fieldDefinition) {
             return $fieldDefinition->getForCsvExport($object);
         } else {
             $fieldParts = explode("~", $field);
             // check for objects bricks and localized fields
             if (substr($field, 0, 1) == "~") {
                 $type = $fieldParts[1];
                 if ($type == "classificationstore") {
                     $fieldname = $fieldParts[2];
                     $groupKeyId = explode("-", $fieldParts[3]);
                     $groupId = $groupKeyId[0];
                     $keyId = $groupKeyId[1];
                     $getter = "get" . ucfirst($fieldname);
                     if (method_exists($object, $getter)) {
                         /** @var  $classificationStoreData Classificationstore */
                         $keyConfig = Pimcore\Model\Object\Classificationstore\KeyConfig::getById($keyId);
                         $type = $keyConfig->getType();
                         $definition = json_decode($keyConfig->getDefinition());
                         $fieldDefinition = \Pimcore\Model\Object\Classificationstore\Service::getFieldDefinitionFromJson($definition, $type);
                         return $fieldDefinition->getForCsvExport($object, ["context" => ["containerType" => "classificationstore", "fieldname" => $fieldname, "groupId" => $groupId, "keyId" => $keyId, "language" => $requestedLanguage]]);
                     }
                 }
                 //key value store - ignore for now
             } elseif (count($fieldParts) > 1) {
                 // brick
                 $brickType = $fieldParts[0];
                 $brickKey = $fieldParts[1];
                 $key = Object\Service::getFieldForBrickType($object->getClass(), $brickType);
                 $brickClass = Pimcore\Model\Object\Objectbrick\Definition::getByKey($brickType);
                 $fieldDefinition = $brickClass->getFieldDefinition($brickKey);
                 if ($fieldDefinition) {
                     $brickContainer = $object->{"get" . ucfirst($key)}();
                     if ($brickContainer && !empty($brickKey)) {
                         $brick = $brickContainer->{"get" . ucfirst($brickType)}();
                         if ($brick) {
                             return $fieldDefinition->getForCsvExport($brick);
                         }
                     }
                 }
             } elseif ($locFields = $object->getClass()->getFieldDefinition("localizedfields")) {
                 // if the definition is not set try to get the definition from localized fields
                 $fieldDefinition = $locFields->getFieldDefinition($field);
                 if ($fieldDefinition) {
                     $needLocalizedPermissions = true;
                     return $fieldDefinition->getForCsvExport($object->getLocalizedFields(), ["language" => $this->getParam("language")]);
                 }
             }
         }
     }
 }
 protected function getCsvFieldData($field, $object)
 {
     //check if field is systemfield
     $systemFieldMap = ['id' => "getId", 'fullpath' => "getFullPath", 'published' => "getPublished", 'creationDate' => "getCreationDate", 'modificationDate' => "getModificationDate", 'filename' => "getKey", 'classname' => "getClassname"];
     if (in_array($field, array_keys($systemFieldMap))) {
         return $object->{$systemFieldMap[$field]}();
     } else {
         //check if field is standard object field
         $fieldDefinition = $object->getClass()->getFieldDefinition($field);
         if ($fieldDefinition) {
             return $fieldDefinition->getForCsvExport($object);
         } else {
             $fieldParts = explode("~", $field);
             // check for objects bricks and localized fields
             if (substr($field, 0, 1) == "~") {
                 //key value store - ignore for now
             } else {
                 if (count($fieldParts) > 1) {
                     // brick
                     $brickType = $fieldParts[0];
                     $brickKey = $fieldParts[1];
                     $key = Object\Service::getFieldForBrickType($object->getClass(), $brickType);
                     $brickClass = Pimcore\Model\Object\Objectbrick\Definition::getByKey($brickType);
                     $fieldDefinition = $brickClass->getFieldDefinition($brickKey);
                     if ($fieldDefinition) {
                         $brickContainer = $object->{"get" . ucfirst($key)}();
                         if ($brickContainer && !empty($brickKey)) {
                             $brick = $brickContainer->{"get" . ucfirst($brickType)}();
                             if ($brick) {
                                 return $fieldDefinition->getForCsvExport($brick);
                             }
                         }
                     }
                 } else {
                     if ($locFields = $object->getClass()->getFieldDefinition("localizedfields")) {
                         // if the definition is not set try to get the definition from localized fields
                         $fieldDefinition = $locFields->getFieldDefinition($field);
                         if ($fieldDefinition) {
                             $needLocalizedPermissions = true;
                             return $fieldDefinition->getForCsvExport($object->getLocalizedFields(), ["language" => $this->getParam("language")]);
                         }
                     }
                 }
             }
         }
     }
 }
Beispiel #3
0
 /**
  * @todo
  */
 private static function installObjectBricks()
 {
     $sourceFiles = scandir(PIMCORE_PLUGINS_PATH . '/OnlineShop/install/objectbrick_sources');
     foreach ($sourceFiles as $filename) {
         if (!is_dir($filename)) {
             preg_match('/_(.*)_/', $filename, $matches);
             $key = $matches[1];
             try {
                 $brick = \Pimcore\Model\Object\Objectbrick\Definition::getByKey($key);
             } catch (Exception $e) {
                 $brick = new \Pimcore\Model\Object\Objectbrick\Definition();
                 $brick->setKey($key);
             }
             $data = file_get_contents(PIMCORE_PLUGINS_PATH . '/OnlineShop/install/objectbrick_sources/' . $filename);
             $success = \Pimcore\Model\Object\ClassDefinition\Service::importObjectBrickFromJson($brick, $data);
             if (!$success) {
                 Logger::err("Could not import {$key} ObjectBrick.");
             }
         }
     }
 }