本文整理汇总了PHP中Pimcore\Tool::getModelClassMapping方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::getModelClassMapping方法的具体用法?PHP Tool::getModelClassMapping怎么用?PHP Tool::getModelClassMapping使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool
的用法示例。
在下文中一共展示了Tool::getModelClassMapping方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: classSaved
/**
* @return void
*/
public function classSaved($class)
{
$className = Tool::getModelClassMapping('\\Pimcore\\Model\\Object\\Data\\ObjectMetadata');
$temp = new $className(null);
$temp->getResource()->createOrUpdateTable($class);
}
示例2: addAction
public function addAction()
{
$success = false;
$className = "\\Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
// check for a mapped class
$className = Tool::getModelClassMapping($className);
$parent = Object::getById($this->getParam("parentId"));
$message = "";
if ($parent->isAllowed("create")) {
$intendedPath = $parent->getFullPath() . "/" . $this->getParam("key");
if (!Object\Service::pathExists($intendedPath) || true) {
$object = new $className();
if ($object instanceof Object\Concrete) {
$object->setOmitMandatoryCheck(true);
// allow to save the object although there are mandatory fields
}
if ($this->getParam("variantViaTree")) {
$parentId = $this->getParam("parentId");
$parent = Object::getById($parentId);
$object->setClassId($parent->getClass()->getId());
} else {
$object->setClassId($this->getParam("classId"));
}
$object->setClassName($this->getParam("className"));
$object->setParentId($this->getParam("parentId"));
$object->setKey($this->getParam("key"));
$object->setCreationDate(time());
$object->setUserOwner($this->getUser()->getId());
$object->setUserModification($this->getUser()->getId());
$object->setPublished(false);
if ($this->getParam("objecttype") == Object\AbstractObject::OBJECT_TYPE_OBJECT || $this->getParam("objecttype") == Object\AbstractObject::OBJECT_TYPE_VARIANT) {
$object->setType($this->getParam("objecttype"));
}
try {
$object->save();
$success = true;
} catch (\Exception $e) {
$this->_helper->json(array("success" => false, "message" => $e->getMessage()));
}
} else {
$message = "prevented creating object because object with same path+key already exists";
\Logger::debug($message);
}
} else {
$message = "prevented adding object because of missing permissions";
\Logger::debug($message);
}
if ($success) {
$this->_helper->json(array("success" => $success, "id" => $object->getId(), "type" => $object->getType(), "message" => $message));
} else {
$this->_helper->json(array("success" => $success, "message" => $message));
}
}
示例3: importProcessAction
public function importProcessAction()
{
$success = true;
$parentId = $this->getParam("parentId");
$job = $this->getParam("job");
$id = $this->getParam("id");
$mappingRaw = \Zend_Json::decode($this->getParam("mapping"));
$class = Object\ClassDefinition::getById($this->getParam("classId"));
$skipFirstRow = $this->getParam("skipHeadRow") == "true";
$fields = $class->getFieldDefinitions();
$file = PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id;
// currently only csv supported
// determine type
$dialect = Tool\Admin::determineCsvDialect(PIMCORE_SYSTEM_TEMP_DIRECTORY . "/import_" . $id . "_original");
$count = 0;
if (($handle = fopen($file, "r")) !== false) {
$data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
}
if ($skipFirstRow && $job == 1) {
//read the next row, we need to skip the head row
$data = fgetcsv($handle, 0, $dialect->delimiter, $dialect->quotechar, $dialect->escapechar);
}
$tmpFile = $file . "_tmp";
$tmpHandle = fopen($tmpFile, "w+");
while (!feof($handle)) {
$buffer = fgets($handle);
fwrite($tmpHandle, $buffer);
}
fclose($handle);
fclose($tmpHandle);
unlink($file);
rename($tmpFile, $file);
// prepare mapping
foreach ($mappingRaw as $map) {
if ($map[0] !== "" && $map[1] && !empty($map[2])) {
$mapping[$map[2]] = $map[0];
} else {
if ($map[1] == "published (system)") {
$mapping["published"] = $map[0];
} else {
if ($map[1] == "type (system)") {
$mapping["type"] = $map[0];
}
}
}
}
// create new object
$className = "\\Pimcore\\Model\\Object\\" . ucfirst($this->getParam("className"));
$className = Tool::getModelClassMapping($className);
$parent = Object::getById($this->getParam("parentId"));
$objectKey = "object_" . $job;
if ($this->getParam("filename") == "id") {
$objectKey = null;
} else {
if ($this->getParam("filename") != "default") {
$objectKey = File::getValidFilename($data[$this->getParam("filename")]);
}
}
$overwrite = false;
if ($this->getParam("overwrite") == "true") {
$overwrite = true;
}
if ($parent->isAllowed("create")) {
$intendedPath = $parent->getFullPath() . "/" . $objectKey;
if ($overwrite) {
$object = Object::getByPath($intendedPath);
if (!$object instanceof Object\Concrete) {
//create new object
$object = new $className();
} else {
if ($object instanceof Object\Concrete and !$object instanceof $className) {
//delete the old object it is of a different class
$object->delete();
$object = new $className();
} else {
if ($object instanceof Object\Folder) {
//delete the folder
$object->delete();
$object = new $className();
} else {
//use the existing object
}
}
}
} else {
$counter = 1;
while (Object::getByPath($intendedPath) != null) {
$objectKey .= "_" . $counter;
$intendedPath = $parent->getFullPath() . "/" . $objectKey;
$counter++;
}
$object = new $className();
}
$object->setClassId($this->getParam("classId"));
$object->setClassName($this->getParam("className"));
$object->setParentId($this->getParam("parentId"));
$object->setKey($objectKey);
$object->setCreationDate(time());
$object->setUserOwner($this->getUser()->getId());
$object->setUserModification($this->getUser()->getId());
//.........这里部分代码省略.........
示例4: createObjectConcrete
/**
* @param $wsDocument
* @throws \Exception
*/
public function createObjectConcrete($wsDocument)
{
try {
if ($wsDocument instanceof Webservice\Data\Object\Concrete\In) {
$classname = Tool::getModelClassMapping("\\Pimcore\\Model\\Object\\" . ucfirst($wsDocument->className));
if (Tool::classExists($classname)) {
$object = new $classname();
if ($object instanceof Object\Concrete) {
return $this->create($wsDocument, $object);
} else {
throw new \Exception("Unable to create new Object Concrete, could not instantiate Object with given class name [ {$classname} ]");
}
} else {
throw new \Exception("Unable to create new Object Concrete, no class name provided");
}
}
throw new \Exception("Unable to create new Object Concrete.");
} catch (\Exception $e) {
\Logger::error($e);
throw $e;
}
}
示例5: getTotalCount
/**
* @param array $config
* @return total count
*/
public static function getTotalCount($config = array())
{
$className = "\\Pimcore\\Model\\Object";
// get classname
if (get_called_class() != "Pimcore\\Model\\Object\\AbstractObject" && get_called_class() != "Pimcore\\Model\\Object\\Concrete") {
$tmpObject = new static();
$className = "\\Pimcore\\Model\\Object\\" . ucfirst($tmpObject->getClassName());
}
if (!empty($config["class"])) {
$className = "\\" . ltrim($config["class"], "\\");
}
if (is_array($config)) {
if ($className) {
$listClass = ucfirst($className) . "\\Listing";
// check for a mapped class
$listClass = Tool::getModelClassMapping($listClass);
if (Tool::classExists($listClass)) {
$list = new $listClass();
}
}
$list->setValues($config);
$count = $list->getTotalCount();
return $count;
}
}
示例6: getTotalCount
/**
* @param array $config
* @return total count
*/
public static function getTotalCount($config = array())
{
if (is_array($config)) {
$listClass = "\\Pimcore\\Model\\Document\\Listing";
$listClass = Tool::getModelClassMapping($listClass);
$list = new $listClass();
$list->setValues($config);
$count = $list->getTotalCount();
return $count;
}
}
示例7: getObjectById
public function getObjectById($id, $decode = true, $idMapper = null)
{
$url = $this->buildEndpointUrl("object/id/" . $id);
if ($this->getEnableProfiling()) {
$this->profilingInfo = null;
$url .= "&profiling=1";
}
if ($this->getCondense()) {
$url .= "&condense=1";
}
$response = $this->doRequest($url, "GET");
if ($this->getEnableProfiling()) {
$this->profilingInfo = $response->profiling;
}
$response = $response->data;
$wsDocument = $this->fillWebserviceData("\\Pimcore\\Model\\Webservice\\Data\\Object\\Concrete\\In", $response);
if (!$decode) {
return $wsDocument;
}
if ($wsDocument->type == "folder") {
$object = new Object\Folder();
$wsDocument->reverseMap($object);
return $object;
} else {
if ($wsDocument->type == "object" || $wsDocument->type == "variant") {
$classname = "\\Pimcore\\Model\\Object\\" . ucfirst($wsDocument->className);
// check for a mapped class
$classname = Tool::getModelClassMapping($classname);
if (Tool::classExists($classname)) {
$object = new $classname();
if ($object instanceof Object\Concrete) {
$curTime = microtime(true);
$wsDocument->reverseMap($object, $this->getDisableMappingExceptions(), $idMapper);
$timeConsumed = round(microtime(true) - $curTime, 3) * 1000;
if ($this->profilingInfo) {
$this->profilingInfo->reverse = $timeConsumed;
}
return $object;
} else {
throw new Exception("Unable to decode object, could not instantiate Object with given class name [ {$classname} ]");
}
} else {
throw new Exception("Unable to deocode object, class [" . $classname . "] does not exist");
}
}
}
}