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


PHP ClassDefinition::getByName方法代码示例

本文整理汇总了PHP中Pimcore\Model\Object\ClassDefinition::getByName方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassDefinition::getByName方法的具体用法?PHP ClassDefinition::getByName怎么用?PHP ClassDefinition::getByName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Model\Object\ClassDefinition的用法示例。


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

示例1: removeClass

 /**
  * @param string $name
  */
 public function removeClass($name)
 {
     $class = ClassDefinition::getByName($name);
     if ($class) {
         $class->delete();
     }
 }
开发者ID:Pegasuz,项目名称:member,代码行数:10,代码来源:Installer.php

示例2: isInstalled

 public static function isInstalled()
 {
     $memberClass = ClassDefinition::getByName('Member');
     if ($memberClass) {
         return true;
     }
     return false;
 }
开发者ID:Pegasuz,项目名称:member,代码行数:8,代码来源:Plugin.php

示例3: indexAction

 /**
  * @todo refactor steps into proper methods instead of doing it all in the action
  * @throws Exception
  */
 public function indexAction()
 {
     // reachable via http://your.domain/plugin/Prototyper/admin/index
     $this->view->previewData = null;
     $this->view->csvText = $this->getParam('csv');
     $this->view->classname = $this->getParam('classname');
     $csvData = array();
     $rowNr = 0;
     $rows = str_getcsv($this->view->csvText, "\n");
     //parse the rows
     foreach ($rows as $row) {
         $rowNr++;
         $rowData = str_getcsv($row, ";");
         $csvData[] = $rowData;
         if ($rowNr == 1) {
             $fieldNames = array();
             $fieldTitles = array();
             foreach ($rowData as $cell) {
                 $fieldTitles[] = $cell;
                 $fieldNames[] = $this->getFieldName($cell);
             }
             $csvData[] = $fieldNames;
         }
         if ($rowNr > 10) {
             break;
         }
     }
     $this->view->previewTable = $csvData;
     $fieldList = array();
     foreach ($fieldNames as $fieldName) {
         $fieldTitle = array_shift($fieldTitles);
         ob_start();
         include __DIR__ . "/../classes/field.json.php";
         $fieldList[] = ob_get_clean();
     }
     $fields = implode(',', $fieldList);
     ob_start();
     include __DIR__ . "/../classes/object.json.php";
     $jsonText = ob_get_clean();
     if ($this->getParam('generate') != '') {
         $class = Object\ClassDefinition::getByName($this->correctClassname($this->getParam("classname")));
         if ($class == null) {
             $class = Object\ClassDefinition::create(array('name' => $this->correctClassname($this->getParam("classname")), 'userOwner' => $this->user->getId()));
             $class->save();
         }
         $class = Object\ClassDefinition::getById($class->getId());
         $success = Object\ClassDefinition\Service::importClassDefinitionFromJson($class, $jsonText);
         if ($success) {
             $this->view->successMessage = '<strong>Class generation successful.</strong>';
         }
     }
 }
开发者ID:basilicom,项目名称:pimcore-plugin-prototyper,代码行数:56,代码来源:AdminController.php

示例4: __construct

 /**
  * @param null $classId
  * @throws \Exception
  */
 public function __construct($classId = null)
 {
     $class = null;
     if (is_string($classId)) {
         $class = Object\ClassDefinition::getByName($classId);
     } elseif (is_int($classId)) {
         $class = Object\ClassDefinition::getById($classId);
     } elseif ($classId !== null) {
         throw new \Exception("No valid class identifier given (class name or ID)");
     }
     if ($class instanceof Object\ClassDefinition) {
         $this->setClass($class);
     }
 }
开发者ID:solverat,项目名称:pimcore,代码行数:18,代码来源:Newsletter.php

示例5: saveAction

 public function saveAction()
 {
     $object = Object::getById($this->getParam("id"));
     // set the latest available version for editmode
     $object = $this->getLatestVersion($object);
     $object->setUserModification($this->getUser()->getId());
     // data
     if ($this->getParam("data")) {
         $data = \Zend_Json::decode($this->getParam("data"));
         foreach ($data as $key => $value) {
             $fd = $object->getClass()->getFieldDefinition($key);
             if ($fd) {
                 if ($fd instanceof Object\ClassDefinition\Data\Localizedfields) {
                     $user = Tool\Admin::getCurrentUser();
                     if (!$user->getAdmin()) {
                         $allowedLanguages = Object\Service::getLanguagePermissions($object, $user, "lEdit");
                         if (!is_null($allowedLanguages)) {
                             $allowedLanguages = array_keys($allowedLanguages);
                             $submittedLanguages = array_keys($data[$key]);
                             foreach ($submittedLanguages as $submittedLanguage) {
                                 if (!in_array($submittedLanguage, $allowedLanguages)) {
                                     unset($value[$submittedLanguage]);
                                 }
                             }
                         }
                     }
                 }
                 if (method_exists($fd, "isRemoteOwner") and $fd->isRemoteOwner()) {
                     $remoteClass = Object\ClassDefinition::getByName($fd->getOwnerClassName());
                     $relations = $object->getRelationData($fd->getOwnerFieldName(), false, $remoteClass->getId());
                     $toAdd = $this->detectAddedRemoteOwnerRelations($relations, $value);
                     $toDelete = $this->detectDeletedRemoteOwnerRelations($relations, $value);
                     if (count($toAdd) > 0 or count($toDelete) > 0) {
                         $this->processRemoteOwnerRelations($object, $toDelete, $toAdd, $fd->getOwnerFieldName());
                     }
                 } else {
                     $object->setValue($key, $fd->getDataFromEditmode($value, $object));
                 }
             }
         }
     }
     // general settings
     // @TODO: IS THIS STILL NECESSARY?
     if ($this->getParam("general")) {
         $general = \Zend_Json::decode($this->getParam("general"));
         // do not allow all values to be set, will cause problems (eg. icon)
         if (is_array($general) && count($general) > 0) {
             foreach ($general as $key => $value) {
                 if (!in_array($key, array("o_id", "o_classId", "o_className", "o_type", "icon", "o_userOwner", "o_userModification"))) {
                     $object->setValue($key, $value);
                 }
             }
         }
     }
     $object = $this->assignPropertiesFromEditmode($object);
     // scheduled tasks
     if ($this->getParam("scheduler")) {
         $tasks = array();
         $tasksData = \Zend_Json::decode($this->getParam("scheduler"));
         if (!empty($tasksData)) {
             foreach ($tasksData as $taskData) {
                 $taskData["date"] = strtotime($taskData["date"] . " " . $taskData["time"]);
                 $task = new Model\Schedule\Task($taskData);
                 $tasks[] = $task;
             }
         }
         $object->setScheduledTasks($tasks);
     }
     if ($this->getParam("task") == "unpublish") {
         $object->setPublished(false);
     }
     if ($this->getParam("task") == "publish") {
         $object->setPublished(true);
     }
     // unpublish and save version is possible without checking mandatory fields
     if ($this->getParam("task") == "unpublish" || $this->getParam("task") == "version") {
         $object->setOmitMandatoryCheck(true);
     }
     if ($this->getParam("task") == "publish" && $object->isAllowed("publish") or $this->getParam("task") == "unpublish" && $object->isAllowed("unpublish")) {
         try {
             $object->save();
             $treeData = array();
             $treeData["qtipCfg"] = $object->getElementAdminStyle()->getElementQtipConfig();
             $this->_helper->json(array("success" => true, "treeData" => $treeData));
         } catch (\Exception $e) {
             \Logger::log($e);
             $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
         }
     } elseif ($this->getParam("task") == "session") {
         //$object->_fulldump = true; // not working yet, donno why
         Tool\Session::useSession(function ($session) use($object) {
             $key = "object_" . $object->getId();
             $session->{$key} = $object;
         }, "pimcore_objects");
         $this->_helper->json(array("success" => true));
     } else {
         if ($object->isAllowed("save")) {
             try {
                 $object->saveVersion();
                 $this->_helper->json(array("success" => true));
//.........这里部分代码省略.........
开发者ID:emanuel-london,项目名称:pimcore,代码行数:101,代码来源:ObjectController.php

示例6: findAction

 /**
  * @return void
  */
 public function findAction()
 {
     $user = $this->getUser();
     $query = $this->getParam("query");
     if ($query == "*") {
         $query = "";
     }
     $query = str_replace("%", "*", $query);
     $query = preg_replace("@([^ ])\\-@", "\$1 ", $query);
     $types = explode(",", $this->getParam("type"));
     $subtypes = explode(",", $this->getParam("subtype"));
     $classnames = explode(",", $this->getParam("class"));
     if ($this->getParam("type") == "object" && is_array($classnames) && empty($classnames[0])) {
         $subtypes = ["object", "variant", "folder"];
     }
     $offset = intval($this->getParam("start"));
     $limit = intval($this->getParam("limit"));
     $offset = $offset ? $offset : 0;
     $limit = $limit ? $limit : 50;
     $searcherList = new Data\Listing();
     $conditionParts = [];
     $db = \Pimcore\Db::get();
     //exclude forbidden assets
     if (in_array("asset", $types)) {
         if (!$user->isAllowed("assets")) {
             $forbiddenConditions[] = " `type` != 'asset' ";
         } else {
             $forbiddenAssetPaths = Element\Service::findForbiddenPaths("asset", $user);
             if (count($forbiddenAssetPaths) > 0) {
                 for ($i = 0; $i < count($forbiddenAssetPaths); $i++) {
                     $forbiddenAssetPaths[$i] = " (maintype = 'asset' AND fullpath not like " . $db->quote($forbiddenAssetPaths[$i] . "%") . ")";
                 }
                 $forbiddenConditions[] = implode(" AND ", $forbiddenAssetPaths);
             }
         }
     }
     //exclude forbidden documents
     if (in_array("document", $types)) {
         if (!$user->isAllowed("documents")) {
             $forbiddenConditions[] = " `type` != 'document' ";
         } else {
             $forbiddenDocumentPaths = Element\Service::findForbiddenPaths("document", $user);
             if (count($forbiddenDocumentPaths) > 0) {
                 for ($i = 0; $i < count($forbiddenDocumentPaths); $i++) {
                     $forbiddenDocumentPaths[$i] = " (maintype = 'document' AND fullpath not like " . $db->quote($forbiddenDocumentPaths[$i] . "%") . ")";
                 }
                 $forbiddenConditions[] = implode(" AND ", $forbiddenDocumentPaths);
             }
         }
     }
     //exclude forbidden objects
     if (in_array("object", $types)) {
         if (!$user->isAllowed("objects")) {
             $forbiddenConditions[] = " `type` != 'object' ";
         } else {
             $forbiddenObjectPaths = Element\Service::findForbiddenPaths("object", $user);
             if (count($forbiddenObjectPaths) > 0) {
                 for ($i = 0; $i < count($forbiddenObjectPaths); $i++) {
                     $forbiddenObjectPaths[$i] = " (maintype = 'object' AND fullpath not like " . $db->quote($forbiddenObjectPaths[$i] . "%") . ")";
                 }
                 $forbiddenConditions[] = implode(" AND ", $forbiddenObjectPaths);
             }
         }
     }
     if ($forbiddenConditions) {
         $conditionParts[] = "(" . implode(" AND ", $forbiddenConditions) . ")";
     }
     if (!empty($query)) {
         $queryCondition = "( MATCH (`data`,`properties`) AGAINST (" . $db->quote($query) . " IN BOOLEAN MODE) )";
         // the following should be done with an exact-search now "ID", because the Element-ID is now in the fulltext index
         // if the query is numeric the user might want to search by id
         //if(is_numeric($query)) {
         //$queryCondition = "(" . $queryCondition . " OR id = " . $db->quote($query) ." )";
         //}
         $conditionParts[] = $queryCondition;
     }
     //For objects - handling of bricks
     $fields = [];
     $bricks = [];
     if ($this->getParam("fields")) {
         $fields = $this->getParam("fields");
         foreach ($fields as $f) {
             $parts = explode("~", $f);
             if (substr($f, 0, 1) == "~") {
                 //                    $type = $parts[1];
                 //                    $field = $parts[2];
                 //                    $keyid = $parts[3];
                 // key value, ignore for now
             } elseif (count($parts) > 1) {
                 $bricks[$parts[0]] = $parts[0];
             }
         }
     }
     // filtering for objects
     if ($this->getParam("filter") && $this->getParam("class")) {
         $class = Object\ClassDefinition::getByName($this->getParam("class"));
         // add Localized Fields filtering
//.........这里部分代码省略.........
开发者ID:pimcore,项目名称:pimcore,代码行数:101,代码来源:SearchController.php

示例7: isInstalled

 /**
  * @return boolean $isInstalled
  */
 public static function isInstalled()
 {
     $entry = Object\ClassDefinition::getByName('CoreShopProduct');
     $category = Object\ClassDefinition::getByName('CoreShopProduct');
     $cartItem = Object\ClassDefinition::getByName('CoreShopCart');
     $cart = Object\ClassDefinition::getByName('CoreShopCartItem');
     $order = Object\ClassDefinition::getByName('CoreShopOrder');
     $orderItem = Object\ClassDefinition::getByName('CoreShopOrderItem');
     $orderPayment = Object\ClassDefinition::getByName('CoreShopPayment');
     //$cartRule = Object\ClassDefinition::getByName('CoreShopCartRule');
     $orderState = Object\ClassDefinition::getByName('CoreShopOrderState');
     if ($entry && $category && $cart && $cartItem && $order && $orderItem && $orderPayment && $orderState) {
         return true;
     }
     return false;
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:19,代码来源:Plugin.php

示例8: batchAction

 public function batchAction()
 {
     $success = true;
     try {
         $object = Object::getById($this->getParam("job"));
         if ($object) {
             $className = $object->getClassName();
             $class = Object\ClassDefinition::getByName($className);
             $value = $this->getParam("value");
             if ($this->getParam("valueType") == "object") {
                 $value = \Zend_Json::decode($value);
             }
             $name = $this->getParam("name");
             $parts = explode("~", $name);
             if (substr($name, 0, 1) == "~") {
                 $type = $parts[1];
                 $field = $parts[2];
                 $keyid = $parts[3];
                 $getter = "get" . ucfirst($field);
                 $setter = "set" . ucfirst($field);
                 $keyValuePairs = $object->{$getter}();
                 if (!$keyValuePairs) {
                     $keyValuePairs = new Object\Data\KeyValue();
                     $keyValuePairs->setObjectId($object->getId());
                     $keyValuePairs->setClass($object->getClass());
                 }
                 $keyValuePairs->setPropertyWithId($keyid, $value, true);
                 $object->{$setter}($keyValuePairs);
             } else {
                 if (count($parts) > 1) {
                     // check for bricks
                     $brickType = $parts[0];
                     $brickKey = $parts[1];
                     $brickField = Object\Service::getFieldForBrickType($object->getClass(), $brickType);
                     $fieldGetter = "get" . ucfirst($brickField);
                     $brickGetter = "get" . ucfirst($brickType);
                     $valueSetter = "set" . ucfirst($brickKey);
                     $brick = $object->{$fieldGetter}()->{$brickGetter}();
                     if (empty($brick)) {
                         $classname = "\\Pimcore\\Model\\Object\\Objectbrick\\Data\\" . ucfirst($brickType);
                         $brickSetter = "set" . ucfirst($brickType);
                         $brick = new $classname($object);
                         $object->{$fieldGetter}()->{$brickSetter}($brick);
                     }
                     $brickClass = Object\Objectbrick\Definition::getByKey($brickType);
                     $field = $brickClass->getFieldDefinition($brickKey);
                     $brick->{$valueSetter}($field->getDataFromEditmode($value, $object));
                 } else {
                     // everything else
                     $field = $class->getFieldDefinition($name);
                     if ($field) {
                         $object->setValue($name, $field->getDataFromEditmode($value, $object));
                     } else {
                         // check if it is a localized field
                         if ($this->getParam("language")) {
                             $localizedField = $class->getFieldDefinition("localizedfields");
                             if ($localizedField) {
                                 $field = $localizedField->getFieldDefinition($name);
                                 if ($field) {
                                     $object->{"set" . $name}($value, $this->getParam("language"));
                                 }
                             }
                         }
                         // seems to be a system field, this is actually only possible for the "published" field yet
                         if ($name == "published") {
                             if ($value == "false" || empty($value)) {
                                 $object->setPublished(false);
                             } else {
                                 $object->setPublished(true);
                             }
                         }
                     }
                 }
             }
             try {
                 // don't check for mandatory fields here
                 $object->setOmitMandatoryCheck(true);
                 $object->setUserModification($this->getUser()->getId());
                 $object->save();
                 $success = true;
             } catch (\Exception $e) {
                 $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
             }
         } else {
             \Logger::debug("ObjectController::batchAction => There is no object left to update.");
             $this->_helper->json(array("success" => false, "message" => "ObjectController::batchAction => There is no object left to update."));
         }
     } catch (\Exception $e) {
         \Logger::err($e);
         $this->_helper->json(array("success" => false, "message" => $e->getMessage()));
     }
     $this->_helper->json(array("success" => $success));
 }
开发者ID:cannonerd,项目名称:pimcore,代码行数:93,代码来源:ObjectHelperController.php

示例9: findAction

 /**
  * @return void
  */
 public function findAction()
 {
     $user = $this->getUser();
     $query = $this->getParam("query");
     if ($query == "*") {
         $query = "";
     }
     $query = str_replace("%", "*", $query);
     $types = explode(",", $this->getParam("type"));
     $subtypes = explode(",", $this->getParam("subtype"));
     $classnames = explode(",", $this->getParam("class"));
     if ($this->getParam("type") == "object" && is_array($classnames) && empty($classnames[0])) {
         $subtypes = array("object", "variant", "folder");
     }
     $offset = intval($this->getParam("start"));
     $limit = intval($this->getParam("limit"));
     $offset = $offset ? $offset : 0;
     $limit = $limit ? $limit : 50;
     $searcherList = new Data\Listing();
     $conditionParts = array();
     $db = \Pimcore\Db::get();
     //exclude forbidden assets
     if (in_array("asset", $types)) {
         if (!$user->isAllowed("assets")) {
             $forbiddenConditions[] = " `type` != 'asset' ";
         } else {
             $forbiddenAssetPaths = Element\Service::findForbiddenPaths("asset", $user);
             if (count($forbiddenAssetPaths) > 0) {
                 for ($i = 0; $i < count($forbiddenAssetPaths); $i++) {
                     $forbiddenAssetPaths[$i] = " (maintype = 'asset' AND fullpath not like " . $db->quote($forbiddenAssetPaths[$i] . "%") . ")";
                 }
                 $forbiddenConditions[] = implode(" AND ", $forbiddenAssetPaths);
             }
         }
     }
     //exclude forbidden documents
     if (in_array("document", $types)) {
         if (!$user->isAllowed("documents")) {
             $forbiddenConditions[] = " `type` != 'document' ";
         } else {
             $forbiddenDocumentPaths = Element\Service::findForbiddenPaths("document", $user);
             if (count($forbiddenDocumentPaths) > 0) {
                 for ($i = 0; $i < count($forbiddenDocumentPaths); $i++) {
                     $forbiddenDocumentPaths[$i] = " (maintype = 'document' AND fullpath not like " . $db->quote($forbiddenDocumentPaths[$i] . "%") . ")";
                 }
                 $forbiddenConditions[] = implode(" AND ", $forbiddenDocumentPaths);
             }
         }
     }
     //exclude forbidden objects
     if (in_array("object", $types)) {
         if (!$user->isAllowed("objects")) {
             $forbiddenConditions[] = " `type` != 'object' ";
         } else {
             $forbiddenObjectPaths = Element\Service::findForbiddenPaths("object", $user);
             if (count($forbiddenObjectPaths) > 0) {
                 for ($i = 0; $i < count($forbiddenObjectPaths); $i++) {
                     $forbiddenObjectPaths[$i] = " (maintype = 'object' AND fullpath not like " . $db->quote($forbiddenObjectPaths[$i] . "%") . ")";
                 }
                 $forbiddenConditions[] = implode(" AND ", $forbiddenObjectPaths);
             }
         }
     }
     if ($forbiddenConditions) {
         $conditionParts[] = "(" . implode(" AND ", $forbiddenConditions) . ")";
     }
     if (!empty($query)) {
         $queryCondition = "( MATCH (`data`,`properties`) AGAINST (" . $db->quote($query) . " IN BOOLEAN MODE) )";
         // the following should be done with an exact-search now "ID", because the Element-ID is now in the fulltext index
         // if the query is numeric the user might want to search by id
         //if(is_numeric($query)) {
         //$queryCondition = "(" . $queryCondition . " OR id = " . $db->quote($query) ." )";
         //}
         $conditionParts[] = $queryCondition;
     }
     //For objects - handling of bricks
     $fields = array();
     $bricks = array();
     if ($this->getParam("fields")) {
         $fields = $this->getParam("fields");
         foreach ($fields as $f) {
             $parts = explode("~", $f);
             if (substr($f, 0, 1) == "~") {
                 //                    $type = $parts[1];
                 //                    $field = $parts[2];
                 //                    $keyid = $parts[3];
                 // key value, ignore for now
             } else {
                 if (count($parts) > 1) {
                     $bricks[$parts[0]] = $parts[0];
                 }
             }
         }
     }
     // filtering for objects
     if ($this->getParam("filter") && $this->getParam("class")) {
         $class = Object\ClassDefinition::getByName($this->getParam("class"));
//.........这里部分代码省略.........
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:101,代码来源:SearchController.php

示例10: importObjectBrickFromJson

 /**
  * @param $objectBrick
  * @param $json
  * @return bool
  */
 public static function importObjectBrickFromJson($objectBrick, $json, $throwException = false)
 {
     $importData = \Zend_Json::decode($json);
     // reverse map the class name to the class ID, see: self::generateObjectBrickJson()
     if (is_array($importData["classDefinitions"])) {
         foreach ($importData["classDefinitions"] as &$cd) {
             if (!is_numeric($cd["classname"])) {
                 $class = Object\ClassDefinition::getByName($cd["classname"]);
                 if ($class) {
                     $cd["classname"] = $class->getId();
                 }
             }
         }
     }
     $layout = self::generateLayoutTreeFromArray($importData["layoutDefinitions"], $throwException);
     $objectBrick->setLayoutDefinitions($layout);
     $objectBrick->setClassDefinitions($importData["classDefinitions"]);
     $objectBrick->setParentClass($importData["parentClass"]);
     $objectBrick->save();
     return true;
 }
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:26,代码来源:Service.php

示例11: execute

 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $newsletter = Model\Tool\Newsletter\Config::getByName($input->getArgument("id"));
     if ($newsletter) {
         $pidFile = $newsletter->getPidFile();
         if (file_exists($pidFile)) {
             \Logger::alert("Cannot send newsletters because there's already one active sending process");
             exit;
         }
         $elementsPerLoop = 10;
         $objectList = "\\Pimcore\\Model\\Object\\" . ucfirst($newsletter->getClass()) . "\\Listing";
         $list = new $objectList();
         $conditions = array("(newsletterActive = 1 AND newsletterConfirmed = 1)");
         if ($newsletter->getObjectFilterSQL()) {
             $conditions[] = $newsletter->getObjectFilterSQL();
         }
         if ($newsletter->getPersonas()) {
             $class = Model\Object\ClassDefinition::getByName($newsletter->getClass());
             if ($class && $class->getFieldDefinition("persona")) {
                 $personas = array();
                 $p = explode(",", $newsletter->getPersonas());
                 if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Persona) {
                     foreach ($p as $value) {
                         if (!empty($value)) {
                             $personas[] = $list->quote($value);
                         }
                     }
                     $conditions[] = "persona IN (" . implode(",", $personas) . ")";
                 } else {
                     if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Personamultiselect) {
                         $personasCondition = array();
                         foreach ($p as $value) {
                             $personasCondition[] = "persona LIKE " . $list->quote("%," . $value . ",%");
                         }
                         $conditions[] = "(" . implode(" OR ", $personasCondition) . ")";
                     }
                 }
             }
         }
         $list->setCondition(implode(" AND ", $conditions));
         $list->setOrderKey("email");
         $list->setOrder("ASC");
         $elementsTotal = $list->getTotalCount();
         $count = 0;
         $pidContents = array("start" => time(), "lastUpdate" => time(), "newsletter" => $newsletter->getName(), "total" => $elementsTotal, "current" => $count);
         $this->writePid($pidFile, $pidContents);
         for ($i = 0; $i < ceil($elementsTotal / $elementsPerLoop); $i++) {
             $list->setLimit($elementsPerLoop);
             $list->setOffset($i * $elementsPerLoop);
             $objects = $list->load();
             foreach ($objects as $object) {
                 try {
                     $count++;
                     \Logger::info("Sending newsletter " . $count . " / " . $elementsTotal . " [" . $newsletter->getName() . "]");
                     \Pimcore\Tool\Newsletter::sendMail($newsletter, $object, null, $input->getArgument("hostUrl"));
                     $note = new Model\Element\Note();
                     $note->setElement($object);
                     $note->setDate(time());
                     $note->setType("newsletter");
                     $note->setTitle("sent newsletter: '" . $newsletter->getName() . "'");
                     $note->setUser(0);
                     $note->setData(array());
                     $note->save();
                     \Logger::info("Sent newsletter to: " . $this->obfuscateEmail($object->getEmail()) . " [" . $newsletter->getName() . "]");
                 } catch (\Exception $e) {
                     \Logger::err($e);
                 }
             }
             // check if pid exists
             if (!file_exists($pidFile)) {
                 \Logger::alert("Newsletter PID not found, cancel sending process");
                 exit;
             }
             // update pid
             $pidContents["lastUpdate"] = time();
             $pidContents["current"] = $count;
             $this->writePid($pidFile, $pidContents);
             \Pimcore::collectGarbage();
         }
         // remove pid
         @unlink($pidFile);
     } else {
         \Logger::emerg("Newsletter '" . $input->getArgument("id") . "' doesn't exist");
     }
 }
开发者ID:siite,项目名称:choose-sa-cloud,代码行数:85,代码来源:InternalNewsletterSendCommand.php

示例12: buildOptions

 public function buildOptions()
 {
     $classes = $this->classes;
     $options = array();
     if (is_array($classes)) {
         foreach ($classes as $class) {
             $class = ClassDefinition::getByName($class);
             if ($class instanceof ClassDefinition) {
                 $listClassName = "Pimcore\\Model\\Object\\" . $class->getName() . "\\Listing";
                 $listObject = new $listClassName();
                 $listObject->getObjects();
                 foreach ($listObject as $listItem) {
                     $options[] = array("key" => $listItem->getKey(), "value" => $listItem->getId(), "path" => $listItem->getFullPath());
                 }
             }
         }
     }
     $this->setOptions($options);
 }
开发者ID:Cube-Solutions,项目名称:pimcore-coreshop,代码行数:19,代码来源:ObjectSelect.php

示例13: getMailAddressesForBatchSending

 /**
  * returns array of email addresses for batch sending
  *
  * @return SendingParamContainer[]
  */
 public function getMailAddressesForBatchSending()
 {
     $listing = $this->getListing();
     $ids = $listing->loadIdList();
     $class = ClassDefinition::getByName($this->class);
     $tableName = "object_" . $class->getId();
     $db = \Pimcore\Db::get();
     $emails = $db->fetchCol("SELECT email FROM {$tableName} WHERE o_id IN (" . implode(",", $ids) . ")");
     $containers = [];
     foreach ($emails as $email) {
         $containers[] = new SendingParamContainer($email, ['emailAddress' => $email]);
     }
     return $containers;
 }
开发者ID:pimcore,项目名称:pimcore,代码行数:19,代码来源:DefaultAdapter.php

示例14: ucfirst

$newsletter = Model\Tool\Newsletter\Config::getByName($argv[1]);
if ($newsletter) {
    $pidFile = $newsletter->getPidFile();
    if (file_exists($pidFile)) {
        \Logger::alert("Cannot send newsletters because there's already one active sending process");
        exit;
    }
    $elementsPerLoop = 10;
    $objectList = "\\Pimcore\\Model\\Object\\" . ucfirst($newsletter->getClass()) . "\\Listing";
    $list = new $objectList();
    $conditions = array("(newsletterActive = 1 AND newsletterConfirmed = 1)");
    if ($newsletter->getObjectFilterSQL()) {
        $conditions[] = $newsletter->getObjectFilterSQL();
    }
    if ($newsletter->getPersonas()) {
        $class = Model\Object\ClassDefinition::getByName($newsletter->getClass());
        if ($class && $class->getFieldDefinition("persona")) {
            $personas = array();
            $p = explode(",", $newsletter->getPersonas());
            if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Persona) {
                foreach ($p as $value) {
                    if (!empty($value)) {
                        $personas[] = $list->quote($value);
                    }
                }
                $conditions[] = "persona IN (" . implode(",", $personas) . ")";
            } else {
                if ($class->getFieldDefinition("persona") instanceof \Pimcore\Model\Object\ClassDefinition\Data\Personamultiselect) {
                    $personasCondition = array();
                    foreach ($p as $value) {
                        $personasCondition[] = "persona LIKE " . $list->quote("%," . $value . ",%");
开发者ID:yonetici,项目名称:pimcore-coreshop-demo,代码行数:31,代码来源:send-newsletter.php

示例15: allowObjectRelation

 /**
  *
  * Checks if an object is an allowed relation
  * @param Model\Object\AbstractObject $object
  * @return boolean
  */
 protected function allowObjectRelation($object)
 {
     //only relations of owner type are allowed
     $ownerClass = Object\ClassDefinition::getByName($this->getOwnerClassName());
     if ($ownerClass->getId() > 0 and $ownerClass->getId() == $object->getClassId()) {
         $fd = $ownerClass->getFieldDefinition($this->getOwnerFieldName());
         if ($fd instanceof Object\ClassDefinition\Data\Objects) {
             return $fd->allowObjectRelation($object);
         }
     } else {
         return false;
     }
 }
开发者ID:emanuel-london,项目名称:pimcore,代码行数:19,代码来源:Nonownerobjects.php


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