当前位置: 首页>>代码示例>>PHP>>正文


PHP Object\Concrete类代码示例

本文整理汇总了PHP中Pimcore\Model\Object\Concrete的典型用法代码示例。如果您正苦于以下问题:PHP Concrete类的具体用法?PHP Concrete怎么用?PHP Concrete使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Concrete类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: save

 /**
  * @param Model\Object\Concrete $object
  * @throws \Exception
  */
 public function save(Model\Object\Concrete $object)
 {
     $tableName = $this->model->getDefinition()->getTableName($object->getClass());
     $data = array("o_id" => $object->getId(), "index" => $this->model->getIndex(), "fieldname" => $this->model->getFieldname());
     try {
         foreach ($this->model->getDefinition()->getFieldDefinitions() as $fd) {
             $getter = "get" . ucfirst($fd->getName());
             if (method_exists($fd, "save")) {
                 // for fieldtypes which have their own save algorithm eg. objects, multihref, ...
                 $fd->save($this->model);
             } else {
                 if ($fd->getColumnType()) {
                     if (is_array($fd->getColumnType())) {
                         $insertDataArray = $fd->getDataForResource($this->model->{$getter}(), $object);
                         $data = array_merge($data, $insertDataArray);
                     } else {
                         $data[$fd->getName()] = $fd->getDataForResource($this->model->{$getter}(), $object);
                     }
                 }
             }
         }
         $this->db->insert($tableName, $data);
     } catch (\Exception $e) {
         throw $e;
     }
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:30,代码来源:Resource.php

示例2: delete

 /**
  * @throws \Exception
  * @param Object\Concrete $object
  * @return void
  */
 public function delete(Object\Concrete $object)
 {
     // this is to clean up also the inherited values
     $fieldDef = $object->getClass()->getFieldDefinition($this->model->getFieldname());
     foreach ($fieldDef->getAllowedTypes() as $type) {
         try {
             $definition = Object\Objectbrick\Definition::getByKey($type);
         } catch (\Exception $e) {
             continue;
         }
         $tableName = $definition->getTableName($object->getClass(), true);
         $this->db->delete($tableName, "o_id = " . $object->getId());
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:19,代码来源:Dao.php

示例3: load

 /**
  * @param Object\Concrete $object
  * @return array
  */
 public function load(Object\Concrete $object)
 {
     $fieldDef = $object->getClass()->getFieldDefinition($this->model->getFieldname());
     $values = array();
     foreach ($fieldDef->getAllowedTypes() as $type) {
         try {
             $definition = Object\Objectbrick\Definition::getByKey($type);
         } catch (\Exception $e) {
             continue;
         }
         $tableName = $definition->getTableName($object->getClass(), false);
         try {
             $results = $this->db->fetchAll("SELECT * FROM " . $tableName . " WHERE o_id = ? AND fieldname = ?", array($object->getId(), $this->model->getFieldname()));
         } catch (\Exception $e) {
             $results = array();
         }
         //$allRelations = $this->db->fetchAll("SELECT * FROM object_relations_" . $object->getO_classId() . " WHERE src_id = ? AND ownertype = 'objectbrick' AND ownername = ?", array($object->getO_id(), $this->model->getFieldname()));
         $fieldDefinitions = $definition->getFieldDefinitions();
         $brickClass = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($type);
         foreach ($results as $result) {
             $brick = new $brickClass($object);
             $brick->setFieldname($result["fieldname"]);
             $brick->setObject($object);
             foreach ($fieldDefinitions as $key => $fd) {
                 if (method_exists($fd, "load")) {
                     // datafield has it's own loader
                     $value = $fd->load($brick);
                     if ($value === 0 || !empty($value)) {
                         $brick->setValue($key, $value);
                     }
                 } else {
                     if (is_array($fd->getColumnType())) {
                         $multidata = array();
                         foreach ($fd->getColumnType() as $fkey => $fvalue) {
                             $multidata[$key . "__" . $fkey] = $result[$key . "__" . $fkey];
                         }
                         $brick->setValue($key, $fd->getDataFromResource($multidata));
                     } else {
                         $brick->setValue($key, $fd->getDataFromResource($result[$key]));
                     }
                 }
             }
             $setter = "set" . ucfirst($type);
             $this->model->{$setter}($brick);
             $values[] = $brick;
         }
     }
     return $values;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:53,代码来源:Resource.php

示例4: doGetInheritedValues

 /**
  * @static
  * @return bool
  */
 public static function doGetInheritedValues(Concrete $object = null)
 {
     if (self::$getInheritedValues && $object !== null) {
         $class = $object->getClass();
         return $class->getAllowInherit();
     }
     return self::$getInheritedValues;
 }
开发者ID:rolandstoll,项目名称:pimcore,代码行数:12,代码来源:AbstractObject.php

示例5: getReplacement

 /**
  * Gets a object by it's id and replaces the placeholder width the value form the called "method"
  *
  * example: %Object(object_id,{"method" : "getId"});
  * @return string
  */
 public function getReplacement()
 {
     $string = '';
     $object = is_object($this->getValue()) ? $this->getValue() : Model\Object\Concrete::getById($this->getValue());
     if ($object) {
         if (is_string($this->getPlaceholderConfig()->method) && method_exists($object, $this->getPlaceholderConfig()->method)) {
             $string = $object->{$this->getPlaceholderConfig()->method}($this->getLocale());
         }
     }
     return $string;
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:17,代码来源:Object.php

示例6: sendMail

 /**
  * @param Model\Tool\Newsletter\Config $newsletter
  * @param Object\Concrete $object
  */
 public static function sendMail($newsletter, $object, $emailAddress = null, $hostUrl = null)
 {
     $params = ["gender" => $object->getGender(), 'firstname' => $object->getFirstname(), 'lastname' => $object->getLastname(), "email" => $object->getEmail(), 'token' => $object->getProperty("token"), "object" => $object];
     $mail = new Mail();
     $mail->setIgnoreDebugMode(true);
     if (\Pimcore\Config::getSystemConfig()->newsletter->usespecific) {
         $mail->init("newsletter");
     }
     if (!Tool::getHostUrl() && $hostUrl) {
         $mail->setHostUrl($hostUrl);
     }
     if ($emailAddress) {
         $mail->addTo($emailAddress);
     } else {
         $mail->addTo($object->getEmail());
     }
     $mail->setDocument(Document::getById($newsletter->getDocument()));
     $mail->setParams($params);
     // render the document and rewrite the links (if analytics is enabled)
     if ($newsletter->getGoogleAnalytics()) {
         if ($content = $mail->getBodyHtmlRendered()) {
             include_once "simple_html_dom.php";
             $html = str_get_html($content);
             if ($html) {
                 $links = $html->find("a");
                 foreach ($links as $link) {
                     if (preg_match("/^(mailto)/", trim(strtolower($link->href)))) {
                         continue;
                     }
                     $glue = "?";
                     if (strpos($link->href, "?")) {
                         $glue = "&";
                     }
                     $link->href = $link->href . $glue . "utm_source=Newsletter&utm_medium=Email&utm_campaign=" . $newsletter->getName();
                 }
                 $content = $html->save();
                 $html->clear();
                 unset($html);
             }
             $mail->setBodyHtml($content);
         }
     }
     $mail->send();
 }
开发者ID:solverat,项目名称:pimcore,代码行数:48,代码来源:Newsletter.php

示例7: testAction

 public function testAction()
 {
     //        $t = new OnlineShop_Framework_AbstractProduct();
     //        p_r($t);
     $x = OnlineShop_Framework_Factory::getInstance();
     //        p_r($x);
     $e = $x->getEnvironment();
     $e->setCurrentUserId(-1);
     p_r($e);
     //        p_r($e->getAllCustomItems());
     $cm = $x->getCartManager();
     //        $key = $cm->createCart(array("name" => "mycart"));
     $cm->addToCart(\Pimcore\Model\Object\Concrete::getById(430), 4, 14, array());
     //array("key" => 'mycart', "itemid" => 4459, "count" => 4));
     //        $e->setCustomItem("myitem2", "88776688");
     //        $e->save();
     $e = $x->getEnvironment();
     p_r($e);
     $x->saveState();
     //        $p = new OnlineShop_Plugin();
     //        p_r($p);
     die("meins");
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:23,代码来源:MyController.php

示例8: delete

 /**
  * @param Object\Concrete $object
  * @return void
  */
 public function delete($object)
 {
     $db = Resource::get();
     $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND " . $db->quoteInto("fieldname = ?", $this->getName()));
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:9,代码来源:ObjectsMetadata.php

示例9: getSuperLayoutDefinition

 /** Calculates the super layout definition for the given object.
  * @param Concrete $object
  * @return mixed
  */
 public static function getSuperLayoutDefinition(Concrete $object)
 {
     $masterLayout = $object->getClass()->getLayoutDefinitions();
     $superLayout = unserialize(serialize($masterLayout));
     self::createSuperLayout($superLayout);
     return $superLayout;
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:11,代码来源:Service.php

示例10: getCalculatedFieldValue

 /**
  * @param $object
  * @param $data Model\Object\Data\CalculatedValue
  * @return mixed|null
  */
 public static function getCalculatedFieldValue($object, $data)
 {
     if (!$data) {
         return null;
     }
     $fieldname = $data->getFieldname();
     $ownerType = $data->getOwnerType();
     /** @var $fd Model\Object\ClassDefinition\Data\CalculatedValue */
     if ($ownerType == "object") {
         $fd = $object->getClass()->getFieldDefinition($fieldname);
     } else {
         if ($ownerType == "localizedfield") {
             $fd = $object->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition($fieldname);
         } else {
             if ($ownerType == "classificationstore") {
                 $fd = $data->getKeyDefinition();
             } else {
                 if ($ownerType == "fieldcollection" || $ownerType == "objectbrick") {
                     $fd = $data->getKeyDefinition();
                 }
             }
         }
     }
     if (!$fd) {
         return null;
     }
     $className = $fd->getCalculatorClass();
     if (!$className || !\Pimcore\Tool::classExists($className)) {
         \Logger::error("Class does not exsist: " . $className);
         return null;
     }
     if (method_exists($className, 'compute')) {
         $inheritanceEnabled = Model\Object\Concrete::getGetInheritedValues();
         Model\Object\Concrete::setGetInheritedValues(true);
         $result = call_user_func($className . '::compute', $object, $data);
         Model\Object\Concrete::setGetInheritedValues($inheritanceEnabled);
         return $result;
     }
     return null;
 }
开发者ID:elavarasann,项目名称:pimcore,代码行数:45,代码来源:Service.php

示例11: getNicePathAction

 public function getNicePathAction()
 {
     $source = \Zend_Json::decode($this->getParam("source"));
     if ($source["type"] != "object") {
         throw new \Exception("currently only objects as source elements are supported");
     }
     $result = [];
     $id = $source["id"];
     $source = Object\Concrete::getById($id);
     if ($this->getParam("context")) {
         $context = \Zend_Json::decode($this->getParam("context"));
     } else {
         $context = [];
     }
     $ownerType = $context["containerType"];
     $fieldname = $context["fieldname"];
     if ($ownerType == "object") {
         $fd = $source->getClass()->getFieldDefinition($fieldname);
     } elseif ($ownerType == "localizedfield") {
         $fd = $source->getClass()->getFieldDefinition("localizedfields")->getFieldDefinition($fieldname);
     } elseif ($ownerType == "objectbrick") {
         $fdBrick = Object\Objectbrick\Definition::getByKey($context["containerKey"]);
         $fd = $fdBrick->getFieldDefinition($fieldname);
     } elseif ($ownerType == "fieldcollection") {
         $containerKey = $context["containerKey"];
         $fdCollection = Object\Fieldcollection\Definition::getByKey($containerKey);
         if ($context["subContainerType"] == "localizedfield") {
             $fdLocalizedFields = $fdCollection->getFieldDefinition("localizedfields");
             $fd = $fdLocalizedFields->getFieldDefinition($fieldname);
         } else {
             $fd = $fdCollection->getFieldDefinition($fieldname);
         }
     }
     if (method_exists($fd, "getPathFormatterClass")) {
         $formatterClass = $fd->getPathFormatterClass();
         if (Pimcore\Tool::classExists($formatterClass)) {
             $targets = \Zend_Json::decode($this->getParam("targets"));
             $result = call_user_func($formatterClass . "::formatPath", $result, $source, $targets, ["fd" => $fd, "context" => $context]);
         } else {
             Logger::error("Formatter Class does not exist: " . $formatterClass);
         }
     }
     $this->_helper->json(["success" => true, "data" => $result]);
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:44,代码来源:ElementController.php

示例12: loadProduct

 /**
  * @param $id
  *
  * @return \Pimcore\Model\Object\Concrete|null
  */
 protected function loadProduct($id)
 {
     return \Pimcore\Model\Object\Concrete::getById($id);
 }
开发者ID:ascertain,项目名称:NGshop,代码行数:9,代码来源:CatalogProduct.php

示例13: delete

 /**
  * @param Object\Concrete $object
  * @return void
  */
 public function delete($object, $params = [])
 {
     $db = Db::get();
     if ($params && $params["context"] && $params["context"]["containerType"] == "fieldcollection" && $params["context"]["subContainerType"] == "localizedfield") {
         $context = $params["context"];
         $index = $context["index"];
         $containerName = $context["fieldname"];
         $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND ownertype = 'localizedfield' AND " . $db->quoteInto("ownername LIKE ?", "/fieldcollection~" . $containerName . "/" . $index . "/%") . " AND " . $db->quoteInto("fieldname = ?", $this->getName()));
     } else {
         $db->delete("object_metadata_" . $object->getClassId(), $db->quoteInto("o_id = ?", $object->getId()) . " AND " . $db->quoteInto("fieldname = ?", $this->getName()));
     }
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:16,代码来源:MultihrefMetadata.php

示例14: testmagicAction

 public function testmagicAction()
 {
     $obj = Object\Concrete::getById(61071);
     $pairs = $obj->getKeyValuePairs();
     $value = $pairs->getab123();
     \Logger::debug("value=" . $value);
     $pairs->setab123("new valuexyz");
     $pairs->setdddd("dvalue");
     $obj->save();
 }
开发者ID:solverat,项目名称:pimcore,代码行数:10,代码来源:KeyValueController.php

示例15: delete

 /**
  * @param Object\Concrete $object
  */
 public function delete(Object\Concrete $object)
 {
     // empty or create all relevant tables
     $fieldDef = $object->getClass()->getFieldDefinition($this->model->getFieldname());
     foreach ($fieldDef->getAllowedTypes() as $type) {
         try {
             $definition = Object\Fieldcollection\Definition::getByKey($type);
         } catch (\Exception $e) {
             continue;
         }
         $tableName = $definition->getTableName($object->getClass());
         try {
             $this->db->delete($tableName, $this->db->quoteInto("o_id = ?", $object->getId()) . " AND " . $this->db->quoteInto("fieldname = ?", $this->model->getFieldname()));
         } catch (\Exception $e) {
             // create definition if it does not exist
             $definition->createUpdateTable($object->getClass());
         }
     }
     // empty relation table
     $this->db->delete("object_relations_" . $object->getClassId(), "ownertype = 'fieldcollection' AND " . $this->db->quoteInto("ownername = ?", $this->model->getFieldname()) . " AND " . $this->db->quoteInto("src_id = ?", $object->getId()));
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:24,代码来源:Resource.php


注:本文中的Pimcore\Model\Object\Concrete类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。