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


PHP Utils\Util类代码示例

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


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

示例1: getImplementation

 public function getImplementation($scope)
 {
     if (empty($this->implementationHashMap[$scope])) {
         $normalizedName = Util::normilizeClassName($scope);
         $className = '\\Espo\\Custom\\AclPortal\\' . $normalizedName;
         if (!class_exists($className)) {
             $moduleName = $this->getMetadata()->getScopeModuleName($scope);
             if ($moduleName) {
                 $className = '\\Espo\\Modules\\' . $moduleName . '\\AclPortal\\' . $normalizedName;
             } else {
                 $className = '\\Espo\\AclPortal\\' . $normalizedName;
             }
             if (!class_exists($className)) {
                 $className = '\\Espo\\Core\\AclPortal\\Base';
             }
         }
         if (class_exists($className)) {
             $acl = new $className($scope);
             $dependencies = $acl->getDependencyList();
             foreach ($dependencies as $name) {
                 $acl->inject($name, $this->getContainer()->get($name));
             }
             $this->implementationHashMap[$scope] = $acl;
         } else {
             throw new Error();
         }
     }
     return $this->implementationHashMap[$scope];
 }
开发者ID:houzhenggang,项目名称:espocrm,代码行数:29,代码来源:AclManager.php

示例2: getNotificator

 protected function getNotificator($entityType)
 {
     if (empty($this->notifatorsHash[$entityType])) {
         $normalizedName = Util::normilizeClassName($entityType);
         $className = '\\Espo\\Custom\\Notificators\\' . $normalizedName;
         if (!class_exists($className)) {
             $moduleName = $this->getMetadata()->getScopeModuleName($entityType);
             if ($moduleName) {
                 $className = '\\Espo\\Modules\\' . $moduleName . '\\Notificators\\' . $normalizedName;
             } else {
                 $className = '\\Espo\\Notificators\\' . $normalizedName;
             }
             if (!class_exists($className)) {
                 $className = '\\Espo\\Core\\Notificators\\Base';
             }
         }
         $notificator = new $className();
         $dependencies = $notificator->getDependencyList();
         foreach ($dependencies as $name) {
             $notificator->inject($name, $this->getContainer()->get($name));
         }
         $this->notifatorsHash[$entityType] = $notificator;
     }
     return $this->notifatorsHash[$entityType];
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:25,代码来源:Notifications.php

示例3: load

 protected function load($fieldName, $entityName)
 {
     $subList = array('first' . ucfirst($fieldName), ' ', 'last' . ucfirst($fieldName));
     $tableName = Util::toUnderScore($entityName);
     $orderByField = 'first' . ucfirst($fieldName);
     // TODO available in settings
     $fullList = array();
     $fullListReverse = array();
     $fieldList = array();
     $like = array();
     $equal = array();
     foreach ($subList as $subFieldName) {
         $fieldNameTrimmed = trim($subFieldName);
         if (!empty($fieldNameTrimmed)) {
             $columnName = $tableName . '.' . Util::toUnderScore($fieldNameTrimmed);
             $fullList[] = $fieldList[] = $columnName;
             $like[] = $columnName . " LIKE {value}";
             $equal[] = $columnName . " = {value}";
         } else {
             $fullList[] = "'" . $subFieldName . "'";
         }
     }
     $fullListReverse = array_reverse($fullList);
     return array($entityName => array('fields' => array($fieldName => array('type' => 'varchar', 'select' => $this->getSelect($fullList), 'where' => array('LIKE' => "(" . implode(" OR ", $like) . " OR CONCAT(" . implode(", ", $fullList) . ") LIKE {value} OR CONCAT(" . implode(", ", $fullListReverse) . ") LIKE {value})", '=' => "(" . implode(" OR ", $equal) . " OR CONCAT(" . implode(", ", $fullList) . ") = {value} OR CONCAT(" . implode(", ", $fullListReverse) . ") = {value})"), 'orderBy' => '' . $tableName . '.' . Util::toUnderScore($orderByField) . ' {direction}'))));
 }
开发者ID:disearth,项目名称:espocrm,代码行数:25,代码来源:PersonName.php

示例4: load

 protected function load($linkName, $entityName)
 {
     $parentRelation = parent::load($linkName, $entityName);
     $relation = array($entityName => array('fields' => array($linkName . 'Types' => array('type' => 'jsonObject', 'notStorable' => true))));
     $relation = \Espo\Core\Utils\Util::merge($parentRelation, $relation);
     return $relation;
 }
开发者ID:disearth,项目名称:espocrm,代码行数:7,代码来源:Attachments.php

示例5: get

 public function get($scope, $name)
 {
     $scope = $this->sanitizeInput($scope);
     $name = $this->sanitizeInput($name);
     if (isset($this->changedData[$scope][$name])) {
         return Json::encode($this->changedData[$scope][$name]);
     }
     $fileFullPath = Util::concatPath($this->getLayoutPath($scope, true), 'portal/' . $name . '.json');
     if (!file_exists($fileFullPath)) {
         $fileFullPath = Util::concatPath($this->getLayoutPath($scope), 'portal/' . $name . '.json');
     }
     if (!file_exists($fileFullPath)) {
         $fileFullPath = Util::concatPath($this->getLayoutPath($scope, true), $name . '.json');
     }
     if (!file_exists($fileFullPath)) {
         $fileFullPath = Util::concatPath($this->getLayoutPath($scope), $name . '.json');
     }
     if (!file_exists($fileFullPath)) {
         $defaultPath = $this->params['defaultsPath'];
         $fileFullPath = Util::concatPath(Util::concatPath($defaultPath, 'layouts'), $name . '.json');
         if (!file_exists($fileFullPath)) {
             return false;
         }
     }
     return $this->getFileManager()->getContents($fileFullPath);
 }
开发者ID:houzhenggang,项目名称:espocrm,代码行数:26,代码来源:Layout.php

示例6: load

 protected function load($fieldName, $entityName)
 {
     $foreignField = $this->getForeignField($fieldName, $entityName);
     $tableName = Util::toUnderScore($entityName);
     $fullList = array();
     //contains empty string (" ") like delimiter
     $fullListReverse = array();
     //reverse of $fullList
     $fieldList = array();
     //doesn't contain empty string (" ") like delimiter
     $like = array();
     $equal = array();
     foreach ($foreignField as $foreignFieldName) {
         $fieldNameTrimmed = trim($foreignFieldName);
         if (!empty($fieldNameTrimmed)) {
             $columnName = $tableName . '.' . Util::toUnderScore($fieldNameTrimmed);
             $fullList[] = $fieldList[] = $columnName;
             $like[] = $columnName . " LIKE '{text}'";
             $equal[] = $columnName . " = '{text}'";
         } else {
             $fullList[] = "'" . $foreignFieldName . "'";
         }
     }
     $fullListReverse = array_reverse($fullList);
     return array($entityName => array('fields' => array($fieldName => array('type' => 'varchar', 'select' => $this->getSelect($fullList), 'where' => array('LIKE' => "(" . implode(" OR ", $like) . " OR CONCAT(" . implode(", ", $fullList) . ") LIKE '{text}' OR CONCAT(" . implode(", ", $fullListReverse) . ") LIKE '{text}')", '=' => "(" . implode(" OR ", $equal) . " OR CONCAT(" . implode(", ", $fullList) . ") = '{text}' OR CONCAT(" . implode(", ", $fullListReverse) . ") = '{text}')"), 'orderBy' => implode(", ", array_map(function ($item) {
         return $item . ' {direction}';
     }, $fieldList))))));
 }
开发者ID:jdavis593,项目名称:appitechture,代码行数:28,代码来源:PersonName.php

示例7: load

 protected function load($linkName, $entityName)
 {
     $parentRelation = parent::load($linkName, $entityName);
     $foreignEntityName = $this->getForeignEntityName();
     $relation = array($entityName => array('relations' => array($linkName => array('midKeys' => array(lcfirst($entityName) . 'Id', lcfirst($foreignEntityName) . 'Id')))));
     $relation = \Espo\Core\Utils\Util::merge($parentRelation, $relation);
     return $relation;
 }
开发者ID:disearth,项目名称:espocrm,代码行数:8,代码来源:EmailEmailAddress.php

示例8: normalizeEntityName

 public function normalizeEntityName($name)
 {
     if (empty($this->entityClassNameHash[$name])) {
         $className = '\\Espo\\Custom\\Entities\\' . Util::normilizeClassName($name);
         if (!class_exists($className)) {
             $className = $this->espoMetadata->getEntityPath($name);
         }
         $this->entityClassNameHash[$name] = $className;
     }
     return $this->entityClassNameHash[$name];
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:11,代码来源:EntityManager.php

示例9: getClassName

 protected function getClassName($name)
 {
     $name = Util::normilizeClassName($name);
     if (!isset($this->data)) {
         $this->init();
     }
     $name = ucfirst($name);
     if (isset($this->data[$name])) {
         return $this->data[$name];
     }
     return false;
 }
开发者ID:houzhenggang,项目名称:espocrm,代码行数:12,代码来源:EntryPointManager.php

示例10: process

 public function process($controllerName, $actionName, $params, $data, $request)
 {
     $customeClassName = '\\Espo\\Custom\\Controllers\\' . Util::normilizeClassName($controllerName);
     if (class_exists($customeClassName)) {
         $controllerClassName = $customeClassName;
     } else {
         $moduleName = $this->metadata->getScopeModuleName($controllerName);
         if ($moduleName) {
             $controllerClassName = '\\Espo\\Modules\\' . $moduleName . '\\Controllers\\' . Util::normilizeClassName($controllerName);
         } else {
             $controllerClassName = '\\Espo\\Controllers\\' . Util::normilizeClassName($controllerName);
         }
     }
     if ($data && stristr($request->getContentType(), 'application/json')) {
         $data = json_decode($data);
     }
     if ($data instanceof \stdClass) {
         $data = get_object_vars($data);
     }
     if (!class_exists($controllerClassName)) {
         throw new NotFound("Controller '{$controllerName}' is not found");
     }
     $controller = new $controllerClassName($this->container, $request->getMethod());
     if ($actionName == 'index') {
         $actionName = $controllerClassName::$defaultAction;
     }
     $actionNameUcfirst = ucfirst($actionName);
     $beforeMethodName = 'before' . $actionNameUcfirst;
     $actionMethodName = 'action' . $actionNameUcfirst;
     $afterMethodName = 'after' . $actionNameUcfirst;
     $fullActionMethodName = strtolower($request->getMethod()) . ucfirst($actionMethodName);
     if (method_exists($controller, $fullActionMethodName)) {
         $primaryActionMethodName = $fullActionMethodName;
     } else {
         $primaryActionMethodName = $actionMethodName;
     }
     if (!method_exists($controller, $primaryActionMethodName)) {
         throw new NotFound("Action '{$actionName}' (" . $request->getMethod() . ") does not exist in controller '{$controllerName}'");
     }
     if (method_exists($controller, $beforeMethodName)) {
         $controller->{$beforeMethodName}($params, $data, $request);
     }
     $result = $controller->{$primaryActionMethodName}($params, $data, $request);
     if (method_exists($controller, $afterMethodName)) {
         $controller->{$afterMethodName}($params, $data, $request);
     }
     if (is_array($result) || is_bool($result) || $result instanceof \StdClass) {
         return \Espo\Core\Utils\Json::encode($result);
     }
     return $result;
 }
开发者ID:disearth,项目名称:espocrm,代码行数:51,代码来源:ControllerManager.php

示例11: __construct

 public function __construct()
 {
     parent::__construct();
     if (empty($this->entityType)) {
         $name = get_class($this);
         if (preg_match('@\\\\([\\w]+)$@', $name, $matches)) {
             $name = $matches[1];
         }
         if ($name != 'Record') {
             $this->entityType = Util::normilizeScopeName($name);
         }
     }
     $this->entityName = $this->entityType;
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:14,代码来源:Record.php

示例12: run

 public function run()
 {
     $uid = $_GET['uid'];
     $action = $_GET['action'];
     if (empty($uid) || empty($action)) {
         throw new BadRequest();
     }
     if (!in_array($action, array('accept', 'decline', 'tentative'))) {
         throw new BadRequest();
     }
     $uniqueId = $this->getEntityManager()->getRepository('UniqueId')->where(array('name' => $uid))->findOne();
     if (!$uniqueId) {
         throw new NotFound();
         return;
     }
     $data = $uniqueId->get('data');
     $eventType = $data->eventType;
     $eventId = $data->eventId;
     $inviteeType = $data->inviteeType;
     $inviteeId = $data->inviteeId;
     $link = $data->link;
     if (!empty($eventType) && !empty($eventId) && !empty($inviteeType) && !empty($inviteeId) && !empty($link)) {
         $event = $this->getEntityManager()->getEntity($eventType, $eventId);
         $invitee = $this->getEntityManager()->getEntity($inviteeType, $inviteeId);
         if ($event && $invitee) {
             $relDefs = $event->getRelations();
             $tableName = Util::toUnderscore($relDefs[$link]['relationName']);
             $status = 'None';
             if ($action == 'accept') {
                 $status = 'Accepted';
             } else {
                 if ($action == 'decline') {
                     $status = 'Declined';
                 } else {
                     if ($action == 'tentative') {
                         $status = 'Tentative';
                     }
                 }
             }
             $pdo = $this->getEntityManager()->getPDO();
             $sql = "\n                    UPDATE `{$tableName}` SET status = '{$status}'\n                    WHERE " . strtolower($eventType) . "_id = '{$eventId}' AND " . strtolower($inviteeType) . "_id = '{$inviteeId}'\n                ";
             $sth = $pdo->prepare($sql);
             $sth->execute();
             $this->getEntityManager()->getRepository('UniqueId')->remove($uniqueId);
             echo $status;
             return;
         }
     }
     throw new Error();
 }
开发者ID:mehulsbhatt,项目名称:espocrm,代码行数:50,代码来源:EventConfirmation.php

示例13: load

 protected function load($fieldName, $entityName)
 {
     $converedFieldName = $fieldName . 'Converted';
     $currencyColumnName = Util::toUnderScore($fieldName);
     $alias = Util::toUnderScore($fieldName) . "_currency_alias";
     $d = array($entityName => array('fields' => array($fieldName => array("type" => "float", "orderBy" => $converedFieldName . " {direction}"))));
     $params = $this->getFieldParams($fieldName);
     if (!empty($params['notStorable'])) {
         $d[$entityName]['fields'][$fieldName]['notStorable'] = true;
     } else {
         $d[$entityName]['fields'][$fieldName . 'Converted'] = array('type' => 'float', 'select' => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate", 'where' => array("=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate = {value}", ">" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate > {value}", "<" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate < {value}", ">=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate >= {value}", "<=" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <= {value}", "<>" => Util::toUnderScore($entityName) . "." . $currencyColumnName . " * {$alias}.rate <> {value}"), 'notStorable' => true, 'orderBy' => $converedFieldName . " {direction}");
     }
     return $d;
 }
开发者ID:disearth,项目名称:espocrm,代码行数:14,代码来源:Currency.php

示例14: restoreFiles

 protected function restoreFiles()
 {
     $GLOBALS['log']->info('Installer: Restore previous files.');
     $backupPath = $this->getPath('backupPath');
     $backupFilePath = Util::concatPath($backupPath, self::FILES);
     $backupFileList = $this->getRestoreFileList();
     $copyFileList = $this->getCopyFileList();
     $deleteFileList = array_diff($copyFileList, $backupFileList);
     $res = $this->copy($backupFilePath, '', true);
     $res &= $this->getFileManager()->remove($deleteFileList, null, true);
     if ($res) {
         $this->getFileManager()->removeInDir($backupPath, true);
     }
     return $res;
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:15,代码来源:Install.php

示例15: create

 public function create($entityName)
 {
     $className = '\\Espo\\Custom\\SelectManagers\\' . Util::normilizeClassName($entityName);
     if (!class_exists($className)) {
         $moduleName = $this->metadata->getScopeModuleName($entityName);
         if ($moduleName) {
             $className = '\\Espo\\Modules\\' . $moduleName . '\\SelectManagers\\' . Util::normilizeClassName($entityName);
         } else {
             $className = '\\Espo\\SelectManagers\\' . Util::normilizeClassName($entityName);
         }
         if (!class_exists($className)) {
             $className = '\\Espo\\Core\\SelectManagers\\Base';
         }
     }
     $selectManager = new $className($this->entityManager, $this->user, $this->acl, $this->metadata);
     $selectManager->setEntityName($entityName);
     return $selectManager;
 }
开发者ID:jdavis593,项目名称:appitechture,代码行数:18,代码来源:SelectManagerFactory.php


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