static function findOneByIdentifier($identifier) { if ($block = lmbActiveRecord::findOne('lmbCmsTextBlock', lmbSQLCriteria::equal('identifier', $identifier))) { return $block; } if (!($default_content = lmbToolkit::instance()->getConf('text_blocks')->get($identifier))) { return null; } $block = new lmbCmsTextBlock(); $block->import($default_content); $block->setIdentifier($identifier); return $block; }
protected function _getBlocks() { $blocks = lmbCollection::toFlatArray(lmbActiveRecord::find('lmbCmsTextBlock'), 'identifier'); $result = array(); foreach ($this->toolkit->getConf('text_blocks') as $identifier => $default_properties) { if (isset($blocks[$identifier])) { $item = $blocks[$identifier]; $item['exists'] = true; } else { $item = new lmbCmsTextBlock(); $item->import($default_properties); $item->setIdentifier($identifier); $item['exists'] = false; } $result[$identifier] = $item; } return $result; }