Version: current

# Class ModelAsController

ModelAsController deals with mapping the initial request to the first `SiteTree`/`ContentController` pair, which are then used to handle the request.

  Object
  ViewableData implements IteratorAggregate
  RequestHandler
  Controller
  ModelAsController implements NestedController

Package: sapphire\control
Located at sapphire/core/control/ModelAsController.php

## Methods summary

`public static `ContentController`` | # `controller_for( `SiteTree` $sitetree, string $action = null )` Get the appropriate `ContentController` for handling a `SiteTree` object, link it to the object and return it. Get the appropriate `ContentController` for handling a `SiteTree` object, link it to the object and return it. #### Parameters $sitetree SiteTree $sitetree $action string $action #### Returns ``ContentController`` ContentController
`public` | # `init( )` Initialisation function that is run before any action on the controller is called. Initialisation function that is run before any action on the controller is called. #### Uses ``BasicAuth::requireLogin()`` #### Overrides `Controller::init`
`public `SS_HTTPResponse`` | # `handleRequest( `SS_HTTPRequest` $request )` #### Parameters $request $request The `SS_HTTPRequest` object that is responsible for distributing request parsing. #### Returns ``SS_HTTPResponse`` SS_HTTPResponse #### Uses ``ModelAsController::getNestedController()`` #### Overrides `Controller::handleRequest`
`public `ContentController`` | # `getNestedController( )` #### Returns ``ContentController`` ContentController #### Used by ``ModelAsController::handleRequest()`` #### Implementation of `NestedController::getNestedController()`
`public static `SiteTree`` | # `find_old_page( string $URLSegment, integer $parentID = 0, mixed $ignoreNestedURLs = false )` #### Parameters $URLSegment string $URLSegment A subset of the url. i.e in /home/contact/ home and contact are URLSegment. $parentID int $parentID The ID of the parent of the page the URLSegment belongs to. $ignoreNestedURLs #### Returns ``SiteTree`` SiteTree

### Methods inherited from Controller

`CurrentMember()`, `Now()`, `PastMember()`, `PastVisitor()`, `can()`, `curr()`, `defaultAction()`, `disableBasicAuth()`, `getAction()`, `getFormOwner()`, `getRequest()`, `getResponse()`, `getSession()`, `getURLParams()`, `getViewer()`, `handleAction()`, `hasAction()`, `hasActionTemplate()`, `has_curr()`, `isAjax()`, `join_links()`, `popCurrent()`, `pushCurrent()`, `redirect()`, `redirectBack()`, `redirectedTo()`, `render()`, `setSession()`, `setURLParams()`

### Methods inherited from RequestHandler

`__construct()`, `allowedActions()`, `checkAccessAction()`, `httpError()`

### Methods inherited from ViewableData

`ATT_val()`, `BaseHref()`, `CSSClasses()`, `ColumnBreak()`, `ColumnCalc()`, `ColumnNumber()`, `ColumnPad()`, `ColumnPos()`, `CurrentPage()`, `Debug()`, `Even()`, `EvenOdd()`, `First()`, `FirstLast()`, `HasPerm()`, `IsAjax()`, `JS_val()`, `Last()`, `Me()`, `Middle()`, `MiddleString()`, `Modulus()`, `MultipleOf()`, `Odd()`, `Pos()`, `RAW_val()`, `SQL_val()`, `ThemeDir()`, `ThemeName()`, `Top()`, `TotalItems()`, `XML_val()`, `__get()`, `__isset()`, `__set()`, `buildCastingCache()`, `cachedCall()`, `castingClass()`, `castingHelper()`, `castingHelperPair()`, `castingObjectCreator()`, `castingObjectCreatorPair()`, `customise()`, `defineMethods()`, `escapeTypeForField()`, `getField()`, `getIterator()`, `getSecurityID()`, `getXMLValues()`, `hasField()`, `hasValue()`, `i18nLocale()`, `iteratorProperties()`, `obj()`, `renderWith()`, `setCustomisedObj()`, `setField()`

### Methods inherited from Object

`__call()`, `__toString()`, `__wakeup()`, `addMethodsFrom()`, `addStaticVars()`, `addWrapperMethod()`, `add_extension()`, `add_static_var()`, `allMethodNames()`, `cacheToFile()`, `cacheToFileWithArgs()`, `clearCache()`, `combined_static()`, `create()`, `createMethod()`, `create_from_string()`, `exists()`, `extInstance()`, `extend()`, `getCustomClass()`, `getExtensionInstance()`, `getExtensionInstances()`, `get_extensions()`, `get_static()`, `hasExtension()`, `hasMethod()`, `has_extension()`, `invokeWithExtensions()`, `is_a()`, `loadCache()`, `parentClass()`, `parse_class_spec()`, `remove_extension()`, `sanitiseCachename()`, `saveCache()`, `set_stat()`, `set_static()`, `set_uninherited()`, `stat()`, `strong_create()`, `uninherited()`, `uninherited_static()`, `useCustomClass()`

### Magic methods summary

## Properties summary

### Properties inherited from Controller

`$action`, `$allowed_actions`, `$baseInitCalled`, `$basicAuthEnabled`, `$controller_stack`, `$request`, `$requestParams`, `$response`, `$session`, `$urlParams`, `$url_handlers`

### Properties inherited from RequestHandler

`$brokenOnConstruct`

### Properties inherited from ViewableData

`$casting`, `$customisedObject`, `$default_cast`, `$failover`, `$iteratorPos`, `$iteratorTotalItems`

### Properties inherited from Object

`$class`, `$extension_instances`, `$extensions`

[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. -