/** * Create structure from plain data * * @param array $data * @return \Zork\Model\Structure\StructureAbstract */ public function createStructure(array $data) { $structure = parent::createStructure($data); if ($structure instanceof SiteInfoAwareInterface) { $structure->setSiteInfo($this->getSiteInfo()); } return $structure; }
/** * Get select() default columns * * @return array */ protected function getSelectColumns($columns = null) { if (null === $columns) { $domains = true; } elseif ($index = array_search('domains', $columns)) { $domains = true; unset($columns[$index]); } else { $domains = false; } $columns = parent::getSelectColumns($columns); $platform = $this->getDbAdapter()->getPlatform(); if ($domains) { $columns['domains'] = new Sql\Expression('(' . $this->sql($this->getTableInSchema(static::$domainTableName))->select()->columns(array(new FunctionCall('string_agg', array('domain', "\n"), array(FunctionCall::TYPE_IDENTIFIER, FunctionCall::TYPE_VALUE))))->where(array(new Sql\Predicate\Expression($platform->quoteIdentifierChain(array(static::$domainTableName, 'siteId')) . ' = ' . $platform->quoteIdentifierChain(array(static::$tableName, 'id')))))->getSqlString($platform) . ')'); } return $columns; }
/** * Contructor * * @param \User\Model\User\Right\Structure $userRightStructurePrototype */ public function __construct(Structure $userRightStructurePrototype = null) { parent::__construct($userRightStructurePrototype ?: new Structure()); }
/** * Save element structure to datasource * * @param \Menu\Model\Menu\Structure\ProxyAbstract $structure * @return int Number of affected rows */ public function save(&$structure) { if (!$structure instanceof Structure\ProxyAbstract || empty($structure->type)) { return 0; } $data = ArrayUtils::iteratorToArray($structure->getBaseIterator()); $label = empty($data['label']) ? '' : $data['label']; unset($data['label']); $result = parent::save($data); if ($result > 0) { if (empty($structure->id)) { $structure->setOption('id', $id = $data['id']); } else { $id = $structure->id; } $result += $this->saveLabel($id, $label); foreach ($structure->getPropertiesIterator() as $property => $value) { $result += $this->saveProperty($id, $property, $value); } } return $result; }
/** * Delete a tag * * @param int|array|\Tag\Model\Tag\Structure $tagOrId * @return int */ public function delete($tagOrId) { if (is_numeric($tagOrId)) { $tag = $this->find((int) $tagOrId); } else { if (is_scalar($tagOrId)) { $tag = $this->findByName((string) $tagOrId); } else { if (is_array($tagOrId)) { if (!empty($tagOrId['id'])) { $tag = $this->find((int) $tagOrId['id']); } else { if (!empty($tagOrId['name'])) { $tag = $this->findByName((string) $tagOrId['name']); } } } else { if ($tagOrId instanceof Structure) { $tag = $tagOrId; } } } } if (empty($tag)) { return 0; } return parent::delete($tag); }
/** * Save paragraph form raw data * * @param array $data * @return int|null */ public function saveRawData(array $data) { if (!parent::save($data)) { return null; } return isset($data['id']) ? $data['id'] : null; }
/** * Save element structure to datasource * * @param array|\Customize\Model\Rule\Structure $structure * @return int Number of affected rows */ public function save(&$structure) { $id = $this->getSaveProperty($structure, 'id'); if (empty($id)) { $selector = $this->getSaveProperty($structure, 'selector', ''); $media = $this->getSaveProperty($structure, 'media', ''); $rootId = $this->getSaveProperty($structure, 'rootParagraphId'); $sql = $this->sql(); $select = $sql->select()->columns(array('id'))->where(array('selector' => $selector, 'media' => $media, 'rootParagraphId' => $rootId))->limit(1); $result = $sql->prepareStatementForSqlObject($select)->execute(); if ($result->getAffectedRows()) { foreach ($result as $row) { $this->setSaveProperty($structure, 'id', $row['id']); } } } $result = parent::save($structure); $id = $this->getSaveProperty($structure, 'id'); if ($result > 0 && !empty($id)) { switch (true) { case $structure instanceof Structure: $properties = $structure->getRawProperties(); break; case is_array($structure): $properties = isset($structure['properties']) ? $structure['properties'] : array(); break; case is_object($structure): $properties = isset($structure->properties) ? $structure->properties : array(); break; default: return $result; } $sql = $this->sql($this->getTableInSchema(static::$propertyTableName)); if (empty($properties)) { $delete = $sql->delete()->where(array('ruleId' => $id)); $result += $sql->prepareStatementForSqlObject($delete)->execute()->getAffectedRows(); } else { $propNames = array(); foreach ($properties as $name => $spec) { $propNames[] = $propName = empty($spec['name']) ? $name : $spec['name']; $result += $this->saveProperty($id, $propName, $spec['value'], $spec['priority']); } $delete = $sql->delete()->where(array('ruleId' => $id, new NotIn('name', $propNames))); $result += $sql->prepareStatementForSqlObject($delete)->execute()->getAffectedRows(); } } return $result; }
/** * Contructor * * @param \Mail\Model\Template\Structure $mailTemplateStructurePrototype * @param string $locale */ public function __construct(Structure $mailTemplateStructurePrototype = null, $locale = null) { parent::__construct($mailTemplateStructurePrototype ?: new Structure()); $this->setLocale($locale); }
/** * Contructor * * @param \Grid\Core\Model\Module\Structure $subDomainStructurePrototype */ public function __construct(Structure $subDomainStructurePrototype = null) { parent::__construct($subDomainStructurePrototype ?: new Structure()); }
/** * Get paginator * * @param mixed|null $where * @param mixed|null $order * @param mixed|null $columns * @param mixed|null $joins * @param mixed|null $quantifier * @return \Zend\Paginator\Paginator */ public function getPaginator($where = null, $order = null, $columns = null, $joins = null, $quantifier = null) { $joins = array_merge((array) $joins, array('subdomain' => array('where' => static::$tableName . '.subdomainId = subdomain.id', 'columns' => array('subdomain'), 'type' => Select::JOIN_LEFT), 'paragraph_content' => array('table' => array('paragraph_content' => 'paragraph'), 'where' => static::$tableName . '.contentId = paragraph_content.id', 'columns' => array('contentName' => 'name'), 'type' => Select::JOIN_LEFT))); return parent::getPaginator($where, $order, $columns, $joins, $quantifier); }
/** * Contructor * * @param \MultisiteCentral\Model\Domain\Structure $multisiteCentralDomainStructurePrototype */ public function __construct(Structure $multisiteCentralDomainStructurePrototype = null) { parent::__construct($multisiteCentralDomainStructurePrototype ?: new Structure()); }
/** * Constructor * * @param TestReadWriteStructure $structurePrototype */ public function __construct(TestReadWriteStructure $structurePrototype = null) { parent::__construct($structurePrototype ?: new TestReadWriteStructure()); }
/** * Contructor * * @param \Customize\Model\Extra\Structure $customizeExtraStructurePrototype */ public function __construct(Structure $customizeExtraStructurePrototype = null) { parent::__construct($customizeExtraStructurePrototype ?: new Structure()); }
/** * Save element structure to datasource * * @param \Grid\Banner\Model\Banner\Structure\ProxyAbstract $structure * @return int Number of affected rows */ public function save(&$structure) { if ($structure instanceof Structure) { $data = $structure->toArray(); } else { $data = (array) $structure; } if (isset($data['tagBanners'])) { $tagBanners = (array) $data['tagBanners']; unset($data['tagBanners']); } if (isset($data['localeBanners'])) { $localeBanners = (array) $data['localeBanners']; unset($data['localeBanners']); } if (isset($data['globalBanners'])) { $globalBanners = (array) $data['globalBanners']; unset($data['globalBanners']); } $result = parent::save($data); if ($result > 0) { if (empty($structure->id)) { $structure->setOption('id', $id = $data['id']); } else { $id = $structure->id; } if (isset($tagBanners)) { $result += $this->saveTagBanners($id, $tagBanners); } if (isset($localeBanners)) { $result += $this->saveLocaleBanners($id, $localeBanners); } if (isset($globalBanners)) { $result += $this->saveGlobalBanners($id, $globalBanners); } } return $result; }