Webylon 3.2 API Docs
  • Package
  • Class
  • Tree
  • Deprecated
  • Download
Version: current
  • 3.2
  • 3.1

Packages

  • 1c
    • exchange
      • catalog
  • auth
  • Booking
  • building
    • company
  • cart
    • shipping
    • steppedcheckout
  • Catalog
    • monument
  • cms
    • assets
    • batchaction
    • batchactions
    • bulkloading
    • comments
    • content
    • core
    • export
    • newsletter
    • publishers
    • reports
    • security
    • tasks
  • Dashboard
  • DataObjectManager
  • event
  • faq
  • forms
    • actions
    • core
    • fields-basic
    • fields-dataless
    • fields-datetime
    • fields-files
    • fields-formatted
    • fields-formattedinput
    • fields-relational
    • fields-structural
    • transformations
    • validators
  • googlesitemaps
  • guestbook
  • installer
  • newsletter
  • None
  • photo
    • gallery
  • PHP
  • polls
  • recaptcha
  • sapphire
    • api
    • bulkloading
    • control
    • core
    • cron
    • dev
    • email
    • fields-formattedinput
    • filesystem
    • formatters
    • forms
    • i18n
    • integration
    • misc
    • model
    • parsers
    • search
    • security
    • tasks
    • testing
    • tools
    • validation
    • view
    • widgets
  • seo
    • open
      • graph
  • sfDateTimePlugin
  • spamprotection
  • stealth
    • captha
  • subsites
  • userform
    • pagetypes
  • userforms
  • webylon
  • widgets

Classes

  • AdditionalMenuWidget_Item
  • AdvancedSliderHomepageWidget_Item
  • AssetManagerFolder
  • BannerWidget_Item
  • BaseObjectDecorator
  • BookingOrder
  • BookingPaymentMethod
  • BookingService
  • Boolean
  • ButtonsBlockHomepageWidget_Item
  • CarouselHomepageWidget_Item
  • CatalogFilter
  • CatalogRubricsHomepageWidget_CatalogDecorator
  • ClientEmailOrderNotification
  • ClientVKOrderNotification
  • ComponentSet
  • Currency
  • DatabaseAdmin
  • DataObject
  • DataObjectDecorator
  • DataObjectLog
  • DataObjectSet
  • DataObjectSet_Iterator
  • Date
  • DB
  • DBField
  • Decimal
  • DocumentItem
  • DocumentPage_File
  • Double
  • Enum
  • ErrorPageSubsite
  • FileDataObjectTrackingDecorator
  • FileImportDecorator
  • Float
  • FlowerGarden_Size
  • ForeignKey
  • Hierarchy
  • HouseCatalogProductDecorator
  • HTMLText
  • HTMLVarchar
  • Import1CLog
  • Import1CLog_File
  • Import1CLog_Item
  • Import1CLog_Task
  • ImportCatalog1C_PriceType
  • ImportCatalog1C_ProductProp
  • Int
  • ManagerEmailOrderNotification
  • Material3D_File
  • MediawebPage_File
  • MediawebPage_Photo
  • MobileContentDecorator
  • Money
  • MonumentGalleryItem
  • MonumentPhotoGallery
  • MultiEnum
  • MySQLDatabase
  • MySQLQuery
  • Notification
  • OrderDataObject
  • OrderDecorator
  • OrderHandlersDecorator
  • OrderItemDecorator
  • OrderItemVariationDecorator
  • Orders1CExchange_OrdersDecorator
  • OrderService
  • OrderServiceOrder
  • PageIcon
  • PageWidgets
  • Payment
  • PaymentMethodShippingDecorator
  • PaymentOrderExtension
  • Percentage
  • Person
  • PhotoAlbumItem
  • PhotoAlbumProductLinkDecorator
  • PhotoAlbumWidgetLinkDecorator
  • PhotoGalleryHomepageWidget_Item
  • PortraitType
  • PrimaryKey
  • Product3DDecorator
  • ProductCatalogCatalogLinkedDecorator
  • ProductImportLog
  • ProductImportLog_Item
  • ProductParam
  • ProductParamValue
  • ProductVariation
  • RatePeriod
  • RealtyImportLog
  • RealtyImportLog_Item
  • RedirectEntry
  • RoomOrder
  • RoomOrderPerson
  • RoomRate
  • RoomService
  • RoomServiceOrder
  • SberbankPaymentDecorator
  • SeoOpenGraphPageDecorator
  • ServiceOrder
  • ShippingMethodPaymentDecorator
  • ShopCountry
  • SimpleOrderCatalogDecorator
  • SimpleOrderProductDecorator
  • SiteConfigWidgets
  • SiteTreeDecorator
  • SiteTreeImportDecorator
  • SliderHomepageWidget_Item
  • SMSCOrderNotification
  • SMSOrderNotification
  • SortableDataObject
  • SQLMap
  • SQLMap_Iterator
  • SQLQuery
  • SS_Database
  • SS_Datetime
  • SS_Query
  • StringField
  • SubsiteDomain
  • Text
  • TextAnonsWidget_Item
  • Texture3D_File
  • Time
  • Varchar
  • Versioned
  • Versioned_Version
  • VideoCategory
  • VideoEntry
  • VKNotificationQueue
  • WebylonWidget_Item
  • YaMoneyPaymentDecorator
  • Year

Interfaces

  • CompositeDBField
  • CurrentPageIdentifier
  • DataObjectInterface
  1 <?php
  2 /**
  3  * This is a class used to represent key->value pairs generated from database queries.
  4  * The query isn't actually executed until you need it.
  5  * 
  6  * @package sapphire
  7  * @subpackage model
  8  */
  9 class SQLMap extends Object implements IteratorAggregate {
 10     /**
 11      * The query used to generate the map.
 12      * @var SQLQuery
 13      */
 14     protected $query;
 15     protected $keyField, $titleField;
 16     
 17     /**
 18      * Construct a SQLMap.
 19      * @param SQLQuery $query The query to generate this map. THis isn't executed until it's needed.
 20      */
 21     public function __construct(SQLQuery $query, $keyField = "ID", $titleField = "Title") {
 22         if(!$query) {
 23             user_error('SQLMap constructed with null query.', E_USER_ERROR);
 24         }
 25         
 26         $this->query = $query;
 27         $this->keyField = $keyField;
 28         $this->titleField = $titleField;
 29         
 30         parent::__construct();
 31     }
 32     
 33     /**
 34      * Get the name of an item.
 35      * @param string|int $id The id of the item.
 36      * @return string
 37      */
 38     public function getItem($id) {
 39         if($id) {
 40             $baseTable = reset($this->query->from);
 41             $this->query->where[] = "$baseTable.ID = $id";
 42             $record = $this->query->execute()->first();
 43             if($record) {
 44                 $className = $record['ClassName'];
 45                 $obj = new $className($record);
 46                 return $obj->Title;
 47             }
 48         }
 49     }
 50     
 51     public function getIterator() {
 52         $this->genItems();
 53         return new SQLMap_Iterator($this->items->getIterator(), $this->keyField, $this->titleField);
 54     }
 55     
 56     /**
 57      * Get the items in this class.
 58      * @return DataObjectSet
 59      */
 60     public function getItems() {
 61         $this->genItems();
 62         return $this->items;
 63     }
 64     
 65     /**
 66      * Generate the items in this map. This is used by
 67      * getItems() if the items have not been generated already.
 68      */
 69     protected function genItems() {
 70         if(!isset($this->items)) {
 71             $this->items = new DataObjectSet();
 72             $items = $this->query->execute();   
 73             
 74             foreach($items as $item) {
 75                 $className = isset($item['RecordClassName'])  ? $item['RecordClassName'] :  $item['ClassName'];
 76 
 77                 if(!$className) {
 78                     user_error('SQLMap query could not retrieve className', E_USER_ERROR);
 79                 }
 80                 
 81                 $this->items->push(new $className($item));
 82             }
 83         }
 84     }
 85 }
 86 
 87 /**
 88  * @package sapphire
 89  * @subpackage model
 90  */
 91 class SQLMap_Iterator extends Object implements Iterator {
 92     protected $items;
 93     protected $keyField, $titleField;
 94     
 95     function __construct(Iterator $items, $keyField, $titleField) {
 96         $this->items = $items;
 97         $this->keyField = $keyField;
 98         $this->titleField = $titleField;
 99     }
100 
101     
102     /*
103      * Iterator functions - necessary for foreach to work
104      */
105     public function rewind() {
106         return $this->items->rewind() ? $this->items->rewind()->{$this->titleField} : null;
107     }
108     
109     public function current() {
110         return $this->items->current()->{$this->titleField};
111     }
112     
113     public function key() {
114         return $this->items->current()->{$this->keyField};
115     }
116     
117     public function next() {
118         $next = $this->items->next();
119         return isset($next->{$this->titleField}) ? $next->{$this->titleField} : null;
120     }
121     
122     public function valid() {
123         return $this->items->valid();
124     }
125 }
126 
127 ?>
[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -
Webylon 3.2 API Docs API documentation generated by ApiGen 2.8.0