本文整理汇总了PHP中XLite\Core\Converter::isEmptyString方法的典型用法代码示例。如果您正苦于以下问题:PHP Converter::isEmptyString方法的具体用法?PHP Converter::isEmptyString怎么用?PHP Converter::isEmptyString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite\Core\Converter
的用法示例。
在下文中一共展示了Converter::isEmptyString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate
/**
* Validate
*
* @param mixed $data Data
*
* @return void
*/
public function validate($data)
{
parent::validate($data);
if (!\XLite\Core\Converter::isEmptyString($data)) {
$entity = \XLite\Core\Database::getRepo('XLite\\Module\\XC\\ProductVariants\\Model\\ProductVariant')->findOneBySku($this->sanitize($data));
if ($entity) {
$this->throwVariantSKUError();
}
}
}
示例2: validate
/**
* Validate
*
* @param mixed $data Data
*
* @return void
*/
public function validate($data)
{
if (!\XLite\Core\Converter::isEmptyString($data)) {
$entity = \XLite\Core\Database::getRepo('XLite\\Model\\Product')->findOneBySku($this->sanitize($data));
// DO NOT use "!==" here
if ($entity && (empty($this->productId) || $entity->getProductId() != $this->productId)) {
$this->throwSKUError();
}
}
}
示例3: validate
/**
* Validate
*
* @param mixed $data Data
*
* @return void
*/
public function validate($data)
{
if (!\XLite\Core\Converter::isEmptyString($data)) {
$entity = \XLite\Core\Database::getRepo($this->fieldClass)->findOneBy(array($this->fieldName => $this->sanitize($data)));
// DO NOT use "!==" here
if ($entity && (empty($this->fieldValue) || $entity->{'get' . \XLite\Core\Converter::convertToCamelCase($this->fieldName)}() != $this->fieldValue)) {
$this->throwSKUError();
}
}
}
示例4: validate
/**
* Validate
*
* @param mixed $data Data
*
* @return void
* @throws \XLite\Core\Validator\Exception
*/
public function validate($data)
{
if (!\XLite\Core\Converter::isEmptyString($data)) {
parent::validate($data);
$entity = \XLite\Core\Database::getRepo($this->class)->findOneByCleanURL($this->sanitize($data));
// DO NOT use "!==" here
if ($entity && (empty($this->id) || $entity->getUniqueIdentifier() != $this->id)) {
$this->throwCleanURLError();
}
}
}
示例5: validate
/**
* Validate
*
* @param mixed $data Data
*
* @return void
* @throws \XLite\Core\Validator\Exception
*/
public function validate($data)
{
$data = $this->sanitize($data);
if (!\XLite\Core\Converter::isEmptyString($data)) {
parent::validate($data);
/** @var \XLite\Model\Repo\CleanURL $repo */
$repo = \XLite\Core\Database::getRepo('XLite\\Model\\CleanURL');
$postedData = \XLite\Core\Request::getInstance()->postedData;
if (!isset($postedData['forceCleanURL']) && !$repo->isURLUnique($data, $this->class, $this->id)) {
$this->throwCleanURLError($data);
}
}
}
示例6: prepareBeforeSave
/**
* Lifecycle callback
*
* @return void
* @see ____func_see____
* @since 1.0.24
*
* @PrePersist
* @PreUpdate
*/
public function prepareBeforeSave()
{
if (\XLite\Core\Converter::isEmptyString($this->getCleanURL())) {
$this->setCleanURL(null);
}
}
示例7: updateCleanURL
/**
* Update cleanURL
*
* @param \XLite\Model\AEntity $model Model
* @param string $value Value
*
* @return void
*/
protected function updateCleanURL(\XLite\Model\AEntity $model, $value)
{
if (!\XLite\Core\Converter::isEmptyString($value)) {
$validator = new \XLite\Core\Validator\String\CleanURL(false, null, get_class($model), $model->getId());
try {
$validator->validate($value);
$model->setCleanURL($value);
} catch (\XLite\Core\Validator\Exception $exception) {
}
} else {
$model->setCleanURL(null);
}
}
示例8: getPostedData
/**
* Get posted data
*
* @param string $field Name of the field to retrieve OPTIONAL
*
* @return mixed
*/
protected function getPostedData($field = null)
{
$value = parent::getPostedData($field);
$time = \XLite\Core\Converter::time();
if (!isset($field)) {
if (isset($value['arrivalDate'])) {
$value['arrivalDate'] = intval(strtotime($value['arrivalDate'])) ?: mktime(0, 0, 0, date('m', $time), date('j', $time), date('Y', $time));
}
if (isset($value['sku']) && \XLite\Core\Converter::isEmptyString($value['sku'])) {
$value['sku'] = null;
}
if (isset($value['productClass'])) {
$value['productClass'] = \XLite\Core\Database::getRepo('\\XLite\\Model\\ProductClass')->find($value['productClass']);
}
if (isset($value['taxClass'])) {
$value['taxClass'] = \XLite\Core\Database::getRepo('\\XLite\\Model\\TaxClass')->find($value['taxClass']);
}
} elseif ('arrivalDate' === $field) {
$value = intval(strtotime($value)) ?: mktime(0, 0, 0, date('m', $time), date('j', $time), date('Y', $time));
} elseif ('sku' === $field) {
$value = null;
} elseif ('productClass' === $field) {
$value = \XLite\Core\Database::getRepo('\\XLite\\Model\\ProductClass')->find($value);
} elseif ('taxClass' === $field) {
$value = \XLite\Core\Database::getRepo('\\XLite\\Model\\TaxClass')->find($value);
}
return $value;
}
示例9: prepareBeforeUpdate
/**
* Prepare update date
*
* @return void
*
* @PreUpdate
*/
public function prepareBeforeUpdate()
{
$this->setUpdateDate(\XLite\Core\Converter::time());
if (\XLite\Core\Converter::isEmptyString($this->getSku())) {
$this->setSKU(null);
}
}
示例10: generateCleanURL
/**
* Generate clean URL
*
* @param \XLite\Model\Product $model Product
* @param string $value Value OPTIONAL
*
* @return void
*/
protected function generateCleanURL(\XLite\Model\Product $model, $value = '')
{
if (\XLite\Core\Converter::isEmptyString($value)) {
if (!\XLite\Core\Converter::isEmptyString($this->currentRowData['name'])) {
// Input cleanURL value is empty, trying to get product name from current row data
$lngCodes = array_unique(array('en', $this->importer->getLanguageCode()));
foreach ($lngCodes as $code) {
if (!empty($this->currentRowData['name'][$code])) {
$value = $this->currentRowData['name'][$code];
break;
}
}
}
if (\XLite\Core\Converter::isEmptyString($value)) {
// Try to get value from current product name
$value = $model->getName();
}
} else {
$value = preg_replace('/\\.html$/', '', $value);
}
/** @var \XLite\Model\Repo\CleanURL $repo */
$repo = \XLite\Core\Database::getRepo('XLite\\Model\\CleanURL');
$value = $repo->generateCleanURL($model, $value);
if (!\XLite\Core\Converter::isEmptyString($value)) {
$this->updateCleanURL($model, $value);
}
}
示例11: normalizeGroupValue
/**
* Normalize 'group' value
*
* @param mixed @value Value
*
* @return \XLite\Model\AttributeGroup
*/
protected function normalizeGroupValue($value)
{
if (!\XLite\Core\Converter::isEmptyString($this->currentRowData['class'])) {
$className = $this->getDefLangValue($this->currentRowData['class']);
$productClass = \XLite\Core\Database::getRepo('XLite\\Model\\ProductClass')->findOneByName($className);
} else {
$productClass = null;
}
return $this->normalizeValueAsAttributeGroup($value, $productClass);
}
示例12: getPostedData
/**
* Get posted data
*
* @param string $field Name of the field to retrieve OPTIONAL
*
* @return mixed
*/
protected function getPostedData($field = null)
{
$value = parent::getPostedData($field);
if (!isset($field)) {
if (isset($value['arrivalDate'])) {
$value['arrivalDate'] = intval(strtotime($value['arrivalDate'])) ?: time();
}
if (isset($value['sku']) && \XLite\Core\Converter::isEmptyString($value['sku'])) {
$value['sku'] = null;
}
} elseif ('arrivalDate' === $field) {
$value = intval(strtotime($value)) ?: time();
} elseif ('sku' === $field) {
$value = null;
}
return $value;
}