[TYPO3-mvc] rRE: getter/setter generation

Nikolas Hagelstein lists at shr-now.de
Wed Jul 15 16:33:00 CEST 2009


Frans,

>Have you thought about implementing a __call method (in the [..]
I did a similar thing for a generic object I use to handle large forms:
---
<?php
class Tx_Abc_Controllerhelper_Container extends ArrayObject {

	public function __construct($array = array(), $flags = 0, $iterator_class = 'ArrayIterator') {
		parent::__construct($array, $flags = 0, $iterator_class = 'ArrayIterator');
	}

	public function __call($methodName, array $arguments) {
		$argumentName = strtolower($methodName{3} . substr($methodName,4));

		if (substr($methodName, 0, 3) == 'get')
			return $this->__get($argumentName);

		if (substr($methodName, 0, 3) == 'set')
			$this->__set($argumentName, $arguments[0]);

	}

	public function __set($name, $value) {
		$this->offsetSet($name, $value);
	}

	public function __get($name) {
		return $this->offsetGet($name);
	}


}
---

Cheers,
Nikolas



More information about the TYPO3-project-typo3v4mvc mailing list