本文整理汇总了PHP中XLite\Model\AEntity类的典型用法代码示例。如果您正苦于以下问题:PHP AEntity类的具体用法?PHP AEntity怎么用?PHP AEntity使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AEntity类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findOneByRecord
/**
* Find one by record
*
* @param array $data Record
* @param \XLite\Model\AEntity $parent Parent model OPTIONAL
*
* @return \XLite\Model\AEntity|void
*/
public function findOneByRecord(array $data, \XLite\Model\AEntity $parent = null)
{
if (empty($data['code'])) {
$data['code'] = \XLite\Model\Base\Translation::DEFAULT_LANGUAGE;
}
return isset($parent) ? $parent->getTranslation($data['code']) : parent::findOneByRecord($data, $parent);
}
示例2: modifyMoney
/**
* Modify money
*
* @param float $value Value
* @param \XLite\Model\AEntity $model Model
* @param string $property Model's property
* @param array $behaviors Behaviors
* @param string $purpose Purpose
*
* @return void
*/
public static function modifyMoney($value, \XLite\Model\AEntity $model, $property, array $behaviors, $purpose)
{
foreach ($model->getOptions() as $option) {
if ($option->getOption() && $option->getOption()->hasActiveSurcharge('price')) {
$value += $option->getOption()->getSurcharge('price')->getAbsoluteValue();
}
}
return $value;
}
示例3: getColumnValue
/**
* Get column value
*
* @param array $column Column
* @param \XLite\Model\AEntity $entity Model
*
* @return mixed
*/
protected function getColumnValue(array $column, \XLite\Model\AEntity $entity)
{
if (isset($column[static::COLUMN_PRODUCT_ATTRIBUTE])) {
$result = $entity->getAttributeValue($column[static::COLUMN_PRODUCT_ATTRIBUTE]);
$result = $result ? $result->asString() : '';
} else {
$result = parent::getColumnValue($column, $entity);
}
return $result;
}
示例4: update
/**
* Update entity
*
* @param \XLite\Model\AEntity $entity Entity to update
* @param array $data New values for entity properties
* @param boolean $flush Flag OPTIONAL
*
* @return void
*/
public function update(\XLite\Model\AEntity $entity, array $data = array(), $flush = self::FLUSH_BY_DEFAULT)
{
$name = null;
foreach ($entity->getTranslations() as $translation) {
if ($translation->getName()) {
$name = $translation->getName();
break;
}
}
if ($name) {
foreach ($entity->getTranslations() as $translation) {
if (!$translation->getName()) {
$translation->setName($name);
}
}
}
parent::update($entity, $data, $flush);
}
示例5: cloneEntity
/**
* Clone
*
* @return \XLite\Model\AEntity
*/
public function cloneEntity()
{
$entity = parent::cloneEntity();
foreach ($entity->getSoftTranslation()->getRepository()->findBy(array('owner' => $entity)) as $translation) {
$newTranslation = $translation->cloneEntity();
$newTranslation->setOwner($entity);
$entity->addTranslations($newTranslation);
\XLite\Core\Database::getEM()->persist($newTranslation);
}
return $entity;
}
示例6: getAttributeValues
/**
* Return attribute values
*
* @param \XLite\Model\AEntity $model Model
*
* @return array
*/
protected static function getAttributeValues(\XLite\Model\AEntity $model)
{
return $model instanceof \XLite\Module\XC\ProductVariants\Model\ProductVariant ? $model->getProduct()->getAttrValues() : parent::getAttributeValues($model);
}
示例7: isAllowEntityRemove
/**
* Check - remove entity or not
*
* @param \XLite\Model\AEntity $entity Entity
*
* @return boolean
*/
protected function isAllowEntityRemove(\XLite\Model\AEntity $entity)
{
return $entity->isPersistent();
}
示例8: getLanguageHelpMessage
/**
* Get specific language help message
*
* @param \XLite\Model\AEntity $entity Language object
*
* @return string
*/
protected function getLanguageHelpMessage(\XLite\Model\AEntity $entity)
{
$message = null;
if ($entity->getValidModule()) {
$moduleClass = \Includes\Utils\ModulesManager::getClassNameByModuleName($entity->getModule());
$moduleName = sprintf('%s (%s)', $moduleClass::getModuleName(), $moduleClass::getAuthorName());
$message = static::t('This language is added by module and cannot be removed.', array('module' => $moduleName));
} elseif ('en' == $entity->getCode()) {
$message = 'English language cannot be removed as it is primary language for all texts.';
}
return $message;
}
示例9: buildMetodName
/**
* Build metod name
*
* @param \XLite\Model\AEntity $entity Entity
* @param string $pattern Pattern
*
* @return string
*/
protected function buildMetodName(\XLite\Model\AEntity $entity, $pattern)
{
return static::TYPE_COUPONS == $entity->getId() ? sprintf($pattern, 'Coupons') : parent::buildMetodName($entity, $pattern);
}
示例10: linkLoadedEntity
/**
* Link loaded entity to parent object
*
* @param \XLite\Model\AEntity $entity Loaded entity
* @param \XLite\Model\AEntity $parent Entity parent callback
* @param array $parentAssoc Entity mapped propery method
*
* @return void
*/
protected function linkLoadedEntity(\XLite\Model\AEntity $entity, \XLite\Model\AEntity $parent, array $parentAssoc)
{
if (!$parentAssoc['many'] || !$entity->getUniqueIdentifier() || !$parent->{$parentAssoc}['getter']()->contains($entity)) {
// Add entity to parent
$parent->{$parentAssoc}['setter']($entity);
// Add parent to entity
if ($parentAssoc['mappedSetter']) {
$entity->{$parentAssoc}['mappedSetter']($parent);
}
}
}
示例11: performDelete
/**
* Delete single entity
*
* @param \XLite\Model\AEntity $entity Entity to detach
*
* @return void
*/
protected function performDelete(\XLite\Model\AEntity $entity)
{
$entity->setOldPaymentStatus(null);
$entity->setOldShippingStatus(null);
parent::performDelete($entity);
}
示例12: isAllowEntityRemove
/**
* Disable removing special methods
*
* @param \XLite\Model\AEntity $entity Shipping method object
*
* @return boolean
*/
protected function isAllowEntityRemove(\XLite\Model\AEntity $entity)
{
/** @var \XLite\Model\Shipping\Method $entity */
return !$entity->getFree() && !$this->isFixedFeeMethod($entity);
}
示例13: checkCache
/**
* Check cache after enity persist or remove
*
* @return void
*/
public function checkCache()
{
parent::checkCache();
// Check translation owner cache
if ($this->getOwner()) {
$this->getOwner()->checkCache();
}
}
示例14: isHistoryConflict
/**
* Is conflict in history
*
* @return bool
*/
protected function isHistoryConflict()
{
return $this->hasConflict() && $this->conflict->getCleanURL() !== $this->getValue();
}
示例15: __construct
/**
* Constructor
*
* @param array $data Entity properties OPTIONAL
*/
public function __construct(array $data = array())
{
$this->addresses = new \Doctrine\Common\Collections\ArrayCollection();
$this->roles = new \Doctrine\Common\Collections\ArrayCollection();
parent::__construct($data);
}