/** * creates a class called "unittest" containing all Object_Class_Data Types currently available. * @return void * @depends testFieldCollectionCreate */ public function testClassCreate() { $conf = new Zend_Config_Xml(TESTS_PATH . "/resources/objects/class-import.xml"); $importData = $conf->toArray(); $layout = Object_Class_Service::generateLayoutTreeFromArray($importData["layoutDefinitions"]); $class = Object_Class::create(); $class->setName("unittest"); $class->setUserOwner(1); $class->save(); $id = $class->getId(); $this->assertTrue($id > 0); $class = Object_Class::getById($id); $class->setLayoutDefinitions($layout); $class->setUserModification(1); $class->setModificationDate(time()); $class->save(); }
public function createClass($name) { $conf = new Zend_Config_Xml(PIMCORE_PLUGINS_PATH . "/Blog/install/class_{$name}.xml", null, true); if ($name == 'BlogEntry' && !class_exists('Tagfield_Plugin')) { unset($conf->layoutDefinitions->childs->childs->{4}); } $class = Object_Class::create(); $class->setName($name); $class->setUserOwner($this->_getUser()->getId()); $class->setLayoutDefinitions(Object_Class_Service::generateLayoutTreeFromArray($conf->layoutDefinitions->toArray())); $class->setIcon($conf->icon); $class->setAllowInherit($conf->allowInherit); $class->setAllowVariants($conf->allowVariants); $class->setParentClass($conf->parentClass); $class->setPreviewUrl($conf->previewUrl); $class->setPropertyVisibility($conf->propertyVisibility); $class->save(); return $class; }
public function exportObjectbrickAction() { $this->removeViewRenderer(); $objectBrick = Object_Objectbrick_Definition::getByKey($this->_getParam("id")); if (!$objectBrick instanceof Object_Objectbrick_Definition) { $errorMessage = ": Object-Brick with id [ " . $this->_getParam("id") . " not found. ]"; Logger::error($errorMessage); echo $errorMessage; } else { $xml = Object_Class_Service::generateFieldCollectionXml($objectBrick); header("Content-type: application/xml"); header("Content-Disposition: attachment; filename=\"class_" . $objectBrick->getKey() . "_export.xml\""); echo $xml; } }
unlink($file); } // delete file } /** @var Object_Fieldcollection_Definition $class */ foreach ($classes as $class) { $key = $class->getKey(); $json = Object_Class_Service::generateFieldCollectionJson($class); $handle = fopen(PIMCORE_DOCUMENT_ROOT . '/data/fieldcollections/' . $key . '.json', 'w'); fwrite($handle, $json); fclose($handle); } $classesList = new Object_Objectbrick_Definition_List(); $classes = $classesList->load(); $files = glob(PIMCORE_DOCUMENT_ROOT . '/data/objectbricks/*'); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) { unlink($file); } // delete file } /** @var Object_Objectbrick_Definition $class */ foreach ($classes as $class) { $key = $class->getKey(); $json = Object_Class_Service::generateObjectbrickJson($class); $handle = fopen(PIMCORE_DOCUMENT_ROOT . '/data/objectbricks/' . $key . '.json', 'w'); fwrite($handle, $json); fclose($handle); }
// array of existing collections /** @var Object_Objectbrick_Definition $class */ foreach ($classes as $class) { $classes_array[$class->getKey()] = true; } $files = glob(PIMCORE_DOCUMENT_ROOT . '/data/objectbricks/*'); // get all file names // tworzenie kolekcji na podstawie plików foreach ($files as $file) { // iterate files if (is_file($file)) { $string = file_get_contents($file); $classname = basename($file, ".json"); unset($classes_array[$classname]); try { $class = Object_Objectbrick_Definition::getByKey($classname); Object_Class_Service::importObjectbrickFromJson($class, $string); } catch (Exception $e) { $newClass = new Object_Objectbrick_Definition(); $newClass->setKey($classname); Object_Class_Service::importObjectbrickFromJson($newClass, $string); } } } // usuwanie kolekcji /** @var Object_Objectbrick_Definition $class */ foreach ($classes_array as $classname => $tmp) { $class = Object_Objectbrick_Definition::getByKey($classname); $class->delete(); echo "Delete objectbrick: " . $classname . "\n"; }
if (is_file($file)) { unlink($file); } // delete file } /** @var Object_Class $class */ foreach ($classes as $class) { $json = Object_Class_Service::generateClassDefinitionJson($class); $handle = fopen('extra/classes/' . $class->getName() . '.json', 'w'); fwrite($handle, $json); fclose($handle); } $classesList = new Object_Fieldcollection_Definition_List(); $classes = $classesList->load(); $files = glob('extra/fieldcollections/*'); // get all file names foreach ($files as $file) { // iterate files if (is_file($file)) { unlink($file); } // delete file } /** @var Object_Fieldcollection_Definition $class */ foreach ($classes as $class) { $key = $class->getKey(); $json = Object_Class_Service::generateFieldCollectionJson($class); $handle = fopen('extra/fieldcollections/' . $key . '.json', 'w'); fwrite($handle, $json); fclose($handle); }
$classes = $classesList->load(); $classes_array = array(); // array of existing classes /** @var Object_Class $class */ foreach ($classes as $class) { $classes_array[$class->getName()] = true; } $files = glob('extra/classes/*'); // get all file names // tworzenie klas na podstawie plików foreach ($files as $file) { // iterate files if (is_file($file)) { $string = file_get_contents($file); $classname = basename($file, ".json"); $class = Object_Class::getByName($classname); unset($classes_array[$classname]); if ($class) { Object_Class_Service::importClassDefinitionFromJson($class, $string); } else { $newClass = Object_Class::create(array("name" => $classname)); Object_Class_Service::importClassDefinitionFromJson($newClass, $string); } } } // usuwanie klas foreach ($classes_array as $classname => $tmp) { $class = Object_Class::getByName($classname); $class->delete(); echo "Delete class: " . $classname . "\n"; }