本文整理汇总了PHP中CoreUtils::checkConstraint方法的典型用法代码示例。如果您正苦于以下问题:PHP CoreUtils::checkConstraint方法的具体用法?PHP CoreUtils::checkConstraint怎么用?PHP CoreUtils::checkConstraint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoreUtils
的用法示例。
在下文中一共展示了CoreUtils::checkConstraint方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initParams
protected function initParams(&$params)
{
CoreUtils::checkConstraint(is_null($params) || is_array($params));
if (!empty($params)) {
$this->params = $params;
} else {
$this->params = array();
}
}
示例2: getChildrenCount
public function getChildrenCount(&$record)
{
CoreUtils::checkConstraint(!empty($record['id']));
$db = CoreServices2::getDB();
$sql = '
SELECT COUNT(*) AS num
FROM subpage
WHERE
subpageParentId = ' . $db->prepareInputValue($record['id']);
$row = $db->getRow($sql);
return $row['num'];
}
示例3: addDynamicImageInfo
protected function addDynamicImageInfo(&$imageData)
{
if (count($imageData) < 4 || count($imageData) > 7) {
throw new CoreException('Invalid number of arguments supplied for image from database in email template!');
}
$image = $fileDAO->getRecordById($imageData[1]);
CoreUtils::checkConstraint(!empty($image['id']));
$fullName = $image['fileBaseName'] . '.' . $image['fileExtension'];
$options = $this->getDynamicImageOptions($imageData);
$resizedImagePath = $files->getResizedImageDiskPath($image['fileBaseName'], $image['fileExtension'], $options);
if (!file_exists($resizedImagePath)) {
$imagePath = $files->getDiskPath($image['fileBaseName'], $image['fileExtension']);
$files->resizeImage($resizedImagePath, $image['fileBaseName'], $image['fileExtension'], $options);
}
$this->attachments[] = array('cid' => $cid, 'fileName' => $fullName, 'filePath' => $resizedImagePath, 'mimeType' => $image['fileMimeType']);
}
示例4: decodePHPUploadError
protected function decodePHPUploadError($errorCode)
{
CoreUtils::checkConstraint($errorCode != UPLOAD_ERR_OK);
switch ($errorCode) {
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
return 'fileTooBig';
case UPLOAD_ERR_PARTIAL:
return 'fileUploadedPartially';
case UPLOAD_ERR_NO_FILE:
return 'fileNotUploaded';
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_EXTENSION:
default:
return 'fileUploadUnknownError';
}
}
示例5: checkDataConsistency
protected function checkDataConsistency()
{
$attachmentTypes = CoreConfig::get('FileUpload', 'swfUploadAttachmentTypes');
$fileCategory = $this->fileRecord['fileCategory'];
$recordType = $this->fileRecord['recordType'];
if ($recordType == '_tmpRecord') {
return;
}
$filePosition = $this->fileRecord['filePosition'];
CoreUtils::checkConstraint(is_array($attachmentTypes[$recordType][$filePosition]));
$minItems = $attachmentTypes[$recordType][$filePosition]['minItems'];
if (!empty($minItems)) {
$currentItems = $this->fileDAO->getCountByRecord($recordType, $this->baseRecord['id'], $fileCategory, $filePosition);
if ($currentItems - 1 < $minItems) {
$this->messageManager->addMessage('fileDeleteErrorTooFewAttachments');
return;
}
}
}
示例6: save
public function save(&$record, &$uploadStruct = null)
{
CoreUtils::checkConstraint(!empty($uploadStruct) || !empty($record['id']));
if (!empty($uploadStruct)) {
$this->saveDiskFile($record, $uploadStruct, $record['fileCategory']);
}
if (empty($record['fileOrder'])) {
$record['fileOrder'] = 0;
}
parent::save($record);
}
示例7: checkSWFUploadLists
protected function checkSWFUploadLists()
{
CoreUtils::checkConstraint(!empty($this->errorMessageContainer));
foreach ($this->swfAttachmentTypes as $listName => $listInfo) {
if ($listInfo['minItems'] > 0 && sizeof($this->fileListOldValues[$listName]) < $listInfo['minItems']) {
$this->errorMessageContainer->addMessage('errorTooFewItems_' . $listName);
}
}
}
开发者ID:piotrPiechura,项目名称:3dPathProject,代码行数:9,代码来源:CMSAbstractControllerEditWithFileUpload.class.php
示例8: prepareData
protected function prepareData()
{
CoreUtils::checkConstraint(!empty($this->params['userRecord']['userEmail']));
}
示例9: checkTypeAndGetExtension
public function checkTypeAndGetExtension($uploadStruct, $fileCategory)
{
CoreUtils::checkConstraint(is_array($uploadStruct));
$allowedMimeTypes = CoreConfig::get('CoreFiles', 'allowedMimeTypes');
$defaultExtensions = CoreConfig::get('CoreFiles', 'defaultExtensions');
$mimeType = mime_content_type($uploadStruct['tmp_name']);
if (!array_key_exists($mimeType, $defaultExtensions) || !array_key_exists($fileCategory, $allowedMimeTypes) || !in_array($mimeType, $allowedMimeTypes[$fileCategory])) {
return null;
}
return $defaultExtensions[$mimeType];
}
示例10: getPatternArray
protected function getPatternArray($pattern)
{
$patternLength = strlen($pattern);
$patternArray = array();
$patternArrayIndex = 0;
for ($i = 0; $i < $patternLength; $i++) {
if ($pattern[$i] == '<') {
$patternArrayIndex++;
$patternArray[$patternArrayIndex] = array('column', '');
} elseif ($pattern[$i] == '>') {
$patternArrayIndex++;
$patternArray[$patternArrayIndex] = array('text', '');
} else {
CoreUtils::checkConstraint(isset($patternArray[$patternArrayIndex][1]));
$patternArray[$patternArrayIndex][1] .= $pattern[$i];
}
}
return $patternArray;
}
示例11: setMessage
protected function setMessage($recordId, $message)
{
CoreUtils::checkConstraint(!empty($recordId));
$this->messages[$recordId] = !empty($message) ? $message : false;
CoreUtils::checkConstraint(isset($this->messages[$recordId]));
}
示例12: checkDataConsistency
protected function checkDataConsistency()
{
$attachmentTypes = CoreConfig::get('FileUpload', 'swfUploadAttachmentTypes');
$fileCategory = $this->form->getField('fileCategory')->getValue();
$recordType = $this->form->getField('recordType')->getValue();
CoreUtils::checkConstraint($recordType != '_tmpRecord');
$filePosition = $this->form->getField('filePosition')->getValue();
$record = $this->getBaseRecord();
if (empty($record)) {
$this->messageManager->addMessage('fileUploadErrorInvalidBaseRecordId');
return;
}
if (!$this->hasUserPermissionsForRecord($recordType, $record)) {
$this->messageManager->addMessage('fileUploadErrorNoPermission');
return;
}
if (!array_key_exists($recordType, $attachmentTypes)) {
$this->messageManager->addMessage('fileUploadErrorInvalidRecordType');
return;
}
if (!array_key_exists($filePosition, $attachmentTypes[$recordType])) {
$this->messageManager->addMessage('fileUploadErrorInvalidFilePosition');
return;
}
if ($fileCategory != $attachmentTypes[$recordType][$filePosition]['fileCategory']) {
$this->messageManager->addMessage('fileUploadErrorWrongCategory');
return;
}
$maxItems = $attachmentTypes[$recordType][$filePosition]['maxItems'];
if (!empty($maxItems)) {
$currentItems = $this->fileDAO->getCountByRecord($recordType, $record['id'], $fileCategory, $filePosition);
if ($currentItems + 1 > $maxItems) {
$this->messageManager->addMessage('fileUploadErrorTooManyAttachments');
return;
}
}
}