本文整理汇总了PHP中Espo\Core\Utils\Util类的典型用法代码示例。如果您正苦于以下问题:PHP Util类的具体用法?PHP Util怎么用?PHP Util使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Util类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: unify
/**
* Unite files content
*
* @param array $paths
* @param bool $isReturnModuleNames - If need to return data with module names
*
* @return array
*/
public function unify(array $paths, $isReturnModuleNames = false)
{
$data = $this->loadData($paths['corePath']);
if (!empty($paths['modulePath'])) {
$moduleDir = strstr($paths['modulePath'], '{*}', true);
$moduleList = isset($this->metadata) ? $this->getMetadata()->getModuleList() : $this->getFileManager()->getFileList($moduleDir, false, '', false);
foreach ($moduleList as $moduleName) {
$moduleFilePath = str_replace('{*}', $moduleName, $paths['modulePath']);
if ($isReturnModuleNames) {
if (!isset($data[$moduleName])) {
$data[$moduleName] = array();
}
$data[$moduleName] = Util::merge($data[$moduleName], $this->loadData($moduleFilePath));
continue;
}
$data = Util::merge($data, $this->loadData($moduleFilePath));
}
}
if (!empty($paths['customPath'])) {
$data = Util::merge($data, $this->loadData($paths['customPath']));
}
return $data;
}
开发者ID:disearth,项目名称:espocrm,代码行数:31,代码来源:FileUnifier.php
示例17: load
protected function load($fieldName, $entityName)
{
return array($entityName => array('fields' => array($fieldName => array('select' => 'phone_number.name', 'where' => array('LIKE' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (\n\t\t\t\t\t\t\t\tSELECT entity_id \n\t\t\t\t\t\t\t\tFROM entity_phone_number\n\t\t\t\t\t\t\t\tJOIN phone_number ON phone_number.id = entity_phone_number.phone_number_id\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\tentity_phone_number.deleted = 0 AND entity_phone_number.entity_type = '{$entityName}' AND\n\t\t\t\t\t\t\t\t\tphone_number.deleted = 0 AND phone_number.name LIKE '{text}' \t\t\n\t\t\t\t\t\t\t)", '=' => \Espo\Core\Utils\Util::toUnderScore($entityName) . ".id IN (\n\t\t\t\t\t\t\t\tSELECT entity_id \n\t\t\t\t\t\t\t\tFROM entity_phone_number\n\t\t\t\t\t\t\t\tJOIN phone_number ON phone_number.id = entity_phone_number.phone_number_id\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\tentity_phone_number.deleted = 0 AND entity_phone_number.entity_type = '{$entityName}' AND\n\t\t\t\t\t\t\t\t\tphone_number.deleted = 0 AND phone_number.name = '{text}' \t\t\n\t\t\t\t\t\t\t)"), 'orderBy' => 'phone_number.name {direction}'), $fieldName . 'Data' => array('type' => 'text', 'notStorable' => true)), 'relations' => array($fieldName . 's' => array('type' => 'manyMany', 'entity' => 'PhoneNumber', 'relationName' => 'entityPhoneNumber', 'midKeys' => array('entity_id', 'phone_number_id'), 'conditions' => array('entityType' => $entityName), 'additionalColumns' => array('entityType' => array('type' => 'varchar', 'len' => 100), 'primary' => array('type' => 'bool', 'default' => false))))));
}
开发者ID:jdavis593,项目名称:appitechture,代码行数:4,代码来源:Phone.php
示例18: getHookData
/**
* Get and merge hook data by checking the files exist in $hookDirs
*
* @param array $hookDirs - it can be an array('Espo/Hooks', 'Espo/Custom/Hooks', 'Espo/Modules/Crm/Hooks')
*
* @return array
*/
protected function getHookData($hookDirs)
{
if (is_string($hookDirs)) {
$hookDirs = (array) $hookDirs;
}
$hooks = array();
foreach ($hookDirs as $hookDir) {
if (file_exists($hookDir)) {
$fileList = $this->getFileManager()->getFileList($hookDir, 1, '\\.php$', 'file');
foreach ($fileList as $scopeName => $hookFiles) {
$hookScopeDirPath = Util::concatPath($hookDir, $scopeName);
$scopeHooks = array();
foreach ($hookFiles as $hookFile) {
$hookFilePath = Util::concatPath($hookScopeDirPath, $hookFile);
$className = Util::getClassName($hookFilePath);
foreach ($this->hookList as $hookName) {
if (method_exists($className, $hookName)) {
$scopeHooks[$hookName][$className::$order][] = $className;
}
}
}
//sort hooks by order
foreach ($scopeHooks as $hookName => $hookList) {
ksort($hookList);
$sortedHookList = array();
foreach ($hookList as $hookDetails) {
$sortedHookList = array_merge($sortedHookList, $hookDetails);
}
$hooks[$scopeName][$hookName] = isset($hooks[$scopeName][$hookName]) ? array_merge($hooks[$scopeName][$hookName], $sortedHookList) : $sortedHookList;
}
}
}
}
return $hooks;
}
开发者ID:jdavis593,项目名称:appitechture,代码行数:42,代码来源:HookManager.php
示例19: testUnsetInArrayByValueWithoutReindex
public function testUnsetInArrayByValueWithoutReindex()
{
$newArray = json_decode('[
"__APPEND__",
{
"name":"populating",
"label":"Populating",
"view":"Advanced:TargetList.Record.Panels.Populating"
}
]', true);
$result = json_decode('{
"1": {
"name": "populating",
"label": "Populating",
"view": "Advanced:TargetList.Record.Panels.Populating"
}
}', true);
$this->assertEquals($result, Util::unsetInArrayByValue('__APPEND__', $newArray, false));
}
开发者ID:naushrambo,项目名称:espocrm,代码行数:19,代码来源:UtilTest.php
示例20: getInitValues
protected function getInitValues(array $fieldParams)
{
$values = array();
foreach ($this->fieldAccordances as $espoType => $ormType) {
if (isset($fieldParams[$espoType])) {
if (is_array($ormType)) {
$conditionRes = false;
if (!is_array($fieldParams[$espoType])) {
$conditionRes = preg_match('/' . $ormType['condition'] . '/i', $fieldParams[$espoType]);
}
if (!$conditionRes || $conditionRes && $conditionRes === $ormType['conditionEquals']) {
$value = is_array($fieldParams[$espoType]) ? json_encode($fieldParams[$espoType]) : $fieldParams[$espoType];
$values = Util::merge($values, Util::replaceInArray('{0}', $value, $ormType['value']));
}
} else {
$values[$ormType] = $fieldParams[$espoType];
}
}
}
return $values;
}
开发者ID:disearth,项目名称:espocrm,代码行数:21,代码来源:Converter.php
注:本文中的Espo\Core\Utils\Util类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论