TYPO3 CMS  TYPO3_6-2
ObjectManagerException.php
Go to the documentation of this file.
1 <?php
3 
20 
24  protected $objectContainer;
25 
29  public function __construct() {
30  $this->objectContainer = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\Container\\Container');
31  }
32 
46  public function __sleep() {
47  // Use get_objects_vars() instead of
48  // a much more expensive Reflection:
49  $properties = get_object_vars($this);
50  unset($properties['objectContainer']);
51  return array_keys($properties);
52  }
53 
63  public function __wakeup() {
64  $this->__construct();
65  }
66 
73  public function isRegistered($objectName) {
74  return class_exists($objectName, TRUE);
75  }
76 
90  public function get($objectName) {
91  $arguments = func_get_args();
92  array_shift($arguments);
93  return $this->objectContainer->getInstance($objectName, $arguments);
94  }
95 
109  public function create($objectName) {
110  $arguments = func_get_args();
111  array_shift($arguments);
112  if ($objectName === 'DateTime') {
113  array_unshift($arguments, $objectName);
114  $instance = call_user_func_array(array('TYPO3\\CMS\\Core\\Utility\\GeneralUtility', 'makeInstance'), $arguments);
115  } else {
116  $instance = $this->objectContainer->getInstance($objectName, $arguments);
117  }
118  if ($instance instanceof \TYPO3\CMS\Core\SingletonInterface) {
119  throw new \TYPO3\CMS\Extbase\Object\Exception\WrongScopeException('Object "' . $objectName . '" is of not of scope prototype, but only prototype is supported by create()', 1265203124);
120  }
121  return $instance;
122  }
123 
131  public function getEmptyObject($className) {
132  return $this->objectContainer->getEmptyObject($className);
133  }
134 }