예제 #1
0
 /**
  * Get detailed foreign keys
  *
  * @return array
  */
 protected function getDetailedForeignKeys()
 {
     $list = parent::getDetailedForeignKeys();
     $list[] = array('fields' => array('group_id'), 'referenceRepo' => 'XLite\\Module\\CDev\\ProductOptions\\Model\\OptionGroup', 'delete' => 'SET NULL');
     $list[] = array('fields' => array('option_id'), 'referenceRepo' => 'XLite\\Module\\CDev\\ProductOptions\\Model\\Option', 'delete' => 'SET NULL');
     return $list;
 }
예제 #2
0
파일: Zone.php 프로젝트: kingsj/core
 /**
  * Define cache cells
  *
  * @return array
  */
 protected function defineCacheCells()
 {
     $list = parent::defineCacheCells();
     $list['all'] = array(self::RELATION_CACHE_CELL => array('\\XLite\\Model\\Zone'));
     $list['default'] = array(self::RELATION_CACHE_CELL => array('\\XLite\\Model\\Zone'));
     $list['zone'] = array(self::ATTRS_CACHE_CELL => array('zone_id'), self::RELATION_CACHE_CELL => array('\\XLite\\Model\\Zone'));
     return $list;
 }
예제 #3
0
파일: Country.php 프로젝트: kingsj/core
 /**
  * Define cache cells
  *
  * @return array
  */
 protected function defineCacheCells()
 {
     $list = parent::defineCacheCells();
     $list['all'] = array(self::RELATION_CACHE_CELL => array('\\XLite\\Model\\State'));
     $list['enabled'] = array(self::RELATION_CACHE_CELL => array('\\XLite\\Model\\State'));
     $list['states'] = array(self::RELATION_CACHE_CELL => array('\\XLite\\Model\\State'));
     return $list;
 }
예제 #4
0
 /**
  * Load raw fixture
  *
  * @param \XLite\Model\AEntity $entity  Entity
  * @param array                $record  Record
  * @param array                $regular Regular fields info OPTIONAL
  * @param array                $assocs  Associations info OPTIONAL
  *
  * @return void
  */
 public function loadRawFixture(\XLite\Model\AEntity $entity, array $record, array $regular = array(), array $assocs = array())
 {
     parent::loadRawFixture($entity, $record, $regular, $assocs);
     if (isset($record['cells']) && is_array($record['cells'])) {
         foreach ($record['cells'] as $cell) {
             $entity->__set($cell['name'], $cell['value']);
         }
     }
 }
예제 #5
0
 /**
  * Create a new QueryBuilder instance that is prepopulated for this entity name
  *
  * @param string $alias   Table alias OPTIONAL
  * @param string $indexBy The index for the from. OPTIONAL
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 public function createQueryBuilder($alias = null, $indexBy = null)
 {
     if (!isset($alias)) {
         $alias = $this->getDefaultAlias();
     }
     $qb = parent::createQueryBuilder($alias, $indexBy)->linkInner($alias . '.transaction', 'pt')->linkInner('pt.order', 'o')->linkInner('o.profile', 'p')->linkInner('pt.payment_method', 'pm');
     $qb->andWhere('pt.status != :badstatus')->setParameter('badstatus', 'F');
     return $qb;
 }
예제 #6
0
파일: SessionCell.php 프로젝트: kingsj/core
 /**
  * Process DB schema
  *
  * @param array  $schema Schema
  * @param string $type   Schema type
  *
  * @return array
  */
 public function processSchema(array $schema, $type)
 {
     $schema = parent::processSchema($schema, $type);
     if (\XLite\Core\Database::SCHEMA_CREATE == $type) {
         $schema[] = 'ALTER TABLE `' . $this->getClassMetadata()->getTableName() . '`' . ' ADD CONSTRAINT `session_cell_to_session` FOREIGN KEY `id` (`id`)' . ' REFERENCES `' . $this->_em->getClassMetadata('XLite\\Model\\Session')->getTableName() . '` (`id`)' . ' ON DELETE CASCADE ON UPDATE CASCADE';
     } elseif (\XLite\Core\Database::SCHEMA_UPDATE == $type) {
         $schema = preg_grep('/DROP FOREIGN KEY `?session_cell_to_session`?/Ss', $schema, PREG_GREP_INVERT);
     }
     return $schema;
 }
예제 #7
0
 /**
  * Load raw fixture
  *
  * @param \XLite\Model\AEntity $entity  Entity
  * @param array                $record  Record
  * @param array                $regular Regular fields info OPTIONAL
  * @param array                $assocs  Associations info OPTIONAL
  *
  * @return void
  */
 public function loadRawFixture(\XLite\Model\AEntity $entity, array $record, array $regular = array(), array $assocs = array())
 {
     parent::loadRawFixture($entity, $record, $regular, $assocs);
     if (!empty($record['loadURL'])) {
         $entity->loadFromURL($record['loadURL']);
     }
 }
예제 #8
0
 /**
  * Define cache cells
  *
  * @return array
  */
 protected function defineCacheCells()
 {
     $list = parent::defineCacheCells();
     $list['class_list'] = array(static::ATTRS_CACHE_CELL => array('list', 'zone'));
     return $list;
 }
예제 #9
0
파일: State.php 프로젝트: kirkbauer2/kirkxc
 /**
  * Define cache cells
  *
  * @return array
  */
 protected function defineCacheCells()
 {
     $list = parent::defineCacheCells();
     $list['all'] = array(self::RELATION_CACHE_CELL => array('\\XLite\\Model\\Country'));
     $list['codes'] = array(self::ATTRS_CACHE_CELL => array('state_id'));
     return $list;
 }
예제 #10
0
파일: ARepo.php 프로젝트: kirkbauer2/kirkxc
 /**
  * Save data to cache
  *
  * @param mixed  $data   Data
  * @param string $name   Cache cell name
  * @param array  $params Cache cell parameters OPTIONAL
  *
  * @return void
  */
 protected function saveToCache($data, $name, array $params = array())
 {
     $cell = $this->getCacheCells($name);
     if ($cell) {
         if ($data instanceof \ArrayAccess) {
             $this->detachList($data);
         } elseif ($data instanceof \XLite\Model\AEntity) {
             $data->detach();
         }
         \XLite\Model\Repo\ARepo::getCacheDriver()->save($this->getCellHash($name, $cell, $params), $data, self::CACHE_DEFAULT_TTL);
     } else {
         // TODO - add throw exception
     }
 }
예제 #11
0
 /**
  * Define cache cells
  *
  * @return array
  */
 protected function defineCacheCells()
 {
     $list = parent::defineCacheCells();
     $list['all'] = array();
     return $list;
 }
예제 #12
0
파일: Order.php 프로젝트: kingsj/core
 /**
  * Delete single entity
  *
  * @param \XLite\Model\AEntity $entity Entity to detach
  *
  * @return void
  */
 protected function performDelete(\XLite\Model\AEntity $entity)
 {
     $entity->setOldStatus(null);
     parent::performDelete($entity);
 }
예제 #13
0
 /**
  * Update single entity
  *
  * @param \XLite\Model\AEntity $entity Entity to use
  * @param array                $data   Data to save OPTIONAL
  *
  * @return void
  */
 protected function performUpdate(\XLite\Model\AEntity $entity, array $data = array())
 {
     parent::performUpdate($entity, $data);
     if ($entity->getProduct()) {
         $entity->getProduct()->updateQuickData();
     }
 }
예제 #14
0
 /**
  * Define import query builder
  *
  * @param array $conditions Conditions
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function defineFindOneByImportConditionsQueryBuilder(array $conditions)
 {
     return parent::defineFindOneByImportConditionsQueryBuilder($conditions)->bindCustomer();
 }
예제 #15
0
파일: OrderItem.php 프로젝트: kingsj/core
 /**
  * Get detailed foreign keys
  *
  * @return array
  */
 protected function getDetailedForeignKeys()
 {
     $list = parent::getDetailedForeignKeys();
     $list[] = array('fields' => array('object_id'), 'referenceRepo' => 'XLite\\Model\\Product', 'referenceFields' => array('product_id'), 'delete' => 'SET NULL');
     return $list;
 }
예제 #16
0
파일: Address.php 프로젝트: kingsj/core
 /**
  * Get detailed foreign keys
  *
  * @return array
  */
 protected function getDetailedForeignKeys()
 {
     $list = parent::getDetailedForeignKeys();
     $list[] = array('fields' => array('profile_id'), 'referenceRepo' => 'XLite\\Model\\Profile');
     return $list;
 }
예제 #17
0
 /**
  * Define export iterator query builder
  *
  * @param integer $position Position
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 protected function defineExportIteratorQueryBuilder($position)
 {
     return parent::defineExportIteratorQueryBuilder($position)->orderBy('o.date', 'desc');
 }
예제 #18
0
 /**
  * Get repository type
  *
  * @return string
  */
 public function getRepoType()
 {
     return isset($this->_class->associationMappings['owner']) ? \XLite\Core\Database::getRepo($this->_class->associationMappings['owner']['targetEntity'])->getRepoType() : parent::getRepoType();
 }
예제 #19
0
파일: I18n.php 프로젝트: kirkbauer2/kirkxc
 /**
  * Create a new QueryBuilder instance that is prepopulated for this entity name
  *
  * @param string $alias   Table alias OPTIONAL
  * @param string $indexBy The index for the from.
  * @param string $code    Language code OPTIONAL
  *
  * @return \XLite\Model\QueryBuilder\AQueryBuilder
  */
 public function createQueryBuilder($alias = null, $indexBy = null, $code = null)
 {
     return $this->addLanguageQuery(parent::createQueryBuilder($alias, $indexBy), $alias, $code);
 }
예제 #20
0
 /**
  * Set attribute value (default)
  *
  * @param \XLite\Model\Repo\ARepo $repo    Repository
  * @param \XLite\Model\Product    $product Product
  * @param mixed                   $data    Data
  *
  * @return \XLite\Model\AttributeValue\AttributeValueText
  */
 protected function setAttributeValueDefault(\XLite\Model\Repo\ARepo $repo, \XLite\Model\Product $product, $data)
 {
     $editable = is_array($data) && self::TYPE_TEXT === $this->getType() ? !empty($data['editable']) : null;
     $value = is_array($data) ? $data['value'] : $data;
     if (is_array($value)) {
         $value = array_shift($value);
     }
     $delete = true;
     $attributeValue = null;
     if ('' !== $value || null !== $editable) {
         $attributeValue = $repo->findOneBy(array('product' => $product, 'attribute' => $this));
         if (!$attributeValue) {
             $attributeValue = $this->createAttributeValue($product);
             $delete = false;
         }
         $attributeValue->setValue($value);
         if (null !== $editable) {
             $attributeValue->setEditable($editable);
         }
     }
     if ($delete) {
         foreach ($repo->findBy(array('product' => $product, 'attribute' => $this)) as $data) {
             if (!$attributeValue || $attributeValue->getId() != $data->getId()) {
                 $repo->delete($data, false);
             }
         }
     }
     return $attributeValue;
 }