/**
  * @param object $object
  * @param string $class
  * @param string $name
  * @param object|object[] $value
  */
 public static function writeProperty($object, $class, $name, $value)
 {
     $rp = new Property($class, $name);
     if (!$rp->isPublic()) {
         $rp->setAccessible(TRUE);
     }
     $rp->setValue($object, $value);
 }
 /**
  * Return an accessible property (setAccessible(true)) or null.
  *
  * @param string $class
  * @param string $property
  * @return \Nette\Reflection\Property
  */
 public function getAccessibleProperty($class, $property)
 {
     try {
         $property = new Reflection\Property($class, $property);
         $property->setAccessible(TRUE);
         return $property;
     } catch (\ReflectionException $e) {
         return NULL;
     }
 }
 /**
  * @internal do not use unless you're absolutely sure what you're doing
  * @return bool|mixed
  */
 public function processMessage()
 {
     if (!($next = $this->nextMessage())) {
         return FALSE;
     }
     list($routingKey, $msgBody) = $next;
     if (!($consumer = $this->findConsumer($routingKey))) {
         throw new InvalidStateException(sprintf('No consumer for exchange "%s" with routing key "%s" found.', $this->exchangeOptions['name'], $routingKey));
     }
     $callbackRefl = new Nette\Reflection\Property($consumer, 'callback');
     $callbackRefl->setAccessible(TRUE);
     $callback = $callbackRefl->getValue($consumer);
     return call_user_func($callback, new AMQPMessage($msgBody, []));
 }
Esempio n. 4
0
 public function __invoke($application, $response)
 {
     if ($response instanceof JsonResponse && ($payload = $response->getPayload()) instanceof \stdClass) {
         if (!$this->forwardHasHappened && isset($payload->redirect)) {
             $url = new Http\UrlScript($payload->redirect);
             $url->setScriptPath($this->httpRequest->url->scriptPath);
             $httpRequest = new Http\Request($url);
             if ($this->router->match($httpRequest) !== NULL) {
                 $prop = new Property($application, 'httpRequest');
                 $prop->setAccessible(TRUE);
                 $prop->setValue($application, $httpRequest);
                 $application->run();
                 exit;
             }
         } elseif ($this->forwardHasHappened && !isset($payload->redirect)) {
             $payload->redirect = $application->getPresenter()->link('this');
         }
     }
 }
 public function __invoke($application, $response)
 {
     if ($response instanceof JsonResponse && ($payload = $response->getPayload()) instanceof \stdClass) {
         if (!$this->forwardHasHappened && isset($payload->redirect)) {
             if (($fragmentPos = strpos($payload->redirect, '#')) !== FALSE) {
                 $this->fragment = substr($payload->redirect, $fragmentPos);
             }
             $url = new Http\UrlScript($payload->redirect);
             $url->setScriptPath($this->httpRequest->url->scriptPath);
             $httpRequest = new Http\Request($url);
             if ($this->router->match($httpRequest) !== NULL) {
                 $prop = new Property('Nette\\Application\\Application', 'httpRequest');
                 $prop->setAccessible(TRUE);
                 $prop->setValue($application, $httpRequest);
                 $application->run();
                 exit;
             }
         } elseif ($this->forwardHasHappened && !isset($payload->redirect)) {
             $payload->redirect = $application->getPresenter()->link('this', $application->getPresenter()->getParameters()) . $this->fragment;
             $this->fragment = '';
         }
     }
 }
Esempio n. 6
0
	/**
	 * @param \Nette\Reflection\Property
	 * @param mixed
	 * @return mixed
	 */
	private function getValue(\Nette\Reflection\Property $reflection, $input)
	{
		$reflection->setAccessible(TRUE);
		return $reflection->getValue($input);
	}
Esempio n. 7
0
 private function getClassMap()
 {
     if ($this->registeredClasses !== NULL) {
         return $this->registeredClasses;
     }
     if (property_exists('Nette\\DI\\Container', 'classes')) {
         return $this->registeredClasses = $this->sl->classes;
     }
     $refl = new Nette\Reflection\Property('Nette\\DI\\Container', 'meta');
     $refl->setAccessible(TRUE);
     $meta = $refl->getValue($this->sl);
     $this->registeredClasses = array();
     foreach ($meta['types'] as $type => $serviceIds) {
         if (isset($this->registeredClasses[$type])) {
             $this->registeredClasses[$type] = FALSE;
             continue;
         }
         $this->registeredClasses[$type] = $serviceIds;
     }
     return $this->registeredClasses;
 }