php Pimcore-Model-Object-Concrete类(方法)实例源码

下面列出了php Pimcore-Model-Object-Concrete 类(方法)源码代码实例,从而了解它的用法。

作者:yonetic    项目:pimcore-coreshop-dem   
/**
  * @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;
     }
 }

作者:solvera    项目:pimcor   
/**
  * @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());
     }
 }

作者:yonetic    项目:pimcore-coreshop-dem   
/**
  * @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;
 }

作者:rolandstol    项目:pimcor   
/**
  * @static
  * @return bool
  */
 public static function doGetInheritedValues(Concrete $object = null)
 {
     if (self::$getInheritedValues && $object !== null) {
         $class = $object->getClass();
         return $class->getAllowInherit();
     }
     return self::$getInheritedValues;
 }

作者:ChristophWurs    项目:pimcor   
/**
  * 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;
 }

作者:solvera    项目:pimcor   
/**
  * @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();
 }

作者:ascertai    项目:NGsho   
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");
 }

作者:yonetic    项目:pimcore-coreshop-dem   
/**
  * @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()));
 }

作者:elavarasan    项目:pimcor   
/** 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;
 }

作者:elavarasan    项目:pimcor   
/**
  * @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;
 }

作者:pimcor    项目:pimcor   
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]);
 }

作者:ascertai    项目:NGsho   
/**
  * @param $id
  *
  * @return \Pimcore\Model\Object\Concrete|null
  */
 protected function loadProduct($id)
 {
     return \Pimcore\Model\Object\Concrete::getById($id);
 }

作者:pimcor    项目:pimcor   
/**
  * @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()));
     }
 }

作者:solvera    项目:pimcor   
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();
 }

作者:yonetic    项目:pimcore-coreshop-dem   
/**
  * @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()));
 }

作者:solvera    项目:pimcor   
/**
  * @param  Document|Asset|ConcreteObject $element
  * @return Document|Asset|ConcreteObject
  */
 protected function getLatestVersion($element)
 {
     //TODO move this maybe to a service method, since this is also used in ObjectController and DocumentControllers
     if ($element instanceof Document) {
         $latestVersion = $element->getLatestVersion();
         if ($latestVersion) {
             $latestDoc = $latestVersion->loadData();
             if ($latestDoc instanceof Document) {
                 $element = $latestDoc;
                 $element->setModificationDate($element->getModificationDate());
             }
         }
     }
     if ($element instanceof Object\Concrete) {
         $modificationDate = $element->getModificationDate();
         $latestVersion = $element->getLatestVersion();
         if ($latestVersion) {
             $latestObj = $latestVersion->loadData();
             if ($latestObj instanceof ConcreteObject) {
                 $element = $latestObj;
                 $element->setModificationDate($modificationDate);
             }
         }
     }
     return $element;
 }

作者:emanuel-londo    项目:pimcor   
/**
  * @param  Object\Concrete $object
  * @return Object\Concrete
  */
 protected function getLatestVersion(Object\Concrete $object)
 {
     $modificationDate = $object->getModificationDate();
     $latestVersion = $object->getLatestVersion();
     if ($latestVersion) {
         $latestObj = $latestVersion->loadData();
         if ($latestObj instanceof Object\Concrete) {
             $object = $latestObj;
             $object->setModificationDate($modificationDate);
             // set de modification-date from published version to compare it in js-frontend
         }
     }
     return $object;
 }

作者:pimcor    项目:pimcor   
/**
  * @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 {
             /** @var  $definition Definition */
             $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());
         }
         if ($definition->getFieldDefinition("localizedfields")) {
             $tableName = $definition->getLocalizedTableName($object->getClass());
             try {
                 $this->db->delete($tableName, $this->db->quoteInto("ooo_id = ?", $object->getId()) . " AND " . $this->db->quoteInto("fieldname = ?", $this->model->getFieldname()));
             } catch (\Exception $e) {
                 \Logger::error($e);
             }
         }
         $childDefinitions = $definition->getFielddefinitions();
         if (is_array($childDefinitions)) {
             foreach ($childDefinitions as $fd) {
                 if (method_exists($fd, "delete")) {
                     $fd->delete($object, ["context" => ["containerType" => "fieldcollection", "containerKey" => $type, "fieldname" => $this->model->getFieldname()]]);
                 }
             }
         }
     }
     // 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()) . ")" . " OR (ownertype = 'localizedfield' AND " . $this->db->quoteInto("ownername LIKE ?", "/fieldcollection~" . $this->model->getFieldname() . "/%") . ")");
 }

作者:ascertai    项目:NGsho   
/**
  * @param $id
  *
  * @return \Pimcore\Model\Object\Concrete|null
  */
 protected function loadCategory($id)
 {
     return \Pimcore\Model\Object\Concrete::getById($id);
 }

作者:Pegasu    项目:membe   
protected function checkcredential(Concrete $identity)
 {
     /** @var \Pimcore\Model\Object\ClassDefinition\Data\Password $credentialField */
     $credentialField = $identity->getClass()->getFieldDefinition($this->credentialColumn);
     $hashed = $credentialField->getDataForResource($this->credential);
     return $hashed === $identity->{$this->credentialColumn};
 }


问题


面经


文章

微信
公众号

扫码关注公众号