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


PHP Util::unsetInArray方法代码示例

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


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

示例1: correctFields

 /**
  * Correct fields defenitions based on \Espo\Custom\Core\Utils\Database\Orm\Fields
  *
  * @param  array  $ormMeta
  *
  * @return array
  */
 protected function correctFields($entityName, array $ormMeta)
 {
     $entityDefs = $this->getEntityDefs();
     $entityMeta = $ormMeta[$entityName];
     //load custom field definitions and customCodes
     foreach ($entityMeta['fields'] as $fieldName => $fieldParams) {
         if (empty($fieldParams['type'])) {
             continue;
         }
         $fieldType = ucfirst($fieldParams['type']);
         $className = '\\Espo\\Custom\\Core\\Utils\\Database\\Orm\\Fields\\' . $fieldType;
         if (!class_exists($className)) {
             $className = '\\Espo\\Core\\Utils\\Database\\Orm\\Fields\\' . $fieldType;
         }
         if (class_exists($className) && method_exists($className, 'load')) {
             $helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
             $fieldResult = $helperClass->process($fieldName, $entityName);
             if (isset($fieldResult['unset'])) {
                 $ormMeta = Util::unsetInArray($ormMeta, $fieldResult['unset']);
                 unset($fieldResult['unset']);
             }
             $ormMeta = Util::merge($ormMeta, $fieldResult);
         }
     }
     //todo move to separate file
     //add a field 'isFollowed' for scopes with 'stream => true'
     $scopeDefs = $this->getMetadata()->get('scopes.' . $entityName);
     if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
         if (!isset($entityMeta['fields']['isFollowed'])) {
             $ormMeta[$entityName]['fields']['isFollowed'] = array('type' => 'varchar', 'notStorable' => true);
             $ormMeta[$entityName]['fields']['followersIds'] = array('type' => 'jsonArray', 'notStorable' => true);
             $ormMeta[$entityName]['fields']['followersNames'] = array('type' => 'jsonObject', 'notStorable' => true);
         }
     }
     //END: add a field 'isFollowed' for stream => true
     return $ormMeta;
 }
开发者ID:disearth,项目名称:espocrm,代码行数:44,代码来源:Converter.php

示例2: testUnsetInArrayByString

 public function testUnsetInArrayByString()
 {
     $input = array('Account' => array('useCache' => true), 'Contact' => array('useCache' => true));
     $unsets = 'Account.useCache';
     $result = array('Account' => array(), 'Contact' => array('useCache' => true));
     $this->assertEquals($result, Util::unsetInArray($input, $unsets));
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:7,代码来源:UtilTest.php

示例3: unsetContents

 /**
  * Unset some element of content data
  *
  * @param  string | array $path
  * @param  array | string $unsets
  * @return bool
  */
 public function unsetContents($path, $unsets, $isJSON = true)
 {
     $currentData = $this->getContents($path);
     if ($currentData == false) {
         $GLOBALS['log']->notice('FileManager::unsetContents: File [' . $this->concatPaths($path) . '] does not exist.');
         return false;
     }
     $currentDataArray = Utils\Json::getArrayData($currentData);
     $unsettedData = Utils\Util::unsetInArray($currentDataArray, $unsets, true);
     if (is_null($unsettedData) || is_array($unsettedData) && empty($unsettedData)) {
         $fullPath = $this->concatPaths($path);
         return $this->unlink($fullPath);
     }
     if ($isJSON) {
         return $this->putContentsJson($path, $unsettedData);
     }
     return $this->putContents($path, $unsettedData);
 }
开发者ID:mehulsbhatt,项目名称:espocrm,代码行数:25,代码来源:Manager.php

示例4: delete

 /**
  * Unset some fields and other stuff in metadat
  *
  * @param  string $key1
  * @param  string $key2
  * @param  array | string $unsets Ex. 'fields.name'
  *
  * @return bool
  */
 public function delete($key1, $key2, $unsets)
 {
     if (!is_array($unsets)) {
         $unsets = (array) $unsets;
     }
     $normalizedData = array('__APPEND__');
     $metaUnsetData = array();
     foreach ($unsets as $unsetItem) {
         $normalizedData[] = $unsetItem;
         $metaUnsetData[] = implode('.', array($key1, $key2, $unsetItem));
     }
     $unsetData = array($key1 => array($key2 => $normalizedData));
     $this->deletedData = Util::merge($this->deletedData, $unsetData);
     $this->deletedData = Util::unsetInArrayByValue('__APPEND__', $this->deletedData);
     $this->meta = Util::unsetInArray($this->getData(), $metaUnsetData);
 }
开发者ID:naushrambo,项目名称:espocrm,代码行数:25,代码来源:Metadata.php

示例5: unifySingle

 /**
  * Unite file content to the file for one directory [NOW ONLY FOR METADATA, NEED TO CHECK FOR LAYOUTS AND OTHERS]
  *
  * @param string $dirPath
  * @param string $type - name of type array("metadata", "layouts"), ex. $this->name
  * @param bool $recursively - Note: only for first level of sub directory, other levels of sub directories will be ignored
  * @param string $moduleName - name of module if exists
  *
  * @return string - content of the files
  */
 protected function unifySingle($dirPath, $type, $recursively = false, $moduleName = '')
 {
     if (empty($dirPath) || !file_exists($dirPath)) {
         return false;
     }
     $unsetFileName = $this->params['unsetFileName'];
     //get matadata files
     $fileList = $this->getFileManager()->getFileList($dirPath, $recursively, '\\.json$');
     $dirName = $this->getFileManager()->getDirName($dirPath, false);
     $defaultValues = $this->loadDefaultValues($dirName, $type);
     $content = array();
     $unsets = array();
     foreach ($fileList as $dirName => $fileName) {
         if (is_array($fileName)) {
             /*get content from files in a sub directory*/
             $content[$dirName] = $this->unifySingle(Utils\Util::concatPath($dirPath, $dirName), $type, false, $moduleName);
             //only first level of a sub directory
         } else {
             /*get content from a single file*/
             if ($fileName == $unsetFileName) {
                 $fileContent = $this->getFileManager()->getContents(array($dirPath, $fileName));
                 $unsets = Utils\Json::getArrayData($fileContent);
                 continue;
             }
             /*END: Save data from unset.json*/
             $mergedValues = $this->unifyGetContents(array($dirPath, $fileName), $defaultValues);
             if (!empty($mergedValues)) {
                 $name = $this->getFileManager()->getFileName($fileName, '.json');
                 $content[$name] = $mergedValues;
             }
         }
     }
     //unset content
     $content = Utils\Util::unsetInArray($content, $unsets);
     //END: unset content
     return $content;
 }
开发者ID:disearth,项目名称:espocrm,代码行数:47,代码来源:Unifier.php

示例6: process

 /**
  * Schema convertation process
  *
  * @param  array  $ormMeta
  * @param  array|null $entityList
  *
  * @return \Doctrine\DBAL\Schema\Schema
  */
 public function process(array $ormMeta, $entityList = null)
 {
     $GLOBALS['log']->debug('Schema\\Converter - Start: building schema');
     //check if exist files in "Tables" directory and merge with ormMetadata
     $ormMeta = Util::merge($ormMeta, $this->getCustomTables($ormMeta));
     //unset some keys in orm
     if (isset($ormMeta['unset'])) {
         $ormMeta = Util::unsetInArray($ormMeta, $ormMeta['unset']);
         unset($ormMeta['unset']);
     }
     //END: unset some keys in orm
     if (isset($entityList)) {
         $entityList = is_string($entityList) ? (array) $entityList : $entityList;
         $dependentEntities = $this->getDependentEntities($entityList, $ormMeta);
         $GLOBALS['log']->debug('Rebuild Database for entities: [' . implode(', ', $entityList) . '] with dependent entities: [' . implode(', ', $dependentEntities) . ']');
         $ormMeta = array_intersect_key($ormMeta, array_flip($dependentEntities));
     }
     $schema = $this->getSchema(true);
     $tables = array();
     foreach ($ormMeta as $entityName => $entityParams) {
         $tableName = Util::toUnderScore($entityName);
         if ($schema->hasTable($tableName)) {
             if (!isset($tables[$entityName])) {
                 $tables[$entityName] = $schema->getTable($tableName);
             }
             $GLOBALS['log']->debug('DBAL: Table [' . $tableName . '] exists.');
             continue;
         }
         $tables[$entityName] = $schema->createTable($tableName);
         $primaryColumns = array();
         $uniqueColumns = array();
         $indexList = array();
         //list of indexes like array( array(comlumn1, column2), array(column3))
         foreach ($entityParams['fields'] as $fieldName => $fieldParams) {
             if (isset($fieldParams['notStorable']) && $fieldParams['notStorable'] || in_array($fieldParams['type'], $this->notStorableTypes)) {
                 continue;
             }
             switch ($fieldParams['type']) {
                 case 'id':
                     $primaryColumns[] = Util::toUnderScore($fieldName);
                     break;
             }
             $fieldType = isset($fieldParams['dbType']) ? $fieldParams['dbType'] : $fieldParams['type'];
             $fieldType = strtolower($fieldType);
             /** doctrine uses strtolower for all field types */
             if (!in_array($fieldType, $this->typeList)) {
                 $GLOBALS['log']->debug('Converters\\Schema::process(): Field type [' . $fieldType . '] does not exist ' . $entityName . ':' . $fieldName);
                 continue;
             }
             $columnName = Util::toUnderScore($fieldName);
             if (!$tables[$entityName]->hasColumn($columnName)) {
                 $tables[$entityName]->addColumn($columnName, $fieldType, $this->getDbFieldParams($fieldParams));
             }
             //add unique
             if ($fieldParams['type'] != 'id' && isset($fieldParams['unique'])) {
                 $uniqueColumns = $this->getKeyList($columnName, $fieldParams['unique'], $uniqueColumns);
             }
             //END: add unique
             //add index. It can be defined in entityDefs as "index"
             if (isset($fieldParams['index'])) {
                 $indexList = $this->getKeyList($columnName, $fieldParams['index'], $indexList);
             }
             //END: add index
         }
         $tables[$entityName]->setPrimaryKey($primaryColumns);
         //add indexes
         if (isset($entityParams['indexes']) && is_array($entityParams['indexes'])) {
             foreach ($entityParams['indexes'] as $indexName => $indexParams) {
                 if (is_array($indexParams['columns'])) {
                     $tableIndexName = $this->generateIndexName($indexName, $entityName);
                     $indexList[$tableIndexName] = Util::toUnderScore($indexParams['columns']);
                 }
             }
         }
         if (!empty($indexList)) {
             foreach ($indexList as $indexName => $indexItem) {
                 $tableIndexName = is_string($indexName) ? $indexName : null;
                 $tables[$entityName]->addIndex($indexItem, $tableIndexName);
             }
         }
         if (!empty($uniqueColumns)) {
             foreach ($uniqueColumns as $uniqueItem) {
                 $tables[$entityName]->addUniqueIndex($uniqueItem);
             }
         }
     }
     //check and create columns/tables for relations
     foreach ($ormMeta as $entityName => $entityParams) {
         if (!isset($entityParams['relations'])) {
             continue;
         }
         foreach ($entityParams['relations'] as $relationName => $relationParams) {
//.........这里部分代码省略.........
开发者ID:mehulsbhatt,项目名称:espocrm,代码行数:101,代码来源:Converter.php

示例7: afterProcess

 public function afterProcess(array $ormMeta)
 {
     $entityDefs = $this->getEntityDefs();
     //load custom field definitions and customCodes
     foreach ($ormMeta as $entityName => &$entityParams) {
         foreach ($entityParams['fields'] as $fieldName => $fieldParams) {
             //load custom field definitions
             $fieldType = ucfirst($fieldParams['type']);
             $className = '\\Espo\\Custom\\Core\\Utils\\Database\\Orm\\Fields\\' . $fieldType;
             if (!class_exists($className)) {
                 $className = '\\Espo\\Core\\Utils\\Database\\Orm\\Fields\\' . $fieldType;
             }
             if (class_exists($className) && method_exists($className, 'load')) {
                 $helperClass = new $className($this->metadata, $ormMeta, $entityDefs);
                 $fieldResult = $helperClass->process($fieldName, $entityName);
                 if (isset($fieldResult['unset'])) {
                     $ormMeta = Util::unsetInArray($ormMeta, $fieldResult['unset']);
                     unset($fieldResult['unset']);
                 }
                 $ormMeta = Util::merge($ormMeta, $fieldResult);
             }
             //END: load custom field definitions
             //todo move to separate file
             //add a field 'isFollowed' for scopes with 'stream => true'
             $scopeDefs = $this->getMetadata()->get('scopes.' . $entityName);
             if (isset($scopeDefs['stream']) && $scopeDefs['stream']) {
                 if (!isset($entityParams['fields']['isFollowed'])) {
                     $entityParams['fields']['isFollowed'] = array('type' => 'varchar', 'notStorable' => true);
                 }
             }
             //END: add a field 'isFollowed' for stream => true
         }
     }
     foreach ($ormMeta as $entityName => &$entityParams) {
         foreach ($entityParams['fields'] as $fieldName => &$fieldParams) {
             switch ($fieldParams['type']) {
                 case 'id':
                     if ($fieldParams['dbType'] != 'int') {
                         $fieldParams = array_merge($fieldParams, $this->idParams);
                     }
                     break;
                 case 'foreignId':
                     $fieldParams = array_merge($fieldParams, $this->idParams);
                     $fieldParams['notNull'] = false;
                     break;
                 case 'foreignType':
                     $fieldParams['dbType'] = Entity::VARCHAR;
                     $fieldParams['len'] = $this->defaultLength['varchar'];
                     break;
                 case 'bool':
                     $fieldParams['default'] = isset($fieldParams['default']) ? (bool) $fieldParams['default'] : $this->defaultValue['bool'];
                     break;
             }
         }
     }
     return $ormMeta;
 }
开发者ID:jdavis593,项目名称:appitechture,代码行数:57,代码来源:Converter.php


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