Overview

Namespaces

  • None
  • PHP
  • picon

Classes

  • AbstractAjaxBehaviour
  • AbstractAssociatedMarkupSource
  • AbstractBehaviour
  • AbstractCallableOption
  • AbstractChoice
  • AbstractColumn
  • AbstractContextLoader
  • AbstractDatabaseDriver
  • AbstractInjectedDataProvider
  • AbstractJQueryBehaviour
  • AbstractJQueryUIBehaviour
  • AbstractLink
  • AbstractMarkupSource
  • AbstractMultipleChoice
  • AbstractOption
  • AbstractPageClassAuthorisationStrategy
  • AbstractRepeater
  • AbstractSingleChoice
  • AbstractTextComponent
  • AbstractToolbar
  • AbstractValidator
  • AjaxButton
  • AjaxEventBehaviour
  • AjaxFormComponentUpdateBehavior
  • AjaxFormSubmitBehavior
  • AjaxLink
  • AjaxRequestTarget
  • AllowAllAuthorisationStrategy
  • AnnotationRule
  • ApplicationConfigLoadListener
  • ApplicationContext
  • ApplicationContextLoadListener
  • ApplicationInitializer
  • ApplicationInitializerConfigLoadListenerCollection
  • ApplicationInitializerContextLoadListenerCollection
  • ApplicationProfile
  • Args
  • ArrayModel
  • ArrayOption
  • AttributeAppender
  • AttributeModifier
  • AutoContextLoader
  • AutoLoader
  • BasicModel
  • BooleanModel
  • BooleanOption
  • Border
  • BorderMarkupSourcingStratagy
  • BorderResolver
  • Button
  • CacheManager
  • CallbackAjaxCallDecorator
  • CallbackColumn
  • CallbackFunctionOption
  • CallbackOption
  • CallbackRowMapper
  • Check
  • CheckBox
  • CheckBoxGroup
  • CheckChoice
  • ChoiceRenderer
  • ClassNameRule
  • ClassNamespaceRule
  • ClassScanner
  • Comment
  • ComonDomainBase
  • Component
  • ComponentAfterRenderListenerCollection
  • ComponentAuthorisationListener
  • ComponentBeforeRenderListenerCollection
  • ComponentInitializationListenerCollection
  • ComponentInjector
  • ComponentInstantiationListenerCollection
  • ComponentRenderHeadListenerCollection
  • ComponentResolverHelper
  • ComponentTag
  • CompoundPropertyModel
  • Config
  • ConfigLoader
  • ContextLoaderFactory
  • DaoSupport
  • DataBaseTemplate
  • DataGridView
  • DataSource
  • DataSourceConfig
  • DataSourceFactory
  • DataSourceType
  • DataTable
  • DateField
  • DatePickerBehaviour
  • DefaultDataTable
  • DefaultJQueryUIBehaviour
  • DefaultMarkupSource
  • DefaultNotAuthorisedListener
  • DialogBehavior
  • DirectToPageComponentNotAuthorisedListener
  • DraggableBehaviour
  • DropDown
  • EmailAddressValidator
  • EmptyPanel
  • Enum
  • ExceptionPageRequestTarget
  • ExtendResolver
  • FeedbackMessage
  • FeedbackModel
  • FeedbackPanel
  • FileModel
  • FileUploadField
  • Form
  • FormComponent
  • FormComponentLabel
  • FormComponentPanel
  • FunctionOption
  • GridItem
  • GridView
  • HeaderContainer
  • HeaderPartContainer
  • HeaderResolver
  • HeaderResponse
  • HeaderToolbar
  • IdenticalValueValidator
  • Identifier
  • Injector
  • JQueryRenderHeadListener
  • JQueryUIRenderHeadListener
  • Label
  • LabeledMarkupContainer
  • Link
  • ListenerCollection
  • ListenerRequestResolver
  • ListenerRequestTarget
  • ListItem
  • ListMultiple
  • ListView
  • Localizer
  • ManualContextLoader
  • MarkupContainer
  • MarkupElement
  • MarkupLoader
  • MarkupParser
  • MarkupUtils
  • MaximumLengthValidator
  • MaximumValidator
  • MinimumLengthValidator
  • MinimumValidator
  • ModalWindow
  • MySqlDriver
  • MySqliDriver
  • NavigationLink
  • NavigationToolbar
  • Navigator
  • NumbericOption
  • NumericValidator
  • Objects
  • Options
  • PageInstanceRequestResolver
  • PageInstanceRequestTarget
  • PageMap
  • PageMapInitializationListenerCollection
  • PageNotFoundPage
  • PageNotFoundRequestTarget
  • PageRequestResolver
  • PageRequestTarget
  • PageRequestWithListenerTarget
  • PaginatingGridView
  • Panel
  • PanelMarkupSource
  • PanelResolver
  • PasswordField
  • PatternValidator
  • PiconApplication
  • PiconErrorHandler
  • PiconSerializer
  • PiconTag
  • PopupSettings
  • PropertyColumn
  • PropertyModel
  • PropertyOption
  • PropertyResolver
  • Radio
  • RadioChoice
  • RadioGroup
  • RangeLengthValidator
  • RangeValidator
  • RedirectRequestTarget
  • RepeatingView
  • RequestCycle
  • RequestResolverCollection
  • RequiredTextField
  • ResourceReference
  • ResourceRequestResolver
  • ResourceRequestTarget
  • SerializableClosure
  • SortableBehavior
  • StaticTabPanel
  • StringValidator
  • SubClassRule
  • Tab
  • TabCollection
  • TabPanel
  • TextArea
  • TextElement
  • TextField
  • TransparentMarkupContainer
  • ValidatableFormComponentWrapper
  • ValidationResponse
  • WebApplicationSecuritySettings
  • WebComponent
  • WebPage
  • WebRequest
  • WebResponse
  • WrappedCompoundModel
  • XMLDocument
  • XMLParser
  • XMLTag
  • XmlTagType

Interfaces

  • AjaxCallDecorator
  • ApplicationInitializerConfigLoadListener
  • ApplicationInitializerContextLoadListener
  • AuthorisationStrategy
  • Behaviour
  • BehaviourListener
  • CallDecoratorWrapper
  • ChoiceGroup
  • ClassScannerRule
  • Column
  • ComponentAfterRenderListener
  • ComponentAwareModel
  • ComponentBeforeRenderListener
  • ComponentInheritedModel
  • ComponentInitializationListener
  • ComponentInstantiationListener
  • ComponentNotAuthorisedListener
  • ComponentRenderHeadListener
  • ComponentResolver
  • CompoundModel
  • DatabaseDriver
  • DataBaseOperations
  • DataProvider
  • Detachable
  • Equalable
  • FormSubmitListener
  • FormSubmitter
  • Identifiable
  • InitializingBean
  • InjectOnWakeup
  • LinkListener
  • Listener
  • MarkupSource
  • Model
  • Pageable
  • PageMapInitializationListener
  • Request
  • RequestablePage
  • RequestResolver
  • RequestTarget
  • Response
  • RowMapper
  • Validatable
  • Validator
  • XmlElement

Exceptions

  • ConfigException
  • ConversionException
  • RestartRequestOnPageException
  • SQLException
  • UnAuthorisdeException
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: 
  3: /**
  4:  * Picon Framework
  5:  * http://code.google.com/p/picon-framework/
  6:  *
  7:  * Copyright (C) 2011-2012 Martin Cassidy <martin.cassidy@webquub.com>
  8: 
  9:  * Picon Framework is free software: you can redistribute it and/or modify
 10:  * it under the terms of the GNU General Public License as published by
 11:  * the Free Software Foundation, either version 3 of the License, or
 12:  * (at your option) any later version.
 13: 
 14:  * Picon Framework is distributed in the hope that it will be useful,
 15:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 17:  *  General Public License for more details.
 18: 
 19:  * You should have received a copy of the GNU General Public License
 20:  * along with Picon Framework.  If not, see <http://www.gnu.org/licenses/>.
 21:  * */
 22: 
 23: namespace picon;
 24: 
 25: /**
 26:  * Front controller for incoming requests.
 27:  * The represents the process of handling a request in the following steps:
 28:  * <ol>
 29:  * <li>Resolves the request to a target</li>
 30:  * <li>Executes any listener events</li>
 31:  * <li>Produces the response</li>
 32:  * </ol>
 33:  * 
 34:  * @author Martin Cassidy
 35:  * @package web/request/cycle
 36:  * @todo create request listeners
 37:  */
 38: class RequestCycle
 39: {
 40:     private $request;
 41:     private $response;
 42:     private $resolver;
 43:     private $targetStack;
 44:     private $maxStackSize = 10; //@todo put this somewhere else
 45:     
 46:     public function __construct()
 47:     {
 48:         $GLOBALS['requestCycle'] = $this;
 49:         $this->targetStack = new \ArrayObject();
 50:         $this->resolver = new RequestResolverCollection();
 51:         $this->request = new WebRequest();
 52:         $this->response = new WebResponse();
 53:     }
 54:     
 55:     public function process()
 56:     {
 57:         $target = $this->resolver->resolve($this->request);
 58:         
 59:         if($target!=null)
 60:         {
 61:             $this->addTarget($target);
 62:         }
 63:         
 64:         if(count($this->targetStack)==0)
 65:         {
 66:             $this->addTarget(new PageNotFoundRequestTarget());
 67:         }
 68:         
 69: 
 70:         $iterator = $this->targetStack->getIterator();
 71: 
 72:         while($iterator->valid()) 
 73:         {
 74:             try
 75:             {
 76:                 if(PiconApplication::get()->getProfile()->isCleanBeforeOutput())
 77:                 {
 78:                     ob_clean();
 79:                     $this->response->clean();
 80:                 }
 81:                 $iterator->current()->respond($this->response);
 82:             }
 83:             catch(RestartRequestOnPageException $restartEx)
 84:             {
 85:                 $iterator->rewind();
 86:                 $this->targetStack->exchangeArray(array());
 87:                 $this->addTarget(new PageRequestTarget($restartEx->getPageIdentifier()));
 88:             }
 89:             catch(\Exception $ex)
 90:             {
 91:                 $iterator->rewind();
 92:                 $this->targetStack->exchangeArray(array());
 93:                 $this->addTarget(new ExceptionPageRequestTarget($ex));
 94:             }
 95:             $iterator->next();
 96:         }
 97:         
 98:     }
 99:     
100:     public function addTarget($target)
101:     {
102:         if($target==null)
103:         {
104:             return;
105:         }
106:         if(!($target instanceof RequestTarget))
107:         {
108:             throw new \InvalidArgumentException("addTarget() expects a paramater that is an instance of RequestTarget");
109:         }
110:         if($this->targetStack->count()==$this->maxStackSize)
111:         {
112:             throw new \OverflowException(sprintf("The request target stack cannot contain more than %d elements per request", $this->maxStackSize));
113:         }
114:         $this->targetStack->append($target);
115:     }
116:     
117:     public function generateUrl(RequestTarget $target)
118:     {
119:         return $this->resolver->generateUrl($target);
120:     }
121:     
122:     public function getResponse()
123:     {
124:         return $this->response;
125:     }
126:     
127:     public function getRequest()
128:     {
129:         return $this->request;
130:     }
131:     
132:     public static function get()
133:     {
134:         return $GLOBALS['requestCycle'];
135:     }
136:     
137:     public function containsTarget(Identifier $contains)
138:     {
139:         foreach($this->targetStack as $target)
140:         {
141:             $identifier = Identifier::forObject($target);
142:             if($identifier->of($contains))
143:             {
144:                 return true;
145:             }
146:         }
147:         return false;
148:     }
149: }
150: 
151: ?>
152: 
Picon Framework API documentation generated by ApiGen 2.7.0