src/ChickenWire/Controller.php
private function _interpretOptionsWithinView(&$options)
		{

			// Nut'n?
			if (is_null($options)) {
				throw new \Exception("Cannot execute an empty render inside a view.", 1);				
			}

			// A simple string?
			if (is_string($options)) {
				$options = array("partial" => $options);

			}

			// Not an array?
			if (!is_array($options)) {
				$options = array($options);
			}

			// Empty?
			if (count($options) == 0) {

				// Render nothing.
				$options = array("nothing" => true);
				return;

			}

			// Determine my view path
			$viewPath = !is_null($this->request->route->module) ? $this->request->route->module->path . "/Views/" : VIEW_PATH . "/";

			// Model instances (or empty array)?
			if (isset($options[0]) && is_object($options[0]) && is_subclass_of($options[0], "\\ChickenWire\\Model")) {

				// Get class name
				$modelClass = $options[0]->getClass();
				
				// Do a partial render for the record set
				$options = array(
					"partial" => strtolower($modelClass),
					"collection" => $options
				);

			}

			// Partial?
			if (array_key_exists("partial", $options)) {

				// An object?
				if (array_key_exists("object", $options)) {
					$options['collection'] = array($options['object']);
					unset($options['object']);
				}

				// Collection?
				if (array_key_exists("collection", $options) && !array_key_exists("as", $options)) {

					/// Get class name
					$modelClass = $options['collection'][0]->getClass();
					$options['as'] = strtolower($modelClass);

				}

				// A slashed location?
				if (strstr($options['partial'], '/')) {


				} else {

					// Does this route have a model?
					if (is_null($this->request->route->models)) {
						throw new \Exception("This route does not have a model linked to it, so you have to define a template, instead of an action.", 1);
					}
					
					// Remove namespace
					$model = $this->request->route->models[count($this->request->route->models) - 1];
					$model = Str::removeNamespace($model);

					// Convert it to a full template				
					$options['partial'] = Str::pluralize($model) . "/" . $options['partial'];
					
				}

				// Add _ to filename
				if (!preg_match('/\/_[a-z]+$/', $options['partial'])) {
					
					// Add _
					$options['partial'] = substr($options['partial'], 0, strrpos($options['partial'], "/")) . '/_' . substr($options['partial'], strrpos($options['partial'], "/") + 1);

				}

				// Add view path
				$options['partial'] = $viewPath . $options['partial'];

			}


			// Any other options..?

		}
private function _interpretOptionsWithinView(&$options)
		{

			// Nut'n?
			if (is_null($options)) {
				throw new \Exception("Cannot execute an empty render inside a view.", 1);				
			}

			// A simple string?
			if (is_string($options)) {
				$options = array("partial" => $options);

			}

			// Not an array?
			if (!is_array($options)) {
				$options = array($options);
			}

			// Empty?
			if (count($options) == 0) {

				// Render nothing.
				$options = array("nothing" => true);
				return;

			}

			// Determine my view path
			$viewPath = !is_null($this->request->route->module) ? $this->request->route->module->path . "/Views/" : VIEW_PATH . "/";

			// Model instances (or empty array)?
			if (isset($options[0]) && is_object($options[0]) && is_subclass_of($options[0], "\\ChickenWire\\Model")) {

				// Get class name
				$modelClass = $options[0]->getClass();
				
				// Do a partial render for the record set
				$options = array(
					"partial" => strtolower($modelClass),
					"collection" => $options
				);

			}

			// Partial?
			if (array_key_exists("partial", $options)) {

				// An object?
				if (array_key_exists("object", $options)) {
					$options['collection'] = array($options['object']);
					unset($options['object']);
				}

				// Collection?
				if (array_key_exists("collection", $options) && !array_key_exists("as", $options)) {

					/// Get class name
					$modelClass = $options['collection'][0]->getClass();
					$options['as'] = strtolower($modelClass);

				}

				// A slashed location?
				if (strstr($options['partial'], '/')) {


				} else {

					// Does this route have a model?
					if (is_null($this->request->route->models)) {
						throw new \Exception("This route does not have a model linked to it, so you have to define a template, instead of an action.", 1);
					}
					
					// Remove namespace
					$model = $this->request->route->models[count($this->request->route->models) - 1];
					$model = Str::removeNamespace($model);

					// Convert it to a full template				
					$options['partial'] = Str::pluralize($model) . "/" . $options['partial'];
					
				}

				// Add _ to filename
				if (!preg_match('/\/_[a-z]+$/', $options['partial'])) {
					
					// Add _
					$options['partial'] = substr($options['partial'], 0, strrpos($options['partial'], "/")) . '/_' . substr($options['partial'], strrpos($options['partial'], "/") + 1);

				}

				// Add view path
				$options['partial'] = $viewPath . $options['partial'];

			}


			// Any other options..?

		}
private function _interpretOptionsWithinView ( & $ options ) { // Nut'n? if ( is_null ( $ options ) ) { throw new \ Exception ( "Cannot execute an empty render inside a view." , 1 ) ; } // A simple string? if ( is_string ( $ options ) ) { $ options = array ( "partial" => $ options ) ; } // Not an array? if ( ! is_array ( $ options ) ) { $ options = array ( $ options ) ; } // Empty? if ( count ( $ options ) == 0 ) { // Render nothing. $ options = array ( "nothing" => true ) ; return ; } // Determine my view path $ viewPath = ! is_null ( $ this -> request -> route -> module ) ? $ this -> request -> route -> module -> path . "/Views/" : VIEW_PATH . "/" ; // Model instances (or empty array)? if ( isset ( $ options [ 0 ] ) && is_object ( $ options [ 0 ] ) && is_subclass_of ( $ options [ 0 ] , "\\ChickenWire\\Model" ) ) { // Get class name $ modelClass = $ options [ 0 ] -> getClass ( ) ; // Do a partial render for the record set $ options = array ( "partial" => strtolower ( $ modelClass ) , "collection" => $ options ) ; } // Partial? if ( array_key_exists ( "partial" , $ options ) ) { // An object? if ( array_key_exists ( "object" , $ options ) ) { $ options [ 'collection' ] = array ( $ options [ 'object' ] ) ; unset ( $ options [ 'object' ] ) ; } // Collection? if ( array_key_exists ( "collection" , $ options ) && ! array_key_exists ( "as" , $ options ) ) { /// Get class name $ modelClass = $ options [ 'collection' ] [ 0 ] -> getClass ( ) ; $ options [ 'as' ] = strtolower ( $ modelClass ) ; } // A slashed location? if ( strstr ( $ options [ 'partial' ] , '/' ) ) { } else { // Does this route have a model? if ( is_null ( $ this -> request -> route -> models ) ) { throw new \ Exception ( "This route does not have a model linked to it, so you have to define a template, instead of an action." , 1 ) ; } // Remove namespace $ model = $ this -> request -> route -> models [ count ( $ this -> request -> route -> models ) - 1 ] ; $ model = Str :: removeNamespace ( $ model ) ; // Convert it to a full template				 $ options [ 'partial' ] = Str :: pluralize ( $ model ) . "/" . $ options [ 'partial' ] ; } // Add _ to filename if ( ! preg_match ( '/\/_[a-z]+$/' , $ options [ 'partial' ] ) ) { // Add _ $ options [ 'partial' ] = substr ( $ options [ 'partial' ] , 0 , strrpos ( $ options [ 'partial' ] , "/" ) ) . '/_' . substr ( $ options [ 'partial' ] , strrpos ( $ options [ 'partial' ] , "/" ) + 1 ) ; } // Add view path $ options [ 'partial' ] = $ viewPath . $ options [ 'partial' ] ; } // Any other options..? }
Interpret the options given to a render call inside a view.
@param  array    The options to interpret by reference.
@return void
Interpret the options given to a render call inside a view .