/** * */ public function __sleep() { $finalVars = array(); $parentVars = parent::__sleep(); if (isset($this->_fulldump)) { // this is if we want to make a full dump of the object (eg. for a new version), including childs for recyclebin $blockedVars = array("dependencies", "userPermissions", "hasChilds", "versions", "scheduledTasks", "parent"); $finalVars[] = "_fulldump"; $this->removeInheritedProperties(); } else { // this is if we want to cache the object $blockedVars = array("dependencies", "userPermissions", "childs", "hasChilds", "versions", "scheduledTasks", "properties", "parent"); } foreach ($parentVars as $key) { if (!in_array($key, $blockedVars)) { $finalVars[] = $key; } } return $finalVars; }
/** * @param $method * @param $args * @return mixed * @throws \Exception */ public function __call($method, $args) { // compatibility mode (they do not have any set_oXyz() methods anymore) if (preg_match("/^(get|set)o_/i", $method)) { $newMethod = preg_replace("/^(get|set)o_/i", "\$1", $method); if (method_exists($this, $newMethod)) { $r = call_user_func_array(array($this, $newMethod), $args); return $r; } } return parent::__call($method, $args); }
/** * @param Element\AbstractElement $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())); } }