Example #1
0
 /**
  * Creates a new synchronizable instance, attaches it to the registry and returns it.
  *
  * @param string $className The class name of the synchronizable to create
  * @param array  $args      The arguments to be passed to the constructor
  *
  * @return \AppserverIo\Synchronizable\SynchronizableInterface The instance
  */
 public static function create($className, array $args = array())
 {
     // create the instance
     $reflectionClass = new \ReflectionClass($className);
     $synchronizable = $reflectionClass->newInstanceArgs($args);
     // attach the instance
     Registry::attach($synchronizable);
     // return the instance
     return $synchronizable;
 }
Example #2
0
 /**
  * Attaches the instance to the registry again and returns it.
  *
  * @return \AppserverIo\Synchronizable\SynchronizableInterface The instance itself
  */
 public function __copy()
 {
     Registry::attach($this);
     return $this;
 }